Package org.glassfish.external.amx
Class MBeanListener<T extends MBeanListener.Callback>
- java.lang.Object
-
- org.glassfish.external.amx.MBeanListener<T>
-
- All Implemented Interfaces:
EventListener,NotificationListener
@Taxonomy(stability=UNCOMMITTED) public class MBeanListener<T extends MBeanListener.Callback> extends Object implements NotificationListener
Listens for registration of MBeans of various types. Intended usage is for subsystems to lazy-load only when the Parent MBean is registered.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceMBeanListener.CallbackCallback interface.static classMBeanListener.CallbackImplDefault callback implementation, can be subclassed if needed Remembers only the last MBean that was seen.
-
Constructor Summary
Constructors Constructor Description MBeanListener(MBeanServerConnection server, String domain, String type, String name, T callback)Listener for MBeans of specified type, with specified name (or any name if null is passed for the name).MBeanListener(MBeanServerConnection server, String domain, String type, T callback)Listener for all MBeans of specified type, with or without a name.MBeanListener(MBeanServerConnection server, ObjectName objectName, T callback)Listener for a specific MBean.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TgetCallback()MBeanServerConnectiongetMBeanServer()StringgetName()StringgetType()voidhandleNotification(Notification notifIn, Object handback)voidstartListening()Start listening.voidstopListening()unregister the listenerStringtoString()
-
-
-
Constructor Detail
-
MBeanListener
public MBeanListener(MBeanServerConnection server, ObjectName objectName, T callback)
Listener for a specific MBean. Caller must callstartListening()to start listening.- Parameters:
server-objectName-callback-
-
MBeanListener
public MBeanListener(MBeanServerConnection server, String domain, String type, T callback)
Listener for all MBeans of specified type, with or without a name. Caller must callstartListening()to start listening.- Parameters:
server-type- type of the MBean (as found in the ObjectName)callback-
-
MBeanListener
public MBeanListener(MBeanServerConnection server, String domain, String type, String name, T callback)
Listener for MBeans of specified type, with specified name (or any name if null is passed for the name). Caller must callstartListening()to start listening.- Parameters:
server-type- type of the MBean (as found in the ObjectName)name- name of the MBean, or null if nonecallback-
-
-
Method Detail
-
getType
public String getType()
-
getName
public String getName()
-
getMBeanServer
public MBeanServerConnection getMBeanServer()
-
getCallback
public T getCallback()
-
startListening
public void startListening()
Start listening. If the required MBean(s) are already present, the callback will be synchronously made before returning. It is also possible that the callback could happen twice for the same MBean.
-
stopListening
public void stopListening()
unregister the listener
-
handleNotification
public void handleNotification(Notification notifIn, Object handback)
- Specified by:
handleNotificationin interfaceNotificationListener
-
-