1 23 package com.sun.enterprise.management; 24 25 import java.util.Set ; 26 27 import javax.management.ObjectName ; 28 import javax.management.MBeanServer ; 29 import javax.management.JMException ; 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 52 public class DomainRootImplBase extends AMXNonConfigImplBase 53 { 55 private String mAppserverDomainName; 56 57 public String 58 getGroup() 59 { 60 return( AMX.GROUP_UTILITY ); 61 } 62 63 public 64 DomainRootImplBase() 65 { 66 mAppserverDomainName = null; 67 } 68 69 public ObjectName 70 preRegisterHook( final ObjectName selfObjectName ) 71 throws Exception 72 { 73 mAppserverDomainName = BootUtil.getInstance().getAppserverDomainName(); 74 75 return selfObjectName; 76 } 77 78 79 public void 80 preRegisterDone( ) 81 throws Exception 82 { 83 super.preRegisterDone(); 84 85 final CheckStartedThread t = new CheckStartedThread(); 86 t.start(); 87 } 88 89 private static final Set <String > NOT_SUPERFLUOUS = 90 GSetUtil.newUnmodifiableStringSet( 91 "getDomainNotificationEmitterServiceObjectName" ); 92 protected final Set <String > 93 getNotSuperfluousMethods() 94 { 95 return GSetUtil.newSet( super.getNotSuperfluousMethods(), NOT_SUPERFLUOUS ); 96 } 97 98 99 public ObjectName 100 getDomainNotificationEmitterServiceObjectName() 101 { 102 return( getContaineeObjectName( XTypes.NOTIFICATION_EMITTER_SERVICE, 103 NotificationEmitterServiceKeys.DOMAIN_KEY ) ); 104 } 105 106 public String 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 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 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 146 private final class CheckStartedThread extends Thread 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 (); 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 <String > 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 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 , InstantiationException , IllegalAccessException 200 { 201 218 { 219 super.registerSelfMgrChild( childInfo ); 220 } 221 } 222 } 223 224 225 226 227 228 229 230 231 232 233 234 235 | Popular Tags |