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

DelegateBase

public abstract class DelegateBase extends Object implements Delegate
Delegate base class which most Delegates will want to extend.

Fields Summary
private Set
mAttributeNames
private DelegateOwner
mOwner
private com.sun.appserv.management.util.misc.Output
mDebug
private final String
mID
Constructors Summary
public DelegateBase(String id, DelegateOwner owner)

	    mID = id;
		mAttributeNames	= null;
		mOwner	= owner;
		mDebug  = null;
	
Methods Summary
protected java.lang.String_getDefaultValue(java.lang.String name)

        return "!!! NO DEFAULT VALUE FOR: \"" + name + "\" !!!" + ", " + this.getClass().getName();
    
protected final voiddebug(java.lang.Object o)

	    if ( mDebug != null )
	    {
	        mDebug.println( o );
	    }
	
public javax.management.AttributeListgetAttributes(java.lang.String[] attrNames)
Default behavior is to loop over each Attribute; subclass may wish to maintain atomicity by implementing directly.

		final AttributeList		attrs	= new AttributeList();
		
		for( int i = 0; i < attrNames.length; ++i )
		{
			try
			{
				final String	attrName	= attrNames[ i ];
				
				final Attribute	attr	=
					new Attribute( attrName, getAttribute( attrName ) );
				attrs.add( attr );
			}
			catch( Exception e )
			{
				// ignore
			}
		}
		
		return( attrs );
	
public final java.lang.StringgetDefaultValue(java.lang.String name)

        if ( ! supportsAttribute( name ) )
        {
            throw new AttributeNotFoundException( name );
        }
        
        return _getDefaultValue( name );
    
public final java.lang.StringgetID()

 return mID; 
public DelegateOwnergetOwner()

		return( mOwner );
	
public javax.management.AttributeListsetAttributes(javax.management.AttributeList attrs)
Default behavior is too loop over each Attribute; subclass may wish to maintain atomicity by implementing directly.

		final int			numAttrs	= attrs.size();
		final AttributeList	successList	= new AttributeList();
		
		for( int i = 0; i < numAttrs; ++i )
		{
			final Attribute attr	= (Attribute)attrs.get( i );
			try
			{
				setAttribute( attr );
				
				successList.add( attr );
			}
			catch( AttributeNotFoundException e )
			{
				// ignore, as per spec
			}
			catch( InvalidAttributeValueException e )
			{
				// ignore, as per spec
			}
		}
		return( successList );
	
public voidsetDebugOutput(com.sun.appserv.management.util.misc.Output debugOutput)

	    mDebug  = debugOutput;
	
public voidsetOwner(DelegateOwner owner)

		mOwner	= owner;
	
public synchronized booleansupportsAttribute(java.lang.String attrName)

		if ( mAttributeNames == null )
		{
			final String[]	attrNames	=
				JMXUtil.getAttributeNames( getMBeanInfo().getAttributes() );
				
			mAttributeNames	= ArrayConversion.arrayToSet( attrNames );
		}
		
		return( mAttributeNames.contains( attrName ) );
	
public booleansupportsOperation(java.lang.String operationName, java.lang.Object[] args, java.lang.String[] types)

		boolean	supports	= false;
		
		final MBeanOperationInfo[]	opInfos	= getMBeanInfo().getOperations();
		
		for( int i = 0; i < opInfos.length; ++i )
		{
			final MBeanOperationInfo	info	= opInfos[ i ];
			
			if ( info.getName().equals( operationName ) )
			{
				if ( typesMatch( types, info.getSignature() ) )
				{
					supports	= true;
					break;
				}
			}
		}
		
		return( supports );
	
private booleantypesMatch(java.lang.String[] types, javax.management.MBeanParameterInfo[] paramInfos)
Do the classnames match the parameter infos?

		boolean	matches	= false;
		final int  numTypes  = types == null ? 0 : types.length;
		final int   numParams   = paramInfos == null ? 0 : paramInfos.length;
		
		if ( numTypes == numParams )
		{
			matches	= true;
			
			for( int i = 0; i < numTypes; ++i )
			{
				if ( ! types[ i ].equals( paramInfos[ i ].getType() ) )
				{
					matches	= false;
					break;
				}
			}
		}
		
		return( matches );
	
protected voidunimplementedOperation(java.lang.String operation)
An operation has not been implemented. Deal with appropriately.

	    debug( "unimplemented operation: " + operation );
		throw new UnsupportedOperationException( operation );