KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > meta > AdminConfigEventListener


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 /*
25  * EventListener of AdminConfig Changes - keeps consistent MBean space
26  * ajusting it according AdminConfigContext changes
27  *
28  * $Id: AdminConfigEventListener.java,v 1.3 2005/12/25 03:47:36 tcfujii Exp $
29  * @author: alexkrav
30  *
31  * $Log: AdminConfigEventListener.java,v $
32  * Revision 1.3 2005/12/25 03:47:36 tcfujii
33  * Updated copyright text and year.
34  *
35  * Revision 1.2 2005/06/27 21:19:43 tcfujii
36  * Issue number: CDDL header updates.
37  *
38  * Revision 1.1.1.1 2005/05/27 22:52:02 dpatil
39  * GlassFish first drop
40  *
41  * Revision 1.2 2004/11/14 07:04:20 tcfujii
42  * Updated copyright text and/or year.
43  *
44  * Revision 1.1 2004/04/05 16:44:05 kravtch
45  * admin/meta/AdminConfigEventListener: new configcontext listener's code
46  * This listener is for synchronization of ConfigBeans changes with both MBeans and dotted-name spaces.
47  * admin/meta/MBeanRegistry: added methods (adoptConfigBeanDelete/Add) implementing beans ajustment
48  * admin/config/BaseConfigMBean: calls from MBean's postRegister/unregister methods to dotted-name-manager is commented out.
49  *
50  * Reviewer: Sridatta
51  * Tests Passed: QuickLook + UnitTest
52  *
53 */

54
55 package com.sun.enterprise.admin.meta;
56
57 import com.sun.enterprise.config.ConfigBean;
58 import com.sun.enterprise.config.ConfigContextEvent;
59 import com.sun.enterprise.config.ConfigContextEventListener;
60
61
62 public class AdminConfigEventListener implements ConfigContextEventListener
63 {
64     /**
65         Creates new <code>AdminConfigEventListener</code>.
66     */

67     public AdminConfigEventListener()
68     {
69         super();
70     }
71
72     // "dummy" methods to satisfy interface
73
public void preAccessNotification(ConfigContextEvent ccce) {}
74     public void postAccessNotification(ConfigContextEvent ccce) {}
75     public void preChangeNotification(ConfigContextEvent ccce) {}
76
77     /**
78      * after config add, delete, set, update or flush. type is in ccce
79      */

80     public void postChangeNotification(ConfigContextEvent event)
81     {
82         boolean bAdded;
83         //set bAdded (shows whether bean added or removed)
84
if((event.getType()).equals(event.POST_DELETE_CHANGE))
85             bAdded = false;
86         else if((event.getType()).equals(event.POST_ADD_CHANGE))
87             bAdded = true;
88         else if((event.getType()).equals(event.POST_SET_CHANGE))
89             bAdded = true;
90         else
91             return;
92         //here we are only for add/set/delete operations
93
//we are interesting only in bean operations:
94
Object JavaDoc bean = event.getObject();
95         if(bean instanceof ConfigBean)
96         {
97             String JavaDoc domainName = MBeanRegistryFactory.getAdminContext().getDomainName();
98             if(bAdded)
99                 MBeanRegistryFactory.getAdminMBeanRegistry().adoptConfigBeanAdd((ConfigBean)bean, domainName);
100             else
101                 MBeanRegistryFactory.getAdminMBeanRegistry().adoptConfigBeanDelete((ConfigBean)bean, domainName);
102         }
103     }
104 }
105
Popular Tags