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


001:        package hero.session;
002:
003:        /**
004:         *
005:         * Bonita
006:         * Copyright (C) 1999 Bull S.A.
007:         * Bull 68 route de versailles  78434 Louveciennes Cedex France
008:         * Further information: bonita@objectweb.org
009:         *
010:         * This library is free software; you can redistribute it and/or
011:         * modify it under the terms of the GNU Lesser General Public
012:         * License as published by the Free Software Foundation; either
013:         * version 2.1 of the License, or any later version.
014:         *
015:         * This library 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 GNU
018:         * Lesser General Public License for more details.
019:         *
020:         * You should have received a copy of the GNU Lesser General Public
021:         * License along with this library; if not, write to the Free Software
022:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
023:         * USA
024:         *
025:         *
026:         --------------------------------------------------------------------------
027:         * $Id: JMSServicesSessionBean.java,v 1.14 2005/10/17 15:40:34 brice Exp $
028:         *
029:         --------------------------------------------------------------------------
030:         */
031:
032:        import hero.util.EventConstants;
033:        import hero.util.BonitaServiceException;
034:        import javax.ejb.CreateException;
035:        import javax.ejb.EJBException;
036:        import javax.ejb.SessionBean;
037:        import javax.ejb.SessionContext;
038:
039:        import javax.jms.TopicConnectionFactory;
040:        import javax.jms.Topic;
041:        import javax.jms.TopicConnection;
042:        import javax.jms.TopicSession;
043:        import javax.jms.TopicPublisher;
044:        import javax.jms.TextMessage;
045:        import javax.jms.JMSException;
046:        import javax.jms.Session;
047:
048:        import java.rmi.RemoteException;
049:        import java.util.Hashtable;
050:        import java.util.Enumeration;
051:
052:        import hero.util.BonitaServiceLocator;
053:        import hero.util.HeroException;
054:
055:        /**
056:         * Session Bean Template
057:         *
058:         * @ejb:bean name="JMSServicesSession"
059:         *           display-name="JMSServices Bean"
060:         *           type="Stateful"
061:         *           transaction-type="Container"
062:         *           jndi-name="ejb/hero/JMSServicesSession"
063:         *           local-jndi-name="ejb/hero/JMSServicesSession_L"
064:         *
065:         * @ejb:transaction type="Required"
066:         * @ejb.permission unchecked="yes" 
067:         * @ejb.security-identity run-as="SuperAdmin"
068:         * @jonas.bean
069:         *      ejb-name="JMSServicesSession"
070:         *      jndi-name="ejb/hero/JMSServicesSession"
071:         * 
072:         * @jboss.container-configuration name="Standard Stateful SessionBean for Bonita"
073:         **/
074:
075:        public class JMSServicesSessionBean implements  SessionBean,
076:                EventConstants {
077:
078:            private TopicConnectionFactory topicConnectionFactory = null;
079:            private Topic topic = null;
080:
081:            // -------------------------------------------------------------------------
082:            // Members 
083:            // -------------------------------------------------------------------------
084:
085:            private SessionContext mContext;
086:
087:            // -------------------------------------------------------------------------
088:            // Methods
089:            // -------------------------------------------------------------------------  
090:
091:            /**
092:             * Send messages, varying text slightly.
093:             *
094:             * @param evt Hashtable that includes the message
095:             * @param type Jms type
096:             * @ejb.permission unchecked="yes" 
097:             * @ejb:interface-method view-type="both"
098:             *
099:             **/
100:            public void send(Hashtable evt, String type) throws Exception {
101:                try {
102:
103:                    TopicSession topicSession = null;
104:                    TopicConnection topicConnection = null;
105:                    TopicPublisher topicPublisher = null;
106:                    TextMessage message = null;
107:                    StringBuffer subs = new StringBuffer("");
108:
109:                    try {
110:                        topicConnection = topicConnectionFactory
111:                                .createTopicConnection();
112:                        topicSession = topicConnection.createTopicSession(
113:                                false, Session.AUTO_ACKNOWLEDGE);
114:                    } catch (JMSException e) {
115:                        System.out.println("Exception occurred: "
116:                                + e.toString());
117:                        throw new CreateException(e.getMessage());
118:                    }
119:
120:                    try {
121:                        topicPublisher = topicSession.createPublisher(topic);
122:                        message = topicSession.createTextMessage();
123:                        Enumeration keys = evt.keys();
124:                        while (keys.hasMoreElements()) {
125:                            String key = (String) keys.nextElement();
126:                            String value = (String) evt.get(key);
127:                            message.setStringProperty(key, value);
128:                            subs.append(" " + key + " = '" + value + "' AND ");
129:                            evt.put(key, value);
130:                        }
131:                        message.setJMSType(type);
132:
133:                        String res = subs.toString();
134:                        String result = res.substring(0, res.length() - 4);
135:                        message.setText(result);
136:
137:                        topicPublisher.publish(message);
138:                        topicSession.close();
139:                        topicConnection.close();
140:
141:                    } catch (JMSException e) {
142:                        System.out.println("Exception occurred: "
143:                                + e.toString());
144:                        throw new Exception(e.getMessage());
145:                    }
146:                } catch (HeroException he) {
147:                }// remove project consistency
148:            }
149:
150:            /**
151:             * Send Node Event.
152:             *
153:             * @param event The name of the event
154:             * @param projectName The name of the project
155:             * @param nodeName The name of the node
156:             * @param type The type of the node
157:             * @param state The state of the node
158:             * @param userName The name of the user
159:             * @ejb.permission unchecked="yes" 
160:             * @ejb:interface-method view-type="both"
161:             *
162:             **/
163:            public void sendNodeEvent(String event, String projectName,
164:                    String nodeName, int type, int state, String userName) {
165:                try {
166:                    Hashtable evt = new Hashtable();
167:                    evt.put(EVENT, event);
168:                    evt.put(PROJECTNAME, projectName);
169:                    evt.put(NODENAME, nodeName);
170:                    evt.put(NODETYPE, (new Integer(type)).toString());
171:                    evt.put(NODESTATE, (new Integer(state)).toString());
172:                    evt.put(USERNAME, userName);
173:                    this .send(evt, NODE);
174:                } catch (Exception e) {
175:                    e.printStackTrace();
176:                }
177:            }
178:
179:            /**
180:             * Send Edge Event.
181:             *
182:             * @param event The name of the event
183:             * @param projectName The name of the project
184:             * @param edgeName The name of the edge
185:             * @param nodeIn The name of the in node
186:             * @param nodeOut The name of the out node
187:             * @param userName The name of the user
188:             * @ejb.permission unchecked="yes" 
189:             * @ejb:interface-method view-type="both"
190:             *
191:             **/
192:            public void sendEdgeEvent(String event, String projectName,
193:                    String edgeName, String nodeIn, String nodeOut,
194:                    String userName) {
195:                try {
196:                    Hashtable evt = new Hashtable();
197:                    evt.put(EVENT, event);
198:                    evt.put(PROJECTNAME, projectName);
199:                    evt.put(EDGENAME, edgeName);
200:                    evt.put(NODEIN, nodeIn);
201:                    evt.put(NODEOUT, nodeOut);
202:                    evt.put(USERNAME, userName);
203:                    this .send(evt, EDGE);
204:                } catch (Exception e) {
205:                    e.printStackTrace();
206:                }
207:            }
208:
209:            /**
210:             * Send Project Event.
211:             * 
212:             * @param event The name of the event
213:             * @param projectName The name of the project
214:             * @ejb.permission unchecked="yes" 
215:             * @ejb:interface-method view-type="both"
216:             *
217:             **/
218:            public void sendProjectEvent(String event, String projectName) {
219:                try {
220:                    Hashtable evt = new Hashtable();
221:                    evt.put(EVENT, event);
222:                    evt.put(PROJECTNAME, projectName);
223:                    this .send(evt, PROJECT);
224:                } catch (Exception e) {
225:                    e.printStackTrace();
226:                }
227:            }
228:
229:            /**
230:             * Send Project Event.
231:             *
232:             * @param event The name of the event
233:             * @param projectName The name of the project
234:             * @param userName The name of the user
235:             * @ejb.permission unchecked="yes" 
236:             * @ejb:interface-method view-type="both"
237:             *
238:             **/
239:
240:            public void sendProjectEvent(String event, String projectName,
241:                    String userName) {
242:                try {
243:                    Hashtable evt = new Hashtable();
244:                    evt.put(EVENT, event);
245:                    evt.put(PROJECTNAME, projectName);
246:                    evt.put(USERNAME, userName);
247:                    this .send(evt, PROJECT);
248:                } catch (Exception e) {
249:                    e.printStackTrace();
250:                }
251:            }
252:
253:            /**
254:             * Send Project Event.
255:             *
256:             * @param event The name of the event
257:             * @param projectName The name of the project
258:             * @param nodeName The name of the node
259:             * @param userName The name of the user
260:             * @ejb.permission unchecked="yes" 
261:             * @ejb:interface-method view-type="both"
262:             *
263:             **/
264:            public void sendProjectEvent(String event, String projectName,
265:                    String nodeName, String userName) {
266:                try {
267:                    Hashtable evt = new Hashtable();
268:                    evt.put(EVENT, event);
269:                    evt.put(PROJECTNAME, projectName);
270:                    evt.put(NODENAME, nodeName);
271:                    evt.put(USERNAME, userName);
272:                    this .send(evt, PROJECT);
273:                } catch (Exception e) {
274:                    e.printStackTrace();
275:                }
276:            }
277:
278:            /**
279:             * Send Iteration Event.
280:             * 
281:             * @param event The name of the event
282:             * @param projectName The name of the project
283:             * @ejb.permission unchecked="yes" 
284:             * @ejb:interface-method view-type="both"
285:             *
286:             **/
287:            public void sendIterationEvent(String event, String projectName,
288:                    String from, String to) {
289:                try {
290:                    Hashtable evt = new Hashtable();
291:                    evt.put(EVENT, event);
292:                    evt.put(PROJECTNAME, projectName);
293:                    evt.put(FROM, from);
294:                    evt.put(TO, to);
295:                    this .send(evt, ITERATION);
296:                } catch (Exception e) {
297:                    e.printStackTrace();
298:                }
299:            }
300:
301:            /**
302:             * Send User Event.
303:             *
304:             * @param event The name of the event
305:             * @param projectName The name of the project
306:             * @param userName The name of the user
307:             * @ejb.permission unchecked="yes" 
308:             * @ejb:interface-method view-type="both"
309:             *
310:             **/
311:            public void sendUserEvent(String event, String projectName,
312:                    String userName) {
313:                try {
314:                    Hashtable evt = new Hashtable();
315:                    evt.put(EVENT, event);
316:                    evt.put(PROJECTNAME, projectName);
317:                    evt.put(USERNAME, userName);
318:                    this .send(evt, USER);
319:                } catch (Exception e) {
320:                    e.printStackTrace();
321:                }
322:            }
323:
324:            /**
325:             * Send Role Event.
326:             *
327:             * @param event The name of the event
328:             * @param projectName The name of the project
329:             * @param roleName The name of the role
330:             * @ejb.permission unchecked="yes" 
331:             * @ejb:interface-method view-type="both"
332:             *
333:             **/
334:            public void sendRoleEvent(String event, String projectName,
335:                    String roleName) {
336:                try {
337:                    Hashtable evt = new Hashtable();
338:                    evt.put(EVENT, event);
339:                    evt.put(PROJECTNAME, projectName);
340:                    evt.put(ROLENAME, roleName);
341:                    this .send(evt, ROLE);
342:                } catch (Exception e) {
343:                    e.printStackTrace();
344:                }
345:            }
346:
347:            /**
348:             * Send User Role Event.
349:             *
350:             * @param event The name of the event
351:             * @param projectName The name of the project
352:             * @param userName The name of the user
353:             * @param roleName The name of the role
354:             * @ejb.permission unchecked="yes" 
355:             * @ejb:interface-method view-type="both"
356:             *
357:             **/
358:            public void sendUserRoleEvent(String event, String projectName,
359:                    String userName, String roleName) {
360:                try {
361:                    Hashtable evt = new Hashtable();
362:                    evt.put(EVENT, event);
363:                    evt.put(PROJECTNAME, projectName);
364:                    evt.put(USERNAME, userName);
365:                    evt.put(ROLENAME, roleName);
366:                    this .send(evt, USERROLE);
367:                } catch (Exception e) {
368:                    e.printStackTrace();
369:                }
370:            }
371:
372:            private void initJMS() throws BonitaServiceException {
373:                BonitaServiceLocator serviceLocator = BonitaServiceLocator
374:                        .getInstance();
375:                topicConnectionFactory = (TopicConnectionFactory) serviceLocator
376:                        .getResource(BonitaServiceLocator.Services.TOPIC_CONNECTION_FACTORY);
377:                topic = (Topic) serviceLocator
378:                        .getResource(BonitaServiceLocator.Services.TOPIC);
379:            }
380:
381:            /**
382:             * Create the All Projects Session Bean
383:             *
384:             * @throws CreateException 
385:             *
386:             * @ejb.permission unchecked="yes" 
387:             * @ejb:create-method view-type="both"
388:             **/
389:
390:            public void ejbCreate() throws CreateException {
391:                try {
392:                    initJMS();
393:                } catch (BonitaServiceException e) {
394:                    throw new CreateException(e.getMessage());
395:                }
396:            }
397:
398:            public void setSessionContext(final javax.ejb.SessionContext context) {
399:                mContext = context;
400:            }
401:
402:            public void ejbRemove() throws EJBException, RemoteException {
403:            }
404:
405:            public void ejbActivate() throws EJBException, RemoteException {
406:                try {
407:                    initJMS();
408:                } catch (BonitaServiceException e) {
409:                    throw new EJBException(e);
410:                }
411:            }
412:
413:            public void ejbPassivate() throws EJBException, RemoteException {
414:                topicConnectionFactory = null;
415:                topic = null;
416:            }
417:
418:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.