MBeanRegistrationListener.javaAPI DocGlassfish v2 API5098Fri May 04 22:31:04 BST


public abstract class MBeanRegistrationListener extends NotificationListenerBase
Convenience base class for listening to {@link MBeanServerNotification} notifications. A class extending this class must implement {@link #mbeanRegistered} and {@link #mbeanUnregistered}.

The class is designed to start listening upon creation. The caller should call cleanup() when listening is no longer desired. Once cleanup() is called, no further listening can be done; a new MBeanRegistrationListener should be instantiated if further listening is desired.

Fields Summary
private final ObjectName
private final String
Constructors Summary
protected MBeanRegistrationListener(String name, MBeanServerConnection conn, ObjectName constrain)
If 'constrain' is non-null, then all registration and unregistration events will be filtered through it. Only those MBeans matching will be passed through to {@link #mbeanRegistered} and {@link #mbeanUnregistered}.

constrain optional fixed or pattern ObjectName

	    super( name, conn, JMXUtil.getMBeanServerDelegateObjectName() );
	    mRegUnregFilter = constrain;
	    mDefaultDomain  = conn.getDefaultDomain();
protected MBeanRegistrationListener(String name, MBeanServerConnection conn)
Calls this( conn, null ).


	    this( name, conn, (ObjectName)null );
Methods Summary
public voidhandleNotification( notifIn, java.lang.Object handback)

		if ( ! (notifIn instanceof MBeanServerNotification) )
		    throw new IllegalArgumentException( notifIn.toString() );
		final MBeanServerNotification notif	= (MBeanServerNotification)notifIn;
		final ObjectName objectName	= notif.getMBeanName();
		final String     type	= notif.getType();
		final boolean matchesFilter   = (mRegUnregFilter == null) ||
			JMXUtil.matchesPattern( mDefaultDomain, mRegUnregFilter, objectName );
		if ( matchesFilter )
            if ( type.equals( MBeanServerNotification.REGISTRATION_NOTIFICATION  ) )
                mbeanRegistered( objectName );
            else if ( type.equals( MBeanServerNotification.UNREGISTRATION_NOTIFICATION  ) )
                mbeanUnregistered( objectName );
protected abstract voidmbeanRegistered( objectName)

protected abstract voidmbeanUnregistered( objectName)