KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > event > EventManager


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: EventManager.java,v $
31  * Revision 1.3 2005/04/10 18:47:38 colinmacleod
32  * Changed i tag to em and b tag to strong.
33  *
34  * Revision 1.2 2005/04/09 17:19:36 colinmacleod
35  * Changed copyright text to GPL v2 explicitly.
36  *
37  * Revision 1.1 2005/03/10 19:23:03 colinmacleod
38  * Moved to ivata groupware.
39  *
40  * Revision 1.4 2004/07/13 19:42:43 colinmacleod
41  * Moved project to POJOs from EJBs.
42  * Applied PicoContainer to services layer (replacing session EJBs).
43  * Applied Hibernate to persistence layer (replacing entity EJBs).
44  *
45  * Revision 1.3 2004/03/21 21:16:23 colinmacleod
46  * Shortened name to ivata op.
47  *
48  * Revision 1.2 2004/02/01 22:07:29 colinmacleod
49  * Added full names to author tags
50  *
51  * Revision 1.1 2004/01/29 13:48:41 janboros
52  * Moved ivata openportal to SourceForge.
53  * -----------------------------------------------------------------------------
54  */

55 package com.ivata.groupware.business.event;
56
57
58 /**
59  * <p>This class manages system events and notifications.</p>
60  *
61  * @author Colin MacLeod
62  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
63  */

64 public class EventManager {
65     /**
66      * <p>The one and only instance of this class.</p>
67      */

68     private static EventManager eventManager = null;
69
70     /**
71      * <p>Private constructor enforces singleton.</p>
72      */

73     private EventManager() {
74     }
75
76     /**
77      * <p>Retrieve the only instance of this class.</p>
78      */

79     public synchronized static EventManager getInstance() {
80         if (eventManager == null) {
81             eventManager = new EventManager();
82         }
83         return eventManager;
84     }
85
86     /**
87      * <p>Send a <em>JMS</em> message to notify other systems that an important
88      * event has taken place.</p>
89      */

90     public void fireEvent(final Event event) {
91
92 /* TODO
93         JBoss applicationServer = (JBoss) ApplicationServer.getInstance();
94         QueueConnectionFactory queueConnectionFactory =
95             applicationServer.getConnectionFactory();
96         // Create the connection
97         try {
98             QueueConnection queueConnection =
99                 queueConnectionFactory.createQueueConnection();
100
101             // Create the session for sending
102             QueueSession senderSession = queueConnection.createQueueSession(
103                 // use transactions
104                 true,
105                 // Auto ack
106                 0);
107
108             ObjectMessage message = senderSession.createObjectMessage(event);
109
110             // Send the message
111             // Look up the destination
112             Queue queue = null;
113             try {
114                 queue = (Queue) ApplicationServer.getInitialContext().lookup(event.getTopic());
115             } catch (NamingException e1) {
116                 throw new RuntimeException(e1);
117             }
118             // Create a sender
119             QueueSender queueSender = senderSession.createSender(queue);
120             queueSender.send(queue, message);
121             senderSession.commit();
122             senderSession.close();
123             queueConnection.close();
124         } catch(JMSException e) {
125             throw new RuntimeException(e);
126         }
127 */

128     }
129 }
130
Popular Tags