KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > navigation > menu > item > listener > UserRemoveBean


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: UserRemoveBean.java,v $
31  * Revision 1.2 2005/04/09 17:19:09 colinmacleod
32  * Changed copyright text to GPL v2 explicitly.
33  *
34  * Revision 1.1.1.1 2005/03/10 17:50:36 colinmacleod
35  * Restructured ivata op around Hibernate/PicoContainer.
36  * Renamed ivata groupware.
37  *
38  * Revision 1.5 2004/07/13 19:41:17 colinmacleod
39  * Moved project to POJOs from EJBs.
40  * Applied PicoContainer to services layer (replacing session EJBs).
41  * Applied Hibernate to persistence layer (replacing entity EJBs).
42  *
43  * Revision 1.4 2004/03/21 21:16:19 colinmacleod
44  * Shortened name to ivata op.
45  *
46  * Revision 1.3 2004/02/01 22:00:34 colinmacleod
47  * Added full names to author tags
48  *
49  * Revision 1.2 2004/01/29 14:31:24 janboros
50  * fixing package declaration
51  * and imports
52  *
53  * Revision 1.1.1.1 2004/01/27 20:57:59 colinmacleod
54  * Moved ivata openportal to SourceForge..
55  *
56  * Revision 1.5 2003/11/07 14:54:15 jano
57  * commitng after fixing some bugs
58  *
59  * Revision 1.4 2003/11/03 11:28:25 jano
60  * commiting addressbook,
61  * tryinjg to fix deploying problem
62  *
63  * Revision 1.3 2003/10/17 12:36:13 jano
64  * fixing problems with building
65  * converting intranet -> portal
66  * Eclipse building
67  *
68  * Revision 1.2 2003/10/15 13:49:57 colin
69  * fixing fo Xdoclet
70  * -----------------------------------------------------------------------------
71  */

72 package com.ivata.groupware.navigation.menu.item.listener;
73
74  import javax.ejb.MessageDrivenBean JavaDoc;
75 import javax.ejb.MessageDrivenContext JavaDoc;
76 import javax.jms.Message JavaDoc;
77 import javax.jms.MessageListener JavaDoc;
78
79  /**
80  * <p>This bean listens for events when a user is removed.</p>
81  *
82  * @since 2003-10-09
83  * @author Colin MacLeod
84  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
85  * @version $Revision: 1.2 $
86  *
87  * @ejb.bean
88  * name = "UserRemoveMenuItem"
89  * display-name = "UserRemoveMenuItem"
90  * acknowledge-mode = "Auto-acknowledge"
91  * destination-type = "javax.jms.Topic"
92  *
93  * @jboss.destination-jndi-name
94  * name = "topic/topicUserRemove"
95  */

96 public class UserRemoveBean implements MessageDrivenBean JavaDoc, MessageListener JavaDoc {
97
98   MessageDrivenContext JavaDoc messageDrivenContext;
99
100   public void ejbCreate() {
101   }
102
103   public void ejbRemove() {
104   }
105
106   public void onMessage(final Message JavaDoc message) {
107 /** TODO
108       // check this is an object message
109       if (!ObjectMessage.class.isInstance(message)) {
110           throw new EJBException("ERROR in folder.UserRemoveBean: unknown messaage class ("
111             + message.getClass().getName()
112             + ")");
113       }
114       ObjectMessage objectMessage = (ObjectMessage) message;
115       UserEvent userEvent = null;
116       try {
117           userEvent = (UserEvent) objectMessage.getObject();
118       } catch (JMSException e) {
119           throw new EJBException(e);
120       }
121       String userName = userEvent.getUserName();
122       try {
123           // remove all menuItems which belong to this user
124           java.util.Collection menuItems = menuItemHome.findByUserName(userName);
125           for (Iterator i = menuItems.iterator(); i.hasNext(); ) {
126               MenuItemLocal item = (MenuItemLocal) i.next();
127               item.remove();
128           }
129       } catch (FinderException e) {
130           throw new EJBException(e);
131       } catch (NamingException e) {
132           throw new EJBException(e);
133       } catch (RemoveException e) {
134           throw new EJBException(e);
135       }
136 */

137   }
138
139   public final void setMessageDrivenContext(final MessageDrivenContext JavaDoc messageDrivenContext) {
140     this.messageDrivenContext = messageDrivenContext;
141   }
142 }
Popular Tags