MBeanRegistrationListenerpublic 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 | mRegUnregFilter | private final String | mDefaultDomain |
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}.
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 void | handleNotification(javax.management.Notification 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 void | mbeanRegistered(javax.management.ObjectName objectName)
| protected abstract void | mbeanUnregistered(javax.management.ObjectName objectName)
|
|