KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > DomainRootImplBase


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.enterprise.management;
24
25 import java.util.Set JavaDoc;
26
27 import javax.management.ObjectName JavaDoc;
28 import javax.management.MBeanServer JavaDoc;
29 import javax.management.JMException JavaDoc;
30
31 import com.sun.appserv.management.DomainRoot;
32 import com.sun.appserv.management.base.XTypes;
33 import com.sun.appserv.management.base.AMX;
34 import com.sun.appserv.management.base.Util;
35 import com.sun.appserv.management.base.NotificationEmitterServiceKeys;
36 import com.sun.appserv.management.base.NotificationEmitterService;
37
38 import com.sun.appserv.management.j2ee.J2EETypes;
39
40 import com.sun.appserv.management.util.misc.GSetUtil;
41 import com.sun.appserv.management.util.misc.GSetUtil;
42
43 import com.sun.enterprise.management.support.AMXNonConfigImplBase;
44 import com.sun.enterprise.management.support.ObjectNames;
45 import com.sun.enterprise.management.support.TypeInfo;
46 import com.sun.enterprise.management.support.NotificationEmitterServiceImpl;
47 import com.sun.enterprise.management.support.BootUtil;
48
49
50 /**
51  */

52 public class DomainRootImplBase extends AMXNonConfigImplBase
53     // implements DomainRoot
54
{
55     private String JavaDoc mAppserverDomainName;
56     
57         public String JavaDoc
58     getGroup()
59     {
60         return( AMX.GROUP_UTILITY );
61     }
62     
63         public
64     DomainRootImplBase()
65     {
66         mAppserverDomainName = null;
67     }
68          
69         public ObjectName JavaDoc
70     preRegisterHook( final ObjectName JavaDoc selfObjectName )
71         throws Exception JavaDoc
72     {
73         mAppserverDomainName = BootUtil.getInstance().getAppserverDomainName();
74     
75         return selfObjectName;
76     }
77     
78     
79         public void
80     preRegisterDone( )
81         throws Exception JavaDoc
82     {
83         super.preRegisterDone();
84         
85         final CheckStartedThread t = new CheckStartedThread();
86         t.start();
87     }
88     
89     private static final Set JavaDoc<String JavaDoc> NOT_SUPERFLUOUS =
90         GSetUtil.newUnmodifiableStringSet(
91             "getDomainNotificationEmitterServiceObjectName" );
92         protected final Set JavaDoc<String JavaDoc>
93     getNotSuperfluousMethods()
94     {
95         return GSetUtil.newSet( super.getNotSuperfluousMethods(), NOT_SUPERFLUOUS );
96     }
97     
98     
99         public ObjectName JavaDoc
100     getDomainNotificationEmitterServiceObjectName()
101     {
102         return( getContaineeObjectName( XTypes.NOTIFICATION_EMITTER_SERVICE,
103             NotificationEmitterServiceKeys.DOMAIN_KEY ) );
104     }
105     
106         public String JavaDoc
107     getAppserverDomainName()
108     {
109         return( mAppserverDomainName );
110     }
111     
112         protected final void
113     registerMisc()
114     {
115         super.registerMisc();
116         
117         registerNotificationEmitterService();
118     }
119
120
121         protected final void
122     registerNotificationEmitterService()
123     {
124         final ObjectNames objectNames = ObjectNames.getInstance( getJMXDomain() );
125         final ObjectName JavaDoc childObjectName =
126             objectNames.buildContaineeObjectName( getObjectName(),
127                 getFullType(), XTypes.NOTIFICATION_EMITTER_SERVICE,
128                     NotificationEmitterServiceKeys.DOMAIN_KEY);
129         
130         final NotificationEmitterService domainNES = new NotificationEmitterServiceImpl();
131         try
132         {
133             getMBeanServer().registerMBean( domainNES, childObjectName );
134         }
135         catch( JMException JavaDoc e )
136         {
137             logWarning( "DomainRootImpl: Can't load global NotificationEmitterService" );
138         }
139     }
140     
141     
142     static private final long AMX_READY_SLEEP_DURATION = 100;
143     /**
144         Notice when AMX has finished loading, the exit.
145      */

146     private final class CheckStartedThread extends Thread JavaDoc
147     {
148         public void CheckStartedThread() {}
149         
150             public void
151         run()
152         {
153             waitAMXReady();
154             amxNowReady();
155         }
156     }
157     
158         private void
159     amxNowReady()
160     {
161         if ( ! getAMXReady() )
162         {
163             throw new IllegalStateException JavaDoc();
164         }
165         sendNotification( DomainRoot.AMX_READY_NOTIFICATION_TYPE );
166     }
167     
168         public boolean
169     getAMXReady()
170     {
171         return BootUtil.getInstance().getAMXReady();
172     }
173     
174         public void
175     waitAMXReady( )
176     {
177         while ( ! getAMXReady() )
178         {
179             sleepMillis( AMX_READY_SLEEP_DURATION );
180         }
181     }
182     
183     static private final Set JavaDoc<String JavaDoc> OFFLINE_INCAPABLE_J2EE_TYPES =
184         GSetUtil.newUnmodifiableStringSet(
185             XTypes.WEB_SERVICE_MGR
186         );
187         
188         protected boolean
189     isOfflineCapable( final TypeInfo childInfo )
190     {
191         final String JavaDoc j2eeType = childInfo.getJ2EEType();
192         
193         return (! OFFLINE_INCAPABLE_J2EE_TYPES.contains( j2eeType )) &&
194                 super.isOfflineCapable( childInfo );
195     }
196     
197         protected void
198     registerSelfMgrChild( final TypeInfo childInfo )
199         throws JMException JavaDoc, InstantiationException JavaDoc, IllegalAccessException JavaDoc
200     {
201         /*
202         KEEP until implemented
203         final String childJ2EEType = childInfo.getJ2EEType( );
204         
205         if ( getOffline() &&
206                 childJ2EEType.equals( XTypes.CONFIG_DOTTED_NAMES ) )
207         {
208             final OfflineConfigDottedNamesImpl impl = new OfflineConfigDottedNamesImpl();
209             
210             final ObjectName childObjectName =
211                 getObjectNames().buildContaineeObjectName( getObjectName(),
212                     getFullType(), childJ2EEType );
213                     
214             registerMBean( impl, childObjectName );
215         }
216         else
217         */

218         {
219             super.registerSelfMgrChild( childInfo );
220         }
221     }
222 }
223
224
225
226
227
228
229
230
231
232
233
234
235
Popular Tags