FileDocCategorySizeDatePackage
ListenCmd.javaAPI DocGlassfish v2 API7975Fri May 04 22:24:50 BST 2007com.sun.cli.jmx.cmd

MyNotificationListener

public class MyNotificationListener extends Object implements NotificationListener

Fields Summary
MyCmdOutput
mOutput
boolean
mPaused
SmartStringifier
mStringifier
Constructors Summary
public MyNotificationListener(MyCmdOutput output)

		mOutput			= output;
		mStringifier	= setupStringifier();
	
Methods Summary
public voidhandleNotification(javax.management.Notification notif, java.lang.Object o)

		if ( ! mPaused )
		{
			final String	msg	=  mStringifier.stringify( notif ) + "\n";
			
			mOutput.println( msg );
		}
	
public voidsetOutput(com.sun.cli.jmx.cmd.MyCmdOutput output)

		assert( mOutput != null );
		mOutput.close();
		mOutput	= output;
	
public voidsetPaused(boolean paused)

		mPaused	= paused;
	
static SmartStringifiersetupStringifier()

	
		 
	
	
		// set up our options the way we want them
		final NotificationStringifier.Options options	=
					new NotificationStringifier.Options();
		options.mDelim	= "\n";
		
		// create a new registry and put our versions in place
		final StringifierRegistry	myRegistry	=
			new StringifierRegistry( StringifierRegistry.DEFAULT );
		
		// register our stringifiers with desired options
		myRegistry.add( Notification.class,
			new NotificationStringifier( options ));
		
		myRegistry.add( AttributeChangeNotification.class,
			new AttributeChangeNotificationStringifier( options ) );
		
		myRegistry.add( MBeanServerNotification.class,
			new MBeanServerNotificationStringifier( options ) );
		
		myRegistry.add( MonitorNotification.class,
			new MonitorNotificationStringifier( options ) );
			
		final SmartStringifier s	= new SmartStringifier( myRegistry, ",", true);
		
		return( s );
	
public voidtogglePaused()

		mPaused	= ! mPaused;