Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
1 Automating business processes on the Internet Any enterprise can be described in terms of three major areas: organizational structure, policy/rules/regulations/practices, and business processes. In modeling business workflow and collaboration among the various people, all the interdependencies and information flow within these three areas are normally needed. All three can contain a hierarchical structure. For instance, Business Process can be decomposed into sub-processes, which are made of operations/tasks/methods along with all its suboperations and all the parameters that each operation needs. Likewise, all three can be described in text form or represented in the XML format. <Process PROCESS-NAME=”ProcName”> <Task> <Name>Transaction 1 </Name> <Parameter1>par1_value </Parameter1> <Parameter2>par2_value</Parameter2> … </Task> … </Process> To carry out any business process automatically, an application, called controller system, executes the operations defined in a task list based on the workflow of the application. The controller and the task-list are loosely bound to make software reuse possible. As the business process is represented in an XML-based file, the controller utilizes an XML parser to parse the file. By interpreting each task and, accordingly, calls functions to actually perform the tasks and provide responses. In a distributed environment, the functions represent the services, which can be provided by either local or remote components. ProcessList Controller Agent XML DB Agent XML DB Agent XML DB The Web-based technologies used here include Java servlet, CORBA, XML, XSL, database, JavaBeans, RMI, IIOP, etc. Collaborative Computing (Spring 2002, Prof. Han) 2 The three-tier architecture: presentation layer (client browser), business logic layer (application server), and data layer. The front end is the client browser. The client views web pages generated from HTML and xsl-based XML pages on his browser. The XSL file provides the presentation for the XML file on the Web. <?xml version=’1.0’> <xsl:stylesheet xmlns:xsl:http://www.w3c.org/TR/WD-XSL> Whenever a DB/ITEM node is encountered in the XML file, the lines between the following two statements will be executed. <xsl:for-each select=”DB/ITEM” /> .. </xsl:for-each> The statement <xsl:value-of select=”TYPE”/> causes the value of the attribute TYPE to be displayed. In this case each item attribute will be displayed in a table. This will display a list of items that the vendor has to sell. A button is provided to start the service, e.g., purchase an item with a minimum price. He selects the item desired from the table and clicks the Buy button, to initiate the search and purchasing process through a servlet. The linkage is made possible by including the lines onto HTML page: <FORM METHOD=”POST” ACTION=”http://venus.ececs.uc.edu:8080/examples/Servlet/ServController”> <INPUT NAME=”test-example” TYPE=”Submit” VALUE=”Order”> The backend is a database server, containing a vendor and product information in a xml-based file format. The database name is the root of the file, the items are the nodes on the top level and the attributes of each individual items are the leaves of these nodes. <?xml version=’1.0’> <product-menu xmlns:dt=”uuid:C2F41010-65B3-11d1-A29F-00AA00C14882”> <ITEM> <ID dt:dt=”string”>SPN377891</ID> <TYPE dt:dt=”string”>Paper</TYPE> <SIZE dt:dt=”string”>A4</SIZA> <NAME dt:dt=”string”>Student Choice</NAME> <PRICE dt:dt=”float”>$25.98</PRICE> <UNIT dt:dt=”number”>1000</UNIT> <AVAILABILITY dt:dt=”string”>Yes</AVAILABILITY> </ITEM> …. </product-menu> The application logic on the server end is the servlet. This service includes the search for the requested item. This request is entered through the form and cgi processing. To run servlet, we need to first start Java Servlet Server by using the command: > run ./startserver The servlet is a Java-based cgi. The difference is that in servlet the request/response is more flexible and efficient than cgi. All servlets must implement the interface ‘servlet’. Here the servlet implements the interface by extending the class ‘HttpServlet’, which is included in the javax.servlet.http package. The servlet gets the form data from the doPost and doGet method: public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { doGet(req, res); // req object contains Http header and form data; res object contains data to be sent back } The actual processing in the doGet method: Public void doGet(HttpServletRequest req, HttpServletResponse res) Throws IOException, ServletException { … String queryValue = req.getParameter(“query”); … } Collaborative Computing (Spring 2002, Prof. Han) 3 An example: Out of paper Available in Stockroom? Stockroom FM Dept s =============== StoreDB.xml =============== <?xml version='1.0'> <product-list xmlns:dt="uuid:C2F41010-65B3-11d1-A29F00AA00C14882"> <ITEM> <TYPE dt:dt="string">Paper</TYPE> <NAME dt:dt="string">OfficeMill</Name> <QUANTITY dt:dt="number">1500</QUANTITY> </ITEM> ... Other items To restock – Get price info from vendors To place order – Get approval from the Finance Dept Vendor(s) Finance Dept ================= ControllerDB.xml ================= <?xml version='1.0'> <process-task-list xmlns:dt="uuid:C2F41010-65B3-11d1A29F-00AA00C14882"> <TASK> <TITLE dt:dt="string">Vendor Check</TITLE> <LOCATION dt:dt="string>venus.ececs.uc.edu</LOCATION> <PORT dt:dt="string">3132</PORT> <INTERFACE dt:dt=string">Vendor</INTERFACE> </TASK> <TASK> <TITLE dt:dt="string">Fac Mgmt Check</TITLE> <LOCATION dt:dt="string>venus.ececs.uc.edu</LOCATION> <PORT dt:dt="string">3131</PORT> <INTERFACE dt:dt=string">Store</INTERFACE> </TASK> <TASK> <TITLE dt:dt="string">Finance Dept Check</TITLE> <LOCATION dt:dt="string>venus.ececs.uc.edu</LOCATION> <PORT dt:dt="string">3133</PORT> <INTERFACE dt:dt=string">Finance</INTERFACE> </TASK> <TASK> <TITLE dt:dt="string">Place Order</TITLE> <LOCATION dt:dt="string>venus.ececs.uc.edu</LOCATION> <PORT dt:dt="string">3132</PORT> <INTERFACE dt:dt=string">Vendor</INTERFACE> </TASK> </process-task-list> Collaborative Computing (Spring 2002, Prof. Han) </product-list> =========== VendorDB.xml ============ <?xml version='1.0'> <product-list xmlns:dt="uuid:C2F41010-65B3-11d1-A29F00AA00C14882"> <ITEM> <TYPE dt:dt="string">Paper</TYPE> <ID dt:dt="string">SPN377891</ID> <SIZE dt:dt="string">A4</SIZE> <NAME dt:dt="string">HomeMill</Name> <PRICE dt:dt="float">$24.99</PRICE> <UNIT dt:dt="number">10000</UNIT> <AVAILABILITY dt:dt="string">Yes</AVAILABILITY> </ITEM> .. Other items </product-list> =========== FinanceDB.xml ============= <?xml version='1.0'> <fund-by-dept-list xmlns:dt="uuid:C2F41010-65B3-11d1A29F-00AA00C14882"> <DEPT> <NAME dt:dt="string"> Marketing </NAME> <FUNDS dt:dt="number">20000</FUNDS> <BALANCE dt:dt="number">12500</BALANCE> </DEPT> ... other funds </fund-by-dept-list> 4 – source for the servlet, which acts as a central controller to the application; coordinates the info from a variety of agency sources, listed under ControllerDB.XML describing the detail of each of the local/remote agency implementation. ServController.java Department servers: Each department provides four files: deptDB.xml, dept.java, deptImpl.java, and deptServer.java For example, the stockroom in the Fac. Mgmt. Dept, called Store, manages the inventory: StoreDB.XML – storage/warehouse database in XML form Store.java - the interface for the server, which may represent a department that has database StoreImpl.java – the actual implementation of each server StoreServer.java – the code for naming the server implementation such that client can use the name to access this method; basically this links the name with the implementation. //========================== // ServController.java //========================== import java.io.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; import java.rmi.*; import java.rmi.server.*; import java.lang.*; import java.security.*; import com.datachannel.xml.om.*; import com.datachannel.xml.util.*; public class ServController extends HttpServlet { public void init() { System.setSecurityManager(new RMISecurityManager()); } public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { res.setContentType("text/html"); Printer.Writer out=res.getWriter; HttpSession session=req.getSession(true); Collaborative Computing (Spring 2002, Prof. Han) out.println("<html>("<head>"); out.println("<title>The Response</title>"); out.println("</head><body><h2>"); // get info from the form String dept = req.getParameter("Department"); System.out.println("the dept is:"+dept); String item = req.getParameter("ItemType"); System.out.println("The item type is:"+item); String qty = req.getParameter("Quantity"); System.out.println("The qty is :"+qty); // read in XML file containing the task list String XMLFile = "ControllerDB.xml"; String price = new String("0"); Document doc = new Document(); doc.setValidateOnParse(false); try{ doc.load(XMLFile); IXMLDOMNodeList names=(IXMLDOMNodeList) doc.getElementsByTagName("TASK"); IXMLDOMNodeList node=names.nextNode(); for(;node!=null; node=names.nextNode()) { XMLDOMNodeList chi_node_list = (XMLDOMNodeList) node.getChildNodes(); XMLDOMNodeList chi_node = (XMLDOMNode) chi_node_list.nextNode(); String task_title = chi_node.getText(); System.out.println("The chi_node node name&value are:" + chi_node.getNodeName() + chi_node.getText()); chi_node=(XMLDOMNode)chi_node_list.nextNode(); String loc = chi_node.getText(); chi_node=(XMLDOMNode)chi_node_list.nextNode(); String port= chi_node.getText(); String loc_port=new String("rmi://"+loc+":"+port); // (a) tasks referring to FM server: if(task_title.equals("Fac Mgmt Check")) { out.println("<br>Checking in the Fac. Mgmt. Dept."); loc_port=loc_port.concat("/store"); System.out.println("loc_port: " + loc_port); Store store=(Store)Naming.lookup(loc_port); System.out.println("loc_port:here "); String ret = store.isAvailable(item,qty); if(ret.equals("Available")) { System.out.println("Available in FM"); out.println("<br>Available in FM Dept"); break; } else { continue; } } // (b) tasks referring to Vendor server if(task_title.equals("Vendor Check")) { out.println("<br>Checking Vendor for minimum price"); loc_port=loc_port.concat("/vendor"); Vendor vendor= (Vendor)Naming.lookup(loc_port); price = vendor.findMin(item); float float_price = (new Float(price)).floatValue(); float qtty = (new Float(qty)).floatValue(); float_price = float_price * qtty; 5 System.out.println("The min priced item is :"+price); out.println("The minimum priced item is :"+price); price = (new Float(float_price)).toString(); System.out.println("The total price is:" + price); out.println("<br>The total price is:"+price); continue; } // (C) tasks referring to Finance Dept else if(task_title.equals("Fin Dept Approval")) { out.println("<br>At the Finance Dept, for approval."); loc_port=loc_port.concat("/finance"); Finance finance = (Finance)Naming.lookup(loc_port); String ret = finance.approve(dept.price); System.out.println("The status of the request is:" + ret); out.println("<br>The status of the request is:" + ret); if(ret.equals("Approved")) { continue; } else { System.out.println("Not approved by Finance Dept."); out.println("<br>Not approved by Finance Dept."); break; } } // tasks referring to placing order to Vendor else if(task_title.equals("Place Order")) { loc_port = loc_port.concat("/vendor"); Vendor vendor = (Vendor)Naming.lookup(loc_port); String ret1 = vendor.placeOrder(dept, item, qty); System.out.println("Response from vendor:"+ret1); out.println("<br>Order is placed. "); continue; }}} catch(Exception e) { System.out.println("Exception"+e); out.println("Exception"+e); System.out.println("The code never went into client 111"); out.println("The code never went into cleint 111"); } out.println("<h2><br><br> <a href=\"http://www.ececs.uc.edu/~author/ app_dir/controller.html\"> click here to make another order </a>"); out.println("</body></html>); } public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException { doGet(req, res); } }//=========end of Controller============ Collaborative Computing (Spring 2002, Prof. Han) 6 ============== Store.java ============= // Store.java // The server interface defined for the Fac Mgmt Dept // The implementation is in StoreImpl.java import java.rmi.*; import java.math.*; public interface Store extends java.rmi.Remote { public String isAvailable(String type, String qty) throws RemoteException; } ============== StoreServer.java ================ // StoreServer.java // This takes care of naming the server implementation // In this example, the 'store' name is assigned // That is, client needs to use 'store' to access this server import java.rmi.*; import java.rmi.server.*; import java.lang.*; public class StoreServer { public static void main(String [] args) { System.setSecurityManager(new RMISecurityManager()); try { StoreImpl store=new StoreImpl(); Naming.rebind("//venus.ececs.uc.edu:3131/store",store); } catch (java.rmi.RemoteException e) { System.out.println("Registering exception:"+e); } catch (java.net.MalformedURLException e) { System.out.println("Registering exception:"+e); } } }//===end of StoreServer ========== Collaborative Computing (Spring 2002, Prof. Han) ========== StoreImpl ==========. // StoreImpl.java // In this case, we only have one method: isAvailable() import java.rmi.*; import java.math.*; import java.rmi.server.UnicastRemoteObject; import com.datachannel.xml.om.*; import com.datachannel.xml.util.*; public class StoreImpl extends UnicastRemoteObject implemnts Store { private String XMKFile = 'StoreDB.xml"; public StoreImpl() { super(); } throws RemoteException public String isAvailable(String type, String qty) throws RemoteException { System.out.println(type + qty); Document doc = new Document(); doc.setValidateOnParse(false); try { // parse the XML file doc.load(XMLFile); IXMLDOMNodeList names= (IXMLDOMNodeLIst) doc.getElementsByTagName("ITEM"); IXMLDOMNode node=names.nextNode(); for( ; node != null; node=names.nextNode()) { XMLDOMNodeList chi_node_list = (XMLDOMNodeList) node.getChildNodes(); XMLDOMNode chi_node = (XMLDOMNode) chi_node_list.nextNode(); if(chi_node.getNodeName().equals("TYPE")) { if(chi_node.getText().equals(type)) { while(!chi_node.getNodeName().equals("QUANTITY")) { chi_node=(XMLDOMNode)chi_node_list.nextNode(); } if( (new Integer(chi_node.getText())).intValue() >= (new Integer(qty)).intValue()) { System.out.println("The requested item:" + type + "of required quantity:" + qty + "is available"); return(new String("Available")); } else { System.out.println("Insufficient quantity of the requested item:" + type); return(new String("Not Available")); } }} } } catch(Exception e) { e.printStackTrace(); } System.out.println("Item:+" + type +"Not Found"); return(new String("Not Available")); } }//======end of StoreImpl=================== 7 ========= Vendor.java =========== // Vendor.java // The interface for the Vendor server import java.rmi.*; import java.math.*; public interface Vendor extends java.rmi.Remote { public String findMin(String str) throws RemoteException; public String placeOrder(String str1, String str2, String str3) throws RemoteException; } public VendorImpl() throws RemoteException { super(); } public String placeOrder(String name, String item, String qty) throws RemoteException { System.out.println("Order received from:" + name + "of type " + item + "of quantity:" + qty); return("Order Placed"); } public String findMin(String str) throws RemoteException { int first = 0; float min_price=0.0; String min_id; ============= XMLDOMNode min_node= null; VendorServer.java Document doc = new Document(); ================== doc.setValidateOnParse(false); // VendorServer.java try { // The server program that takes care of naming of the server doc.load(XMLFile); // implementation. In this case, the name 'vendor' is defined. IXMLDOMNodeList names = // It binds the server IP addr and the port to the name 'vendor' (IXMLDOMNodeList)doc.getElementsByTagName("ITEM"); import java.rmi.*; IXMLDOMNode node = names.nextNode(); import java.rmi.server.*; for( ; node!=null; node=names.nextNode()) { import java.lang.*; XMLDOMNodeList chi_node_list = (XMLDOMNodeList)node.getChildNodes(); public class VendorServer XMLDOMNode chi_node = (XMLDOMNode) { chi_node_list.nextNode(); public static void main(String [] args) if(chi_node_getText().equals(str)) { { for( ; chi_node!=null; System.setSecurityManager(new RMISecurityManager()); chi_node=(XMLDOMNode)chi_node_list.nextNode()) { try { if(chi_node.getNodeName().equals("PRICE")) { VendorImpl vendor=new VendorImpl(); String price_text = new String(chi_node.getText()); Naming.rebind("//venus.ececs.uc.edu:3132/vendor",vendor); if(price_text.substring(0,1).equals("$")) } { price_text=price_text_substring(1); } catch (java.rmi.RemoteException e) if(first==0) { { System.out.println("Registering exception:"+e); } min_price=(new Float(price_text)).floatValue(); catch (java.net.MalformedURLException e) first=1; } { System.out.println("Registering URI malformed try { exception:"+e); } if((new Float(price_text)).floatValue()<=min_price){ } min_price=(new Float(price_text).floatValue(); }//======end of VendorServer============== min_node=(XMLDOMNode)node; } } catch (Exception ee) {ee.printStackTrace(); } ============ } VendorImpl } ============ } // VendorImpl.java } // In this case, there are two methods } import java.rmi.*; catch(Exception eee) {eee.printStackTrace(); import java.math.*; String res1 = (new Float(min_price)).toString(); import java.rmi.server.UnicastRemoteObject; min_id = min_node.selectSingleNode("ID").getText(); import com.datachannel.xml.om.*; System.out.println("minimum price:" +res1+ " item id is:" + import com.datachannel.xml.util.*; min_id); return res1; public class VendorImpl extends UnicastRemoteException } { }// ======= end of VendorImpl ================== private String XMLFile = "VendorDB.xml"; Collaborative Computing (Spring 2002, Prof. Han) 8 ============ Finance.java ============ // Finance.java // The interface for the Finance Dept server import java.rmi.*; import java.math.*; " of amount "+price+" is approved"); return(new String("Approved"); } else { System.out.prinln("The transaction by "+dept + " of amount "+price+" is NOT approved"); return(new String("Not Approved"); } } } public interface Finance extends java.rmi.Remote { public String approve(String dept, String price) throws RemoteException; } ============== FinanceImpl ============== // FinanceImpl.java // The implementation of the method approve() import java.rmi.*; import java.math.*; import java.rmi.server.UnicastRemoteObject; import com.datachannel.xml.om.*; import com.datachannel.xml.util.*; public class FinanceImpl extends UnicastRemoteObject implements Finance { private String XMLFile = "FinanceDB.xml"; public FinanceImpl() throws RemoteException { super(); } public String approve (String dept, String price) throws RemoteException { System.out.println(dept+price); Document doc = new Document(); doc.setValidateOnParse(false); try { doc.load(XMLFile); IXMLDOMNodeList names= (IXMLDOMNodeList) doc.getElementsByTagName("DEPT"); IXMLDOMNode node=names.nextNode(); for( ; node!=null; node=names.nextNode()) { XMLDOMNodeList chi_node_list = (XMLDOMNodeList)node.getChildNodes(); XMLDOMNode chi_node = (XMLDOMNode) chi_node_list.nextNode(); if(chi_node_getText().equals("NAME")) { if(chi_node.getText().equals(dept)) { chi_node=(XMLDOMNode)chi_node_list.nextNode(); float funds = (new Float(chi_node.getText())).floatValue(); chi_node=(XMLDOMNode)chi_node_list.nextNode(); float balance=(new Float(chi_node.getText())).floatValue(); if(funds-balance)>=(new Float(price).floatValue())) { System.out.prinln("The transaction by "+dept + Collaborative Computing (Spring 2002, Prof. Han) } } catch(Exception eee) { eee.printStackTrace(); } System.out.prinln("The transaction by " +dept+ "has an error"); return (new String("Error"); } }//======end of FinanceImpl============= ============= FinanceServer.java ================== // FinanceServer.java // This binds the name 'finance' to the server import java.rmi.*; import java.rmi.server.*; import java.lang.*; public class FinanceServer { public static void main(String [] args) { System.setSecurityManager(new RMISecurityManager()); try { FinanceImpl finance = new FinanceImpl(); Naming.rebind("//venus.ececs.uc.edu:3133/finance",finance);} catch (java.rmi.RemoteException e) { System.out.println("Registering exception:"+e); } catch (java.net.MalformedURLException ee) { System.out.println("Registering URL exception:"+ee); } } }// ======end of FinanceServer ===========