KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > server > JmsServiceEventListener


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.server;
25
26 import com.sun.enterprise.admin.event.AdminEventListener;
27 import com.sun.enterprise.admin.event.jms.*;
28 import com.sun.enterprise.admin.event.AdminEventListenerException;
29 import com.sun.enterprise.config.serverbeans.*;
30 import com.sun.enterprise.config.*;
31 import com.sun.enterprise.connectors.*;
32 import com.sun.enterprise.connectors.system.*;
33
34
35 /**
36  * Listener interface to handle jms-service element events.
37  *
38  * @author: alexkrav
39  */

40 public class JmsServiceEventListener implements
41        com.sun.enterprise.admin.event.jms.JmsServiceEventListener {
42
43     private ConnectorRegistry registry = ConnectorRegistry.getInstance();
44
45     /**
46      * Handles jms-service element removal.
47      * It is called whenever a JmsServiceEvent is received.
48      *
49      * @param event Event to be processed.
50      *
51      * @throws AdminEventListenerException when the listener is unable to
52      * process the event.
53      */

54     public void handleDelete(JmsServiceEvent event)
55              throws AdminEventListenerException {
56     }
57
58     /**
59      * Handles jms-service element modification
60      * (attributes/properties values changed).
61      * It is called whenever a JmsServiceEvent is received.
62      *
63      * @param event Event to be processed.
64      *
65      * @throws AdminEventListenerException when the listener is unable to
66      * process the event.
67      */

68     public void handleUpdate(JmsServiceEvent event)
69              throws AdminEventListenerException {
70         try {
71             JmsService service = getJmsService(event);
72             ActiveJmsResourceAdapter ajr = (ActiveJmsResourceAdapter)
73                 registry.getActiveResourceAdapter(ConnectorRuntime.DEFAULT_JMS_ADAPTER);
74             if (ajr != null) {
75                 ajr.reloadRA(service);
76             }
77             JmsService oldService = ServerBeansFactory.getJmsServiceBean(
78                 event.getOldConfigContext());
79             if(!oldService.getType().equals(service.getType()))
80                 throw new AdminEventListenerException
81                 ("jms type is not dynamically configured");
82         } catch (ConnectorRuntimeException cre) {
83             AdminEventListenerException ale =
84                 new AdminEventListenerException(cre.getMessage());
85             ale.initCause(cre);
86             throw ale;
87         } catch (Exception JavaDoc ce) {
88             AdminEventListenerException ale =
89                 new AdminEventListenerException(ce.getMessage());
90             ale.initCause(ce);
91             throw ale;
92         }
93     }
94
95     /**
96      * Handles element additions.
97      * It is called whenever a JmsServiceEvent is received.
98      *
99      * @param event Event to be processed.
100      *
101      * @throws AdminEventListenerException when the listener is unable to
102      * process the event.
103      */

104     public void handleCreate(JmsServiceEvent event)
105              throws AdminEventListenerException {
106     }
107
108     private JmsService getJmsService(JmsServiceEvent event) throws ConfigException {
109         ConfigContext context = event.getConfigContext();
110         return ServerBeansFactory.getJmsServiceBean(context);
111     }
112 }
113
Popular Tags