KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > config > OfflineConfigIniter


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 package com.sun.appserv.management.config;
24
25 import java.io.File JavaDoc;
26
27 import java.lang.reflect.Constructor JavaDoc;
28
29 import javax.management.MBeanServer JavaDoc;
30 import javax.management.ObjectName JavaDoc;
31
32 import com.sun.appserv.management.base.AMX;
33 import com.sun.appserv.management.base.Util;
34 import com.sun.appserv.management.DomainRoot;
35 import com.sun.appserv.management.client.ProxyFactory;
36
37
38
39 /**
40     <b>Private interface, DO NOT USE</b>
41 */

42 public final class OfflineConfigIniter
43 {
44     private final MBeanServer JavaDoc mServer;
45     private final File JavaDoc mDomainXML;
46     private final ObjectName JavaDoc mLoader;
47     private final DomainRoot mDomainRoot;
48     
49     private static final String JavaDoc LOADER_CLASSNAME =
50         "com.sun.enterprise.management.offline.OfflineLoader";
51     
52     private final Class JavaDoc[] LOADER_CONSTRUCTOR_SIG = new Class JavaDoc[]
53     {
54         MBeanServer JavaDoc.class,
55         File JavaDoc.class,
56     };
57     
58         public
59     OfflineConfigIniter(
60         final MBeanServer JavaDoc server,
61         final File JavaDoc domainXML )
62     {
63         mServer = server;
64         mDomainXML = domainXML;
65         mLoader = initLoader();
66         
67         mDomainRoot = ProxyFactory.getInstance( server ).getDomainRoot();
68     }
69     
70         public DomainRoot
71     getDomainRoot()
72     {
73         return mDomainRoot;
74     }
75     
76     public static final String JavaDoc NAME = "offline-mbean-loader";
77     
78         private ObjectName JavaDoc
79     initLoader()
80     {
81         ObjectName JavaDoc loaderObjectName = null;
82         
83         try
84         {
85             // can't import it because it's this code is in client API.
86
// We want this feature to work only if the requisite classes are present,
87
// but we can't include them.
88
//
89
final Class JavaDoc loaderClass = Class.forName( LOADER_CLASSNAME );
90             final Constructor JavaDoc constructor =
91                 loaderClass.getConstructor( LOADER_CONSTRUCTOR_SIG );
92             
93             final Object JavaDoc loader = constructor.newInstance( mServer, mDomainXML );
94             
95             final String JavaDoc domain = AMX.JMX_DOMAIN + "-support";
96             loaderObjectName = Util.newObjectName( domain, Util.makeNameProp( NAME ) );
97             loaderObjectName =
98                 mServer.registerMBean( loader, loaderObjectName ).getObjectName();
99         }
100         catch(Throwable JavaDoc t)
101         {
102             t.printStackTrace();
103             
104             throw new RuntimeException JavaDoc( t );
105         }
106         
107         return loaderObjectName;
108     }
109 }
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
Popular Tags