FileDocCategorySizeDatePackage
GetterInvocationHandler.javaAPI DocGlassfish v2 API4043Fri May 04 22:30:52 BST 2007com.sun.appserv.management.j2ee.statistics

GetterInvocationHandler

public abstract class GetterInvocationHandler extends Object implements Serializable, InvocationHandler
Abstract base {@link InvocationHandler} for any getXXX() method.
Internal use only

Fields Summary
static final long
serialVersionUID
Constructors Summary
public GetterInvocationHandler()


		 
		
	
	
	
Methods Summary
protected abstract booleancontainsValue(java.lang.String name)

protected abstract TgetValue(java.lang.String name)

public java.lang.Objectinvoke(java.lang.Object myProxy, java.lang.reflect.Method method, java.lang.Object[] args)

   		Object			result	= null;
   		final String	methodName		= method.getName();
   		final int		numArgs	= args == null ? 0 : args.length;
   		
   		if ( numArgs == 0 && JMXUtil.isGetter( method ) )
   		{
   			final String	name	= StringUtil.stripPrefix( methodName, JMXUtil.GET );
   			
   			result	= getValue( name );
   			if ( result == null && ! containsValue( name ) )
   			{
   				throw new NoSuchMethodException( methodName );
   			}
   		}
   		else if ( method.getName().equals( "equals" ) &&
   			numArgs == 1 )
   		{
   			result	= new Boolean( equals( args[ 0 ] ) );
   		}
   		else if ( numArgs == 0 && method.getName().equals( "toString" ) &&
   			method.getReturnType() == String.class )
   		{
   			result	= this.toString();
   		}
   		else if ( numArgs == 0 && method.getName().equals( "hashCode" ) &&
   			method.getReturnType() == int.class )
   		{
   			result	= new Integer( this.hashCode() );
   		}
   		else
   		{
   			throw new IllegalArgumentException( methodName );
   		}

   		return( result );