Source Code Cross Referenced for Pattern12MultipleInstancesWithoutSynchronization.java in  » Workflow-Engines » bonita-v3.1 » hero » client » samples » patterns » src » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Workflow Engines » bonita v3.1 » hero.client.samples.patterns.src 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Bonita
003:         * Copyright (C) 1999 Bull S.A.
004:         * Bull 68 route de versailles  78434 Louveciennes Cedex France
005:         * Further information: bonita@objectweb.org
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or any later version.
011:         *
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
020:         * USA
021:        --------------------------------------------------------------------------
022:         * BONITA Workflow Patterns sample
023:         *   Pattern 12 : Multiple Instances witout Synchronization
024:         *       Author : Jordi Anguela
025:         *         Date : 2006/03/01 
026:        --------------------------------------------------------------------------
027:         * Example
028:         * In this example we have an activity called 'order_books' that simulates
029:         * a book order. It instantiates three sub processes to manage each book.
030:         * These sub process are independent of next activity 'send_bill' and 
031:         * between them.
032:        --------------------------------------------------------------------------
033:         */package hero.client.samples.patterns.src;
034:
035:        import hero.client.test.SimpleCallbackHandler;
036:        import hero.interfaces.Constants;
037:        import hero.interfaces.ProjectSession;
038:        import hero.interfaces.ProjectSessionHome;
039:        import hero.interfaces.ProjectSessionUtil;
040:
041:        import javax.security.auth.login.LoginContext;
042:
043:        public class Pattern12MultipleInstancesWithoutSynchronization {
044:
045:            public static void main(String[] args) {
046:                try {
047:                    // User Admin login
048:                    char[] password = { 't', 'o', 't', 'o' };
049:                    SimpleCallbackHandler handler = new SimpleCallbackHandler(
050:                            "admin", password);
051:                    LoginContext lc = new LoginContext("TestClient", handler);
052:                    lc.login();
053:
054:                    // Project Session Bean creation
055:                    ProjectSessionHome prjHome = (ProjectSessionHome) ProjectSessionUtil
056:                            .getHome();
057:                    ProjectSession prjSession = prjHome.create();
058:
059:                    // Model creation 
060:                    System.out
061:                            .print("\n   Pattern 12 - Multiple Instances without Synchronization");
062:                    prjSession
063:                            .initModel("Pattern 12 - Multiple Instances without Synchronization");
064:
065:                    // Add activities and set them to Non anticipable
066:                    prjSession.addNode("order_books",
067:                            hero.interfaces.Constants.Nd.AND_JOIN_NODE);
068:                    prjSession.addNode("send_bill",
069:                            hero.interfaces.Constants.Nd.AND_JOIN_NODE);
070:                    prjSession.setNodeTraditional("order_books");
071:                    prjSession.setNodeTraditional("send_bill");
072:                    prjSession.addEdge("order_books", "send_bill");
073:
074:                    // Add Project Properties and set transition conditions
075:                    prjSession.setProperty("books", "3");
076:
077:                    // SubProcess definition
078:                    ProjectSession prjSession2 = prjHome.create();
079:                    prjSession2.initModel("Process book order (SubProcess)");
080:                    prjSession2.addNode("update_stock",
081:                            Constants.Nd.AND_JOIN_NODE);
082:                    prjSession2
083:                            .addNode("send_book", Constants.Nd.AND_JOIN_NODE);
084:                    prjSession2.setNodeTraditional("update_stock");
085:                    prjSession2.setNodeTraditional("send_book");
086:                    prjSession2.addEdge("update_stock", "send_book");
087:                    String update_stockHookScript = "import hero.interfaces.*;\n"
088:                            + "beforeStart(Object engine, Object currentNode) {\n\n\n"
089:                            + "  hero.interfaces.ProjectSessionHome pHome = (hero.interfaces.ProjectSessionHome) hero.interfaces.ProjectSessionUtil.getHome(); \n"
090:                            + "  hero.interfaces.ProjectSession prjSession = pHome.create(); \n"
091:                            + "  prjSession.initModel(currentNode.getBnProject().getName()); \n"
092:                            + "  BnProjectPropertyValue bookNameProp = prjSession.getProperty(\"book_name\"); \n"
093:                            + "  System.out.println(\"   ---> update_stock : \" + bookNameProp.getTheValue()); \n"
094:                            + "}";
095:                    prjSession2.addNodeInterHook("update_stock",
096:                            "update_stock Hook",
097:                            hero.interfaces.Constants.Nd.BEFORESTART,
098:                            hero.interfaces.Constants.Hook.BSINTERACTIVE,
099:                            update_stockHookScript);
100:                    prjSession2
101:                            .addRole("Executor",
102:                                    "Rol that enables to execute the activities inside the SubProcess");
103:                    prjSession2.setUserRole("admin", "Executor");
104:                    prjSession2.setNodeRole("update_stock", "Executor");
105:                    prjSession2.setNodeRole("send_book", "Executor");
106:                    prjSession2.remove();
107:
108:                    // Add Hook to 'Order books' activity to create a SubProces for each book 
109:                    String approveHookScript = "import hero.interfaces.*;\n"
110:                            + "beforeTerminate(Object engine, Object currentNode) {\n\n\n"
111:                            + "  hero.interfaces.ProjectSessionHome pHome = (hero.interfaces.ProjectSessionHome) hero.interfaces.ProjectSessionUtil.getHome(); \n"
112:                            + "  hero.interfaces.ProjectSession prjSession = pHome.create(); \n"
113:                            + "  prjSession.initModel(currentNode.getBnProject().getName()); \n"
114:                            + "  BnProjectPropertyValue booksProp = prjSession.getProperty(\"books\"); \n"
115:                            + "  int books = Integer.parseInt(booksProp.getTheValue()); \n"
116:                            + "  for (int i = 0; i < books; i++) { \n"
117:                            + "    String nodeName = \"book\" + Integer.toString(i); \n"
118:                            + "    prjSession.addNodeSubProcess(nodeName, \"Process book order (SubProcess)\"); \n"
119:                            + "    prjSession.setNodeProperty(nodeName, \"book_name\", nodeName, true); \n"
120:                            + "    prjSession.addEdge(\"order_books\", nodeName); \n"
121:                            + "    prjSession.setNodeRole(nodeName, \"Executor\"); \n"
122:                            + "  } \n" + "}";
123:                    prjSession.addNodeInterHook("order_books",
124:                            "Order books Hook",
125:                            hero.interfaces.Constants.Nd.BEFORETERMINATE,
126:                            hero.interfaces.Constants.Hook.BSINTERACTIVE,
127:                            approveHookScript);
128:
129:                    // Add and set a role for the user admin to execute the activities
130:                    prjSession.addRole("Executor",
131:                            "Rol that enables to execute the activities");
132:                    prjSession.setUserRole("admin", "Executor");
133:                    prjSession.setNodeRole("order_books", "Executor");
134:                    prjSession.setNodeRole("send_bill", "Executor");
135:
136:                    // Check model definition
137:                    prjSession.checkModelDefinition();
138:
139:                    System.out.println("   [ OK ]");
140:                } catch (Exception e) {
141:                    System.out.println("\n\n   [ ERROR ] : " + e);
142:                    e.printStackTrace();
143:                } // Maybe something is wrong
144:            }
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.