FileDocCategorySizeDatePackage
kstatMBean.javaAPI DocGlassfish v2 API6279Fri May 04 22:25:02 BST 2007com.sun.enterprise.jmx.kstat

kstatMBean

public class kstatMBean extends Object implements DynamicMBean

Fields Summary
private final kstat
mSource
private final kstatMgrMBean
mMgr
private MBeanInfo
mMBeanInfo
Constructors Summary
public kstatMBean(kstatMgrMBean mgr, kstat source)

		mSource	= source;
		mMgr	= mgr;
	
Methods Summary
private java.lang.Object_getAttribute(java.lang.String name)

		final Object value	= mSource.getValue( name );
		
		return( value );
	
private javax.management.MBeanAttributeInfocreateAttrInfo(java.lang.String attrName)

		final MBeanAttributeInfo	info	= new MBeanAttributeInfo(
			attrName,
			mSource.getAttributeType( attrName ).getName(),
			"",
			true, false, false );
		
		return( info );
	
private javax.management.MBeanAttributeInfo[]createAttrInfos()

		final ArrayList	list	= new ArrayList();
		
		final Set	attrNames	= mSource.getAttributeNames();
		final Iterator	iter	= attrNames.iterator();
		while ( iter.hasNext() )
		{
			final String	attrName	= (String)iter.next();
			try
			{
				final MBeanAttributeInfo	info	= createAttrInfo( attrName );
				
				list.add( info );
			}
			catch( IllegalArgumentException e )
			{
				// don't add it, but continue
				//System.out.println( "createAttrInfos: illegal Attribute name: " + attrNames[ i ]);
			}
		}
		
		final MBeanAttributeInfo []	infos = new MBeanAttributeInfo [ list.size() ];
		list.toArray( infos );
		
		return( infos );
	
private javax.management.MBeanOperationInfo[]createOperationInfos()

		final MBeanOperationInfo []	infos	= new MBeanOperationInfo[ 1 ];
		
		try
		{
			final Method	m	= this.getClass().getDeclaredMethod( "refresh", null);
			infos[ 0 ] 	= new MBeanOperationInfo(
				"refresh all attributes for " + mSource.getScopedName(),
				m );
		}
		catch( NoSuchMethodException e )
		{
			assert( false );
		}
		
		return( infos );
	
public java.lang.ObjectgetAttribute(java.lang.String name)

		return( _getAttribute( name ) );
	
public javax.management.AttributeListgetAttributes(java.lang.String[] names)

		final AttributeList	list	= new AttributeList();
		
		for( int i = 0; i < names.length; ++i )
		{
			final Object	value	= _getAttribute( names[ i ] );
			if ( value != null )
			{
				list.add( new Attribute( names[ i ], value ) );
			}
		}

		return( list );
	
public synchronized javax.management.MBeanInfogetMBeanInfo()

		if ( mMBeanInfo == null )
		{
			final MBeanAttributeInfo []		attrInfo		= createAttrInfos();
			final MBeanOperationInfo []		operationInfo	=  createOperationInfos();
			final MBeanConstructorInfo []	constructorInfo	=  new MBeanConstructorInfo[0];
			final MBeanNotificationInfo []	notificationInfo	=  new MBeanNotificationInfo[0];
			
			final MBeanInfo		info = new MBeanInfo(
				this.getClass().getName(),
				mSource.getScopedName(),
				attrInfo,
				constructorInfo,
				operationInfo,
				notificationInfo );
			
			mMBeanInfo	= info;
		}
		
		return( mMBeanInfo );
	
private java.lang.ObjectinternalInvoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)

		Object	result	= null;
		
		if ( actionName.equals( "refresh" ) )
		{
			refresh();
		}
		else
		{
			throw new OperationsException( "No such method: " + actionName );
		}
		
		return( result );
	
public java.lang.Objectinvoke(java.lang.String actionName, java.lang.Object[] params, java.lang.String[] signature)

		Object	result	= null;
		
		try
		{
			result	= internalInvoke( actionName, params, signature );
		}
		catch( MBeanException e )
		{
			throw e;
		}
		catch( ReflectionException e )
		{
			throw e;
		}
		catch( Exception e )
		{
			throw new MBeanException( e );
		}
		
		return( result );
	
public voidrefresh()

		mMgr.refresh( mSource.getScopedName() );
	
public voidsetAttribute(javax.management.Attribute attr)

		throw new java.lang.UnsupportedOperationException( "can't set kstat value" );
	
public javax.management.AttributeListsetAttributes(javax.management.AttributeList names)

		throw new java.lang.UnsupportedOperationException( "can't set kstat value" );