1 19 package fr.dyade.aaa.util.management; 20 21 import org.objectweb.util.monolog.api.BasicLevel; 22 import org.objectweb.util.monolog.api.Logger; 23 import org.objectweb.util.monolog.api.LoggerFactory; 24 25 import fr.dyade.aaa.util.Debug; 26 27 public final class MXWrapper { 28 33 public final static String ServerImpl = "MXServer"; 34 35 public static MXServer mxserver = null; 36 37 public static void init() { 38 if (mxserver != null) return; 39 40 String mxname = System.getProperty(ServerImpl); 41 42 45 try { 46 if ((mxname != null) && (mxname.length() > 0)) 47 Class.forName(mxname).newInstance(); 48 } catch (Exception exc) { 49 Debug.getLogger("fr.dyade.aaa.util.management").log( 50 BasicLevel.ERROR, "can't instantiate MXServer: " + mxname, exc); 51 } 52 53 Debug.getLogger("fr.dyade.aaa.util.management").log( 54 BasicLevel.INFO, "MXWrapper.ServerImpl -> " + mxname); 55 } 56 57 public static void registerMBean(Object bean, 58 String domain, 59 String name) throws Exception { 60 if (mxserver == null) return; 61 62 Debug.getLogger("fr.dyade.aaa.util.management").log( 63 BasicLevel.INFO, "registerMBean: " + name + " -> " + mxserver); 64 65 mxserver.registerMBean(bean, domain, name); 66 } 67 68 public static void unregisterMBean(String domain, 69 String name) throws Exception { 70 if (mxserver == null) return; 71 72 Debug.getLogger("fr.dyade.aaa.util.management").log( 73 BasicLevel.INFO, "unregisterMBean: " + name + " -> " + mxserver); 74 75 mxserver.unregisterMBean(domain, name); 76 } 77 78 public static void setMXServer(MXServer server) { 79 Debug.getLogger("fr.dyade.aaa.util.management").log( 80 BasicLevel.INFO, "setMXServer: " + server); 81 82 mxserver = server; 83 } 84 85 public static MXServer getMXServer() { 86 return mxserver; 87 } 88 } 89 | Popular Tags |