Source Code Cross Referenced for Sample1RunningSession.java in  » Workflow-Engines » bonita-v3.1 » hero » client » samples » 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 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package hero.client.samples;
002:
003:        /*
004:         *
005:         * Inscription.java - 
006:         * Copyright (C) 2004 Ecoo Team
007:         * miguel.valdes-faura@ext.bull.net
008:         * 
009:         *
010:         * This program is free software; you can redistribute it and/or
011:         * modify it under the terms of the GNU Lesser General Public License
012:         * as published by the Free Software Foundation; either version 2
013:         * of the License, or (at your option) any later version.
014:         *
015:         * This program is distributed in the hope that it will be useful,
016:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
017:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
018:         * GNU Lesser General Public License for more details.
019:         *
020:         * You should have received a copy of the GNU Lesser General Public License
021:         * along with this program; if not, write to the Free Software
022:         * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
023:         */
024:
025:        /* This class implements the third part of the Business Process example described in the 
026:         *   "BONITA workflow cooperative System Users's Guide
027:         * jack : Custumer 
028:         * john : Custumer Service employee
029:         */
030:
031:        import javax.security.auth.login.LoginContext;
032:        import hero.client.test.SimpleCallbackHandler;
033:
034:        import hero.interfaces.ProjectSession;
035:        import hero.interfaces.ProjectSessionHome;
036:        import hero.interfaces.ProjectSessionUtil;
037:
038:        import hero.interfaces.UserSession;
039:        import hero.interfaces.UserSessionHome;
040:        import hero.interfaces.UserSessionUtil;
041:
042:        import hero.interfaces.UserRegistration;
043:        import hero.interfaces.UserRegistrationHome;
044:        import hero.interfaces.UserRegistrationUtil;
045:
046:        import java.util.*;
047:
048:        public class Sample1RunningSession {
049:
050:            static public void main(String[] args) throws Exception {
051:
052:                // jackOrderProcessing  	  
053:                // "jack" is logged
054:                char[] passwordJack = { 'j', 'a', 'c', 'k' };
055:                SimpleCallbackHandler handlerJack = new SimpleCallbackHandler(
056:                        "jack", passwordJack);
057:                LoginContext lcJack = new LoginContext("TestClient",
058:                        handlerJack);
059:                lcJack.login();
060:
061:                // jack creates User Session Bean  (Activity running)
062:                UserSessionHome userHome = UserSessionUtil.getHome();
063:                UserSession userSession = userHome.create();
064:
065:                Collection names = userSession
066:                        .getProjectInstancesNames("Order Processing");
067:                Iterator i = names.iterator();
068:                String instNameOP = (String) i.next();
069:
070:                // ProjectSessionBean needed (Activity properties setting )
071:                ProjectSessionHome prjHome = ProjectSessionUtil.getHome();
072:                ProjectSession prjSession = prjHome.create();
073:
074:                System.out.println("SessionBean created");
075:
076:                // Verifying roles
077:                try {
078:                    prjSession.initProject(instNameOP);
079:                } catch (Exception e) {
080:                    System.out.println("initProject : exception raised");
081:                }
082:
083:                try {
084:                    Collection roleNames = prjSession
085:                            .getUserRolesInProject("jack");
086:                    Iterator j = roleNames.iterator();
087:                    while (j.hasNext()) {
088:                        System.out.println("user jack : rôle : " + j.next());
089:                    }
090:                } catch (Exception e) {
091:                    System.out
092:                            .println("getUserRolesInProject : exception raised : "
093:                                    + e);
094:                }
095:
096:                // Activity to be started :  
097:                String activityName = "Receive Order";
098:
099:                // etat de l'activité avant lancement 
100:                int state = 0;
101:                try {
102:                    state = prjSession.getNodeState(activityName);
103:                } catch (Exception e) {
104:                    System.out.println("getNodeState : exception raised");
105:                }
106:
107:                System.out.println("Verification : Node State : " + state);
108:
109:                try {
110:                    userSession.startActivity(instNameOP, activityName);
111:                    System.out.println("(Jack) Activity started : "
112:                            + activityName);
113:                } catch (Exception e) {
114:                    System.out.println("startActivity : exception raised : "
115:                            + e);
116:                } // Maybe instance or activity does not exists 
117:
118:                try {
119:                    state = prjSession.getNodeState(activityName);
120:                } catch (Exception e) {
121:                    System.out.println("getNodeState : exception raised");
122:                }
123:
124:                System.out.println("Verification : Node State : " + state);
125:
126:                // Now He has to set the Order Data : setting the values for the properties associated to this activities
127:                try {
128:                    prjSession.setNodeProperty(activityName, "customer_name",
129:                            "jack", true);
130:                    prjSession.setNodeProperty(activityName, "product_name",
131:                            "tv", true);
132:                    prjSession
133:                            .setNodeProperty(activityName, "items", "1", true);
134:                } catch (Exception e) {
135:                    System.out.println("setNodeProperty : exception raised : "
136:                            + e);
137:                } // maybe it raises some exception
138:
139:                System.out.println("properties set");
140:
141:                try {
142:                    Collection Properties = prjSession
143:                            .getNodeProperties(activityName);
144:                    Iterator k = Properties.iterator();
145:                    while (k.hasNext()) {
146:                        System.out.println("Activity  " + activityName
147:                                + " property : " + k.next());
148:                    }
149:                } catch (Exception e) {
150:                    System.out
151:                            .println("getNodeProperties : exception raised : "
152:                                    + e);
153:                }
154:
155:                try {
156:                    userSession.terminateActivity(instNameOP, activityName);
157:                    System.out.println("(Jack) Activity terminated : "
158:                            + activityName);
159:                } catch (Exception e) {
160:                    System.out
161:                            .println("terminateActivity : exception raised : "
162:                                    + e);
163:                } // Maybe instance or activity does not exists 
164:
165:                // johnStartAcceptOrder
166:                // "john" is logged
167:                char[] passwordJohn = { 'j', 'o', 'h', 'n' };
168:                SimpleCallbackHandler handlerJohn = new SimpleCallbackHandler(
169:                        "john", passwordJohn);
170:                LoginContext lcJohn = new LoginContext("TestClient",
171:                        handlerJohn);
172:                lcJohn.login();
173:
174:                names = userSession.getProjectInstancesNames("Accept Order");
175:                i = names.iterator();
176:                String instNameAO = (String) i.next();
177:                ;
178:
179:                // jackStartAskCustomer
180:                // Jack context
181:                lcJack.login();
182:
183:                // Session bean already created
184:                // Activity to be started :  
185:                activityName = "Ask Customer";
186:
187:                try {
188:                    userSession.startActivity(instNameAO, activityName);
189:                    System.out.println("(Jack) Activity started : "
190:                            + activityName);
191:                } catch (Exception e) {
192:                    System.out.println("startActivity : exception raised : "
193:                            + e);
194:                } // Maybe instance or activity does not exists 
195:
196:                try {
197:                    userSession.terminateActivity(instNameAO, activityName);
198:                    System.out.println("(Jack) Activity terminated : "
199:                            + activityName);
200:                } catch (Exception e) {
201:                    System.out
202:                            .println("terminateActivity : exception raised : "
203:                                    + e);
204:                } // Maybe instance or activity does not exists 
205:
206:                //johnTermAcceptOrder
207:                // John context
208:                lcJohn.login();
209:
210:                // Session bean already created
211:
212:                // John starts and terminates "Notify Sales"
213:                activityName = "Notify Sales";
214:                try {
215:                    userSession.startActivity(instNameAO, activityName);
216:                    System.out.println("(John) Activity started : "
217:                            + activityName);
218:                } catch (Exception e) {
219:                    System.out.println("startActivity : exception raised : "
220:                            + e);
221:                } // Maybe instance or activity does not exists 
222:
223:                try {
224:                    userSession.terminateActivity(instNameAO, activityName);
225:                    System.out.println("(John) Activity terminated : "
226:                            + activityName);
227:                } catch (Exception e) {
228:                    System.out
229:                            .println("terminateActivity : exception raised : "
230:                                    + e);
231:                } // Maybe instance or activity does not exists 
232:
233:                System.out.println(" ");
234:                System.out
235:                        .println(" ------------------------------------------");
236:                System.out.println(" First Iteration terminated");
237:                System.out
238:                        .println(" Play other iterations with Bonita manager tool (jack and john users)");
239:                System.out
240:                        .println(" To stop : just use Bonita Web admin page (admin user) and ");
241:                System.out
242:                        .println(" position the once_more property to KO for the Accept Order_Instance1 SUB PROJECT ");
243:                System.out
244:                        .println("(and not activity) before terminating the Notify Sales activity ");
245:                System.out
246:                        .println(" ------------------------------------------");
247:
248:            }
249:
250:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.