FileDocCategorySizeDatePackage
JMXMonitorBase.javaAPI DocGlassfish v2 API6260Fri May 04 22:23:30 BST 2007com.sun.enterprise.management.monitor

JMXMonitorBase

public class JMXMonitorBase extends com.sun.enterprise.management.support.AMXImplBase
Implementation of javax.management.monitor.StringMonitor which is an AMX.

Fields Summary
final Monitor
mMonitor
Constructors Summary
protected JMXMonitorBase(Monitor mon)
Because we want our implementation to be an AMX, we will extend appropriately, but this means that we must delegate javax.management.StringMonitor functionality to an instance of that class.

		mMonitor	= mon;
	
Methods Summary
protected java.lang.ObjectgetAttributeManually(java.lang.String name)

		final MBeanAttributeInfo	attrInfo	= (MBeanAttributeInfo)getAttributeInfos().get( name );
		assert( attrInfo != null );	// getAttributeManually() should not have been called otherwise
		
		final String	prefix	= attrInfo.isIs() ? JMXUtil.IS : JMXUtil.GET;
		final String	operationName	= prefix + name;
		
		Object	result	= null;
		try
		{
			result	= invokeManually( operationName, null, null );
		}
		catch( Exception e )
		{
			throw new AttributeNotFoundException( name );
		}
		
		return( result );
	
public java.lang.StringgetGroup()

		return( AMX.GROUP_UTILITY );
	
protected java.lang.ObjectinvokeManually(java.lang.String operationName, java.lang.Object[] args, java.lang.String[] types)

		Object	result	= null;
		
		try
		{
			final Class[]	sig	= ClassUtil.signatureFromClassnames( types );
			
			result	= invokeSig( operationName, args, sig );
		}
		catch( Exception e )
		{
			e.printStackTrace();
			throw new RuntimeException( e );
		}

		return( result );
	
private java.lang.ObjectinvokeSig(java.lang.String operationName, java.lang.Object[] args, java.lang.Class[] sig)

		Object	result	= null;
		
		try
		{
			final Method	m	= mMonitor.getClass().getMethod( operationName, sig );
			
			result	= m.invoke( mMonitor, args );
		}
		catch( Exception e )
		{
			throw new RuntimeException( e );
		}

		return( result );
	
public voidpostDeregisterHook()

		super.postDeregisterHook( );
		
		mMonitor.postDeregister( );
	
public voidpostRegisterHook(java.lang.Boolean registrationDone)

		super.postRegisterHook( registrationDone );
		
		mMonitor.postRegister( registrationDone );
	
public voidpreDeregisterHook()

		super.preDeregisterHook( );
		
		try
		{
		    mMonitor.preDeregister( );
		}
		catch( Exception e )
		{
		    throw new RuntimeException( e );
		}
	
public voidpreRegisterDone()

		final ObjectName	x	= mMonitor.preRegister( getMBeanServer(), getObjectName() );
	
protected voidsetAttributeManually(javax.management.Attribute attr)

		final String	operationName	= JMXUtil.SET + attr.getName();
		final MBeanAttributeInfo	attrInfo	= (MBeanAttributeInfo)getAttributeInfos().get( attr.getName() );
		
		Object	result	= null;
		try
		{
			final Object	value	= attr.getValue();
			// won't work to get the class from the value; must use MBeanInfo
			final Class	theClass	= ClassUtil.getClassFromName( attrInfo.getType() );
			
			result	= invokeSig( operationName,
				new Object[] { value }, new Class[] { theClass } );
			assert( result == null );
		}
		catch( Exception e )
		{
			throw new AttributeNotFoundException( attr.getName() );
		}