FileDocCategorySizeDatePackage
ComSunAppservConfigMBeansIniter.javaAPI DocGlassfish v2 API8590Fri May 04 22:33:46 BST 2007com.sun.enterprise.admin.server.core

ComSunAppservConfigMBeansIniter

public final class ComSunAppservConfigMBeansIniter extends com.sun.appserv.management.util.misc.RunnableBase
Loads the com.sun.appserv configuration MBeans in a separate thread.

Fields Summary
private static final Logger
sLogger
private final MBeanServer
mServer
private final String
mJMXDomainName
private final com.sun.enterprise.admin.AdminContext
mAdminContext
private static final String
DottedMBeansIniterClassName
Constructors Summary
public ComSunAppservConfigMBeansIniter(String jmxDomainName, MBeanServer server, com.sun.enterprise.admin.AdminContext adminContext)

    
              
    
        super( "ComSunAppservConfigMBeansIniter" );
        mServer         = server;
        mJMXDomainName  = jmxDomainName;
        mAdminContext    = adminContext;
        
        checkAlreadyLoaded();
    
Methods Summary
private voidcheckAlreadyLoaded()

        if ( mServer.isRegistered( ObjectNames.getControllerObjectName() ) )
        {
            throw new IllegalArgumentException();
        }
    
private javax.management.ObjectInstancecreateAndRegister(java.lang.String className, javax.management.ObjectName objectName)

        final Class  mbeanClass				= Class.forName( className );
        final Object mbeanImpl				= mbeanClass.newInstance();
        final ObjectInstance mbeanInstance	= this.registerMBean( mbeanImpl, objectName );
        
        return( mbeanInstance );
	
protected voiddoRun()

        checkAlreadyLoaded();
        
        initialize();
    
private voidinitialize()
Initializes the MBeanServer. This method registers the System MBeans. The System MBeans are assumed to have default constructor.

throws
InitException if any of the System MBeans can't be initialized.

        try {
            final ObjectName controllerObjectName = ObjectNames.getControllerObjectName();
            final ObjectName configObjectName     = ObjectNames.getGenericConfiguratorObjectName();
            final ObjectName[] objectNames        = { controllerObjectName, configObjectName };
            
            final String controllerClassName = 
                "com.sun.enterprise.admin.server.core.mbean.config.ServerController";
            final String configClassName = 
                "com.sun.enterprise.admin.server.core.mbean.config.GenericConfigurator";
                
            final String[] clNames = {controllerClassName, configClassName};
        
            for (int i = 0 ; i < clNames.length ; i++) {
                createAndRegister( clNames[i], objectNames[ i ] );
            }
            registerDottedNameSupport();
            registerConfigMBeans();
        }
        catch (Exception e) {
            sLogger.log(Level.WARNING, "Error in initialize", e);
            throw new InitException(e.getMessage(), e );
        }
    
private voidregisterConfigMBeans()
OLD, possibly invalid comments below NOTE: I am using runtime configcontext to instantiate configmbeans FIXME: The current implementation does not load all the mbeans while creating elements. Hence, some mbeans may never be loaded. This needs to be fixed. FIXME: Eventual plan is to move this method to AdminService where it is initialized once and there is no need to call again. This method does not throw any exception and is best-effort.

        final long start = System.currentTimeMillis();
        
        final MBeanRegistry mr = MBeanRegistryFactory.getAdminMBeanRegistry();  
        final ConfigContext  configContext    = mAdminContext.getAdminConfigContext();
        final String jmxDomainName = ApplicationServer.getServerContext().getDefaultDomainName();
        
        mr.instantiateAndRegisterAllConfigMBeans(
             configContext, 
             jmxDomainName);
        
        final long elapsed = System.currentTimeMillis() - start;
        
        FeatureAvailability.getInstance().registerFeature( FeatureAvailability.COM_SUN_APPSERV_CONFIG_MBEANS_FEATURE, mServer );
    
private voidregisterDottedNameSupport()

			
		 
	
		 
	
		final Class		initerClass	= Class.forName( DottedMBeansIniterClassName );
		
		// invoke new DottedNamesMBeanIniter( MBeanServer m )
		final Class []		signature	= new Class [] { MBeanServer.class };
		final java.lang.reflect.Constructor	constructor	= initerClass.getConstructor( signature );
		constructor.newInstance( new Object [] { mServer } );
		// done--it will have done its job
	
public javax.management.ObjectInstanceregisterMBean(java.lang.Object object, javax.management.ObjectName objectName)

        return mServer.registerMBean(object, objectName);
    
protected voidstartLoading(boolean synchronous)

        checkAlreadyLoaded();
        
        if ( synchronous )
        {
            run();
        }
        else
        {
            new Thread( this ).start();
        }