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

SampleImpl

public final class SampleImpl extends AMXImplBase
see
Sample

Fields Summary
private final Map
mAttributes
private MBeanInfo
mMBeanInfo
private static final int
MEGABYTE
Constructors Summary
public SampleImpl()

		mAttributes	= Collections.synchronizedMap( new HashMap<String,Serializable>() );
		mMBeanInfo	= null;
	
Methods Summary
public voidaddAttribute(java.lang.String name, java.io.Serializable value)

		if ( name == null || name.length() == 0 )
		{
			throw new IllegalArgumentException( );
		}
		
		mAttributes.put( name, value );
		mMBeanInfo	= null;
	
private synchronized javax.management.MBeanInfocreateMBeanInfo()

		final MBeanInfo	baseMBeanInfo	= super.getMBeanInfo();
		
		final MBeanAttributeInfo[]	dynamicAttrInfos	=
			new MBeanAttributeInfo[ mAttributes.keySet().size() ];
		final Iterator	iter	= mAttributes.keySet().iterator();
		int	i = 0;
		while ( iter.hasNext() )
		{
			final String	name	= (String)iter.next();
			final Object	value	= mAttributes.get( name );
			final String	type	= value == null ? String.class.getName() : value.getClass().getName();
			
			dynamicAttrInfos[ i ]	= new MBeanAttributeInfo( name, type, "dynamically-added Attribute",
										true, true, false );
			++i;
		}
		
		final MBeanAttributeInfo[]	attrInfos	=
			JMXUtil.mergeMBeanAttributeInfos( dynamicAttrInfos, baseMBeanInfo.getAttributes() );
		
		return( JMXUtil.newMBeanInfo( baseMBeanInfo, attrInfos ) );
	
public byte[]downloadBytes(int numBytes)

		 
	    
		
		if ( numBytes <0 || numBytes > 10 * MEGABYTE )
		{
			throw new IllegalArgumentException( "Illegal count: " + numBytes );
		}

		final byte[]	bytes	= new byte[ numBytes ];
		
		return( bytes );
	
public voidemitNotifications(java.io.Serializable data, int numNotifs, long interval)

		if ( numNotifs <= 0 )
		{
			throw new IllegalArgumentException( "" + numNotifs );
		}
		
		new EmitterThread( data, numNotifs, interval ).start();
	
protected java.io.SerializablegetAttributeManually(java.lang.String name)

		return( mAttributes.get( name ) );
	
public synchronized javax.management.MBeanInfogetMBeanInfo()

		if ( mMBeanInfo == null )
		{
			mMBeanInfo	= createMBeanInfo();
		}
		
		return( mMBeanInfo );
	
public booleangetMBeanInfoIsInvariant()

		return( false );
	
public voidremoveAttribute(java.lang.String name)

		mAttributes.remove( name );
		mMBeanInfo	= null;
	
protected voidsetAttributeManually(javax.management.Attribute attr)

		mAttributes.put( attr.getName(), Serializable.class.cast( attr.getValue() ) );
	
public voiduploadBytes(byte[] bytes)

	
		// do nothing; just a bandwidth test