FileDocCategorySizeDatePackage
LoaderBase.javaAPI DocGlassfish v2 API10328Fri May 04 22:23:42 BST 2007com.sun.enterprise.management.support

LoaderBase

public abstract class LoaderBase extends MBeanImplBase implements LoaderRegHandler, LoaderMBean

Fields Summary
protected volatile boolean
mStarted
protected final ObjectNames
mObjectNames
private static LoaderMBean
LOADER
Constructors Summary
public LoaderBase()

	    debug( "LoaderBase" );

	    final boolean   offline = false;
		BootUtil.init( false );
		
		mServer			= null;
		
		new StringifierRegistryIniterImpl( StringifierRegistryImpl.DEFAULT );
		new StringifierRegistryIniter( StringifierRegistryImpl.DEFAULT );
		
		mStarted	    = false;
		mObjectNames	= ObjectNames.getInstance( getAMXJMXDomainName() );
	
Methods Summary
public voidadminServiceReady()
See com.sun.enterprise.admin.server.core.notifyAMXThatAdminServiceIsReady() Make a [synchronous] call to AMX. Semantics are that this should be a quick call, not a long-running one.

	    // nothing by default
	
protected abstract java.lang.ObjectcreateDomainRoot()

public java.lang.StringgetAMXJMXDomainName()

		return( BootUtil.getInstance().getAMXJMXDomainName() );
	
public java.lang.StringgetAdministrativeDomainName()

		return( BootUtil.getInstance().getAppserverDomainName() );
	
public final com.sun.appserv.management.DomainRootgetDomainRoot()

		final ProxyFactory    factory    =
				ProxyFactory.getInstance( getMBeanServer() );
		
		return( factory.getDomainRoot() ); 
	
public static LoaderMBeangetLoader(javax.management.MBeanServer server)

		return( LOADER );
	
public voidhandleMBeanRegistered(javax.management.ObjectName oldObjectName)

	
public voidhandleMBeanUnregistered(javax.management.ObjectName oldObjectName)

	
public voidhandleNotification(javax.management.Notification notifIn, java.lang.Object handback)

	    /* nothing by default */
	
private static voidinitLOADER(javax.management.MBeanServer server, javax.management.ObjectName loaderObjectName)

	
		  
	       
	
		assert( LOADER == null );
		
		try
		{
			final MBeanServerConnectionSource conn	= new MBeanServerConnectionSource( server );
			final MBeanProxyHandler	handler	= new MBeanProxyHandler( conn, loaderObjectName );
			
			LOADER	= (LoaderMBean)
					Proxy.newProxyInstance( LoaderMBean.class.getClassLoader(), new Class[] { LoaderMBean.class }, handler);
		}
		catch( IOException e )
		{
			assert( false ) : "can't happen";
			throw new RuntimeException( e );
		}
	
public abstract booleanisDAS()

public booleanisStarted()

		return( mStarted );
	
private final voidloadDomainRoot()

	    debug( "loadDomainRoot ENTER" );
	    final Object    domainRoot  = createDomainRoot();
	    if ( domainRoot != null )
	    {
    		ObjectName objectName	= mObjectNames.getDomainRootObjectName( );
    	    
    	    debug( "Registering DomainRoot, impl class = " + domainRoot.getClass().getName() );
    		try
    		{
    			objectName  = mServer.registerMBean( domainRoot, objectName ).getObjectName();
    	        debug( "Registered DomainRoot: " + objectName );
    		}
    		catch( final Exception e )
    		{
    	        final Throwable rootCause   = ExceptionUtil.getRootCause(e);
    	        debug( "Exception loading DomainRoot: " +
    	             rootCause + ", msg=" + rootCause.getMessage() );
    	        throw new RuntimeException( rootCause );
    		}
    	}
    	else
    	{
	        debug( "loadDomainRoot: NULL" );
    	}
    	
	    debug( "loadDomainRoot DONE" );
	
protected javax.management.ObjectNameloadSystemInfo(javax.management.MBeanServer server)

	    debug( "loadSystemInfo" );
	    
		final BootUtil	bootUtil	= BootUtil.getInstance();
		
		final SystemInfoImpl	systemInfo	= new SystemInfoImpl( server, bootUtil );
		
		final ObjectName	tempName	= mObjectNames.getSingletonObjectName( systemInfo.J2EE_TYPE );
		
		final ObjectName objectName	= mServer.registerMBean( systemInfo, tempName ).getObjectName();
		
		debug( "loaded SystemInfo" );
		return( objectName );
	
protected booleanmySleep(long millis)

		boolean	interrupted	= false;
		
		try
		{
			Thread.sleep( millis );
		}
		catch( InterruptedException e )
		{
			Thread.interrupted();
			interrupted	= true;
		}
		
		return interrupted;
	
protected static longnow()

		return( System.currentTimeMillis() );
	
public voidpostRegister(java.lang.Boolean registrationDone)

		super.postRegister( registrationDone );
		
		if ( registrationDone.booleanValue() )
		{
			initLOADER( getMBeanServer(), getObjectName() );
            
		}
		start();
        
        postRegisterHook();
	
protected voidpostRegisterHook()

	
public final javax.management.ObjectNamepreRegister(javax.management.MBeanServer server, javax.management.ObjectName objectNameIn)

	    debug( "preRegister" );
		final ObjectName	superObjectName	= super.preRegister( server, objectNameIn );
		
		final String    domain  = BootUtil.getInstance().getAMXSupportJMXDomain();
		mSelfObjectName	= Util.newObjectName( domain, LOADER_NAME_PROPS );
			
		preRegisterHook();
		
		try
		{
			loadSystemInfo( server );
			
			final MBeanServerNotificationFilter filter	=
				new MBeanServerNotificationFilter();

            filter.enableAllObjectNames();
            
            if ( mServer != server )
            {
                throw new IllegalStateException();
            }
		
			JMXUtil.listenToMBeanServerDelegate( mServer, this, filter, null );
			
		}
		catch( Exception e )
		{
			throw new RuntimeException( e );
		}
		
	    debug( "preRegister done: " + mSelfObjectName );
		return( mSelfObjectName );
	
protected voidpreRegisterHook()

	
public javax.management.ObjectNameresyncAMXMBean(javax.management.ObjectName amx)

	    // do nothing
	    return amx;
	
protected voidstart()

		synchronized( this )
		{
			if ( mStarted )
			{
				throw new IllegalArgumentException( "Can't start Loader twice" );
			}
			mStarted	= true;
		}
		
		new AMXDebugSupport( mServer );
		loadDomainRoot();
		
		startHook();
		
		(new CheckStartedThread()).start();
	
protected voidstartHook()

	    // nothing 
	
public javax.management.ObjectNamesync(javax.management.ObjectName name)

	    throw new UnsupportedOperationException( "sync" );