1 23 package com.sun.enterprise.management.support; 24 25 import javax.management.ObjectName ; 26 import javax.management.MBeanServer ; 27 import javax.management.MBeanServerInvocationHandler ; 28 29 import com.sun.appserv.management.base.Util; 30 import com.sun.enterprise.management.support.AMXServerLogger; 31 import com.sun.enterprise.management.support.AMXMBeanRootLogger; 32 33 import com.sun.enterprise.admin.server.core.AdminService; 34 35 38 public final class BootUtil 39 { 40 private final String mAppserverDomainName; 41 42 private final String mAMX_JMXDomain; 43 44 private static BootUtil INSTANCE = null; 45 46 private boolean mAMXReady; 47 48 private final boolean mOfflineAMX; 49 50 private 51 BootUtil( 52 final String appserverDomainName, 53 final boolean offline ) 54 { 55 AMXServerLogger.getInstance(); 56 AMXMBeanRootLogger.getInstance(); 57 58 mAppserverDomainName = appserverDomainName; 59 mAMX_JMXDomain = appserverDomainName; 60 61 mAMXReady = false; 62 63 mOfflineAMX = offline; 64 } 65 66 69 public String 70 getServerName() 71 { 72 return AdminService.getAdminService().getAdminContext().getServerName(); 73 } 74 75 public static synchronized void 76 init( final boolean offline ) 77 { 78 INSTANCE = new BootUtil( "amx", offline ); 79 } 80 81 public boolean 82 getOffline() 83 { 84 return mOfflineAMX; 85 } 86 87 public static synchronized BootUtil 88 getInstance() 89 { 90 if ( INSTANCE == null ) 91 { 92 throw new IllegalArgumentException ( "must call init() first" ); 93 } 94 95 return( INSTANCE ); 96 } 97 98 public boolean 99 getAMXReady() 100 { 101 return mAMXReady; 102 } 103 104 public void 105 setAMXReady( final boolean ready) 106 { 107 if ( mAMXReady && ! ready ) 108 { 109 throw new IllegalArgumentException (); 110 } 111 112 mAMXReady = ready; 113 } 114 115 private ObjectName 116 getObjectName( String props ) 117 { 118 final String domain = getAMXSupportJMXDomain(); 119 120 return( Util.newObjectName( domain, props ) ); 121 } 122 123 public String 124 getAMXSupportJMXDomain() 125 { 126 return getAMXJMXDomainName() + "-support"; 127 } 128 129 public String 130 getAppserverDomainName() 131 { 132 return( mAppserverDomainName ); 133 } 134 135 public String 136 getAMXJMXDomainName() 137 { 138 return( mAMX_JMXDomain ); 139 } 140 } 141 142 143 144 145 146 147 148 149 | Popular Tags |