1 28 29 package com.caucho.jmx; 30 31 import com.caucho.log.Log; 32 33 import javax.management.MBeanServer ; 34 import javax.management.MBeanServerBuilder ; 35 import javax.management.MBeanServerDelegate ; 36 import java.util.logging.Logger ; 37 38 41 public class MBeanServerBuilderImpl extends MBeanServerBuilder { 42 private static final Logger log = Log.open(MBeanServerBuilderImpl.class); 43 44 private static boolean _isInit; 45 private static boolean _isJdkManagementInit; 46 47 public MBeanServerBuilderImpl() 48 { 49 } 50 51 54 public MBeanServerDelegate newMBeanServerDelegate() 55 { 56 return new MBeanServerDelegateImpl("Resin"); 57 } 58 59 62 public MBeanServer newMBeanServer(String defaultDomain, 63 MBeanServer outer, 64 MBeanServerDelegate delegate) 65 { 66 EnvironmentMBeanServerBuilder.getGlobal(defaultDomain); 68 69 if (! _isJdkManagementInit) { 70 Exception e = new Exception (); 71 e.fillInStackTrace(); 72 StackTraceElement []stackTrace = e.getStackTrace(); 73 74 for (int i = 0; i < stackTrace.length; i++) { 75 if (stackTrace[i].getClassName().equals("java.lang.management.ManagementFactory")) { 76 _isJdkManagementInit = true; 77 78 return Jmx.getGlobalMBeanServer(); 79 } 80 } 81 } 82 83 if (! _isInit) { 84 _isInit = true; 85 86 return Jmx.getContextMBeanServer(); 87 } 88 89 if (defaultDomain == null) 90 defaultDomain = "resin"; 91 92 return new MBeanServerImpl(defaultDomain, delegate); 93 } 94 } 95 | Popular Tags |