KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > mbeans > DottedNameMBeansIniter


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  * $Header: /cvs/glassfish/admin/mbeans/src/java/com/sun/enterprise/admin/mbeans/DottedNameMBeansIniter.java,v 1.3 2005/12/25 03:42:19 tcfujii Exp $
26  * $Revision: 1.3 $
27  * $Date: 2005/12/25 03:42:19 $
28  */

29 package com.sun.enterprise.admin.mbeans;
30  
31
32 import javax.management.MBeanServer JavaDoc;
33 import javax.management.ObjectName JavaDoc;
34 import javax.management.ObjectInstance JavaDoc;
35
36 import com.sun.enterprise.admin.common.ObjectNames;
37 import com.sun.enterprise.admin.util.ClassUtil;
38
39 import com.sun.enterprise.admin.dottedname.DottedNameRegistry;
40 import com.sun.enterprise.admin.dottedname.DottedNameGetSetMBean;
41 import com.sun.enterprise.admin.server.core.AdminService;
42 import com.sun.enterprise.admin.AdminContext;
43 import java.lang.reflect.Constructor JavaDoc;
44 import java.lang.reflect.InvocationTargetException JavaDoc;
45
46 /*
47     A registry for DottedName-to-ObjectName mapping.
48  */

49 public class DottedNameMBeansIniter
50 {
51         public
52     DottedNameMBeansIniter( MBeanServer JavaDoc server )
53         throws Exception JavaDoc
54     {
55         init( server );
56     }
57     
58     
59         public void
60     init( MBeanServer JavaDoc server )
61         throws Exception JavaDoc
62     {
63         // config registry
64
final DottedNameRegistry registry = new DottedNameRegistryMBeanImpl();
65         server.registerMBean( registry, ObjectNames.getDottedNameRegistryObjectName() );
66         
67         // monitoring registry
68
final DottedNameRegistry monitoringRegistry = new DottedNameRegistryMBeanImpl();
69         server.registerMBean( monitoringRegistry, ObjectNames.getDottedNameMonitoringRegistryObjectName() );
70         
71         
72         /* dotted name get-set
73             probably would be cleaner to generate proxies for registry & monitoringRegistry, but
74             that would only matter if these objects were unregistered an re-registered (unlikely).
75             
76             It is also more efficient to just call them directly.
77          */

78         server.registerMBean(
79                 getDottedNameGetSetMBean(server, registry, monitoringRegistry),
80                 ObjectNames.getDottedNameGetSetObjectName() );
81     }
82
83     private DottedNameGetSetMBean getDottedNameGetSetMBean(
84                                     final MBeanServer JavaDoc server,
85                                     final DottedNameRegistry registry,
86                                     final DottedNameRegistry monitoringRegistry)
87                                     throws Exception JavaDoc
88     {
89         final String JavaDoc dnClassName= AdminService.getAdminService().getAdminContext().getDottedNameMBeanImplClassName();
90         final Class JavaDoc dnClass = Class.forName(dnClassName);
91         final Class JavaDoc[] types = new Class JavaDoc[]{javax.management.MBeanServerConnection JavaDoc.class,
92                                           com.sun.enterprise.admin.dottedname.DottedNameRegistry.class,
93                                           com.sun.enterprise.admin.dottedname.DottedNameRegistry.class};
94         final Constructor JavaDoc dnConstructor = dnClass.getConstructor(types);
95         final Object JavaDoc[] params = new Object JavaDoc[]{server, registry, monitoringRegistry};
96         final DottedNameGetSetMBean dnMbean = (DottedNameGetSetMBean) dnConstructor.newInstance(params);
97         return dnMbean;
98     }
99 }
100
101
Popular Tags