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 ClassesModifier and TypeClassDescriptionstatic interface
Callback interface.static class
Default callback implementation, can be subclassed if needed Remembers only the last MBean that was seen. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final T
private final String
listen for MBeans in a given domain of a given type[name] OR an ObjectName (below)private final MBeanServerConnection
private final String
private final ObjectName
mType and mName should be null if mObjectName is non-null, and vice versaprivate final String
-
Constructor Summary
ConstructorsConstructorDescriptionMBeanListener
(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
Modifier and TypeMethodDescriptionprivate static void
getName()
getType()
void
handleNotification
(Notification notifIn, Object handback) private boolean
isRegistered
(MBeanServerConnection conn, ObjectName objectName) void
Start listening.void
unregister the listenertoString()
-
Field Details
-
mJMXDomain
listen for MBeans in a given domain of a given type[name] OR an ObjectName (below) -
mType
-
mName
-
mObjectName
mType and mName should be null if mObjectName is non-null, and vice versa -
mMBeanServer
-
mCallback
-
-
Constructor Details
-
MBeanListener
Listener for a specific MBean. Caller must callstartListening()
to start listening.- Parameters:
server
-objectName
-callback
-
-
MBeanListener
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 Details
-
debug
-
toString
-
getType
-
getName
-
getMBeanServer
-
getCallback
-
isRegistered
-
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
- Specified by:
handleNotification
in interfaceNotificationListener
-