1 23 24 package com.sun.enterprise.admin.server.core; 25 import com.sun.enterprise.config.serverbeans.Mbean; 26 import java.lang.reflect.Constructor ; 27 import javax.management.MBeanServer ; 28 import com.sun.enterprise.config.ConfigContext; 29 import com.sun.enterprise.config.serverbeans.ServerBeansFactory; 30 import com.sun.enterprise.util.SystemPropertyConstants; 31 import java.util.List ; 32 33 class CustomMBeanRegistrationHelper { 34 private final MBeanServer mbs; 35 private final ConfigContext cc; 36 private final String myName; 37 private final CustomMBeanRegistration cmr; 38 CustomMBeanRegistrationHelper(final MBeanServer mbs, final ConfigContext cc) throws Exception { 39 this.mbs = mbs; 40 this.cc = cc; 41 myName = System.getProperty(SystemPropertyConstants.SERVER_NAME); 42 cmr = mbeanRegistrationFactory(); 43 } 44 45 void registerMBeans() throws Exception { 46 final List <Mbean> m2r = getMBeans2Register(); 47 cmr.registerMBeans(m2r); 48 } 49 50 private CustomMBeanRegistration mbeanRegistrationFactory() throws Exception { 52 final String CUSTOM_REGRISTRATION_IMPL_CLASS = "com.sun.enterprise.admin.mbeans.custom.loading.CustomMBeanRegistrationImpl"; 53 final Class c = Class.forName(CUSTOM_REGRISTRATION_IMPL_CLASS); 54 final Class [] pts = new Class []{javax.management.MBeanServer .class}; 55 final Constructor ctor = c.getConstructor(pts); 56 final Object [] aps = new Object []{mbs}; 57 return ( (CustomMBeanRegistration) ctor.newInstance(aps) ); 58 } 59 60 private List <Mbean> getMBeans2Register() throws Exception { 61 return ( ServerBeansFactory.getFullyEnabledUserDefinedMBeans(cc, myName) ); 62 } 63 } | Popular Tags |