public interface MBeanServerManager
MBeanServerManagerImpl
that wraps an Java MBeanServer
and provides several useful abstractions. It supports registering and unregistering JMXBean
annotated classes, adding and removing MBean relations, sending notifications to JMX clients upon attribute change, and registering LongAttributeListener
s and sending notifying these listeners of attribute changes.
public class AnnotatedBeanExample { public static void main(String[] args) throws Exception { DataSource dataSource = DataSourceFactory.createDataSource(args); dataSource.start(); MBeanServerManagerImpl beanServerManager = new MBeanServerManagerImpl(dataSource.getMBeanServer(), Logger.getAnonymousLogger()); beanServerManager.registerMBean(new SimpleAnnotatedBean()); } } @JMXBean public class SimpleAnnotatedBean { private String COUNT_ATTRIBUTE_NAME = "count"; private long count = 0; @JMXBeanAttribute(name = COUNT_ATTRIBUTE_NAME) public void setCount(long count) { this.count = count; } @JMXBeanAttribute(name = COUNT_ATTRIBUTE_NAME) public long getCount() { return this.count; } @JMXBeanKey public String getBeanKey() { return "com.caplin.example:name=SimpleAnnotatedBean"; } }
Modifier and Type | Method and Description |
---|---|
void |
addMBeanManyRelation(java.lang.String attributeName,
java.lang.Object parentObject,
java.lang.Object childObject)
Adds a bean relationship which links a parentObject to a childObject, this has to be added to an existing one-to-many relationship
|
void |
createMBeanManyRelation(java.lang.String attributeName,
java.lang.String description,
java.lang.Object parentObject)
Creates an empty one-to-many bean relation for a parentObject with an attribute name
|
void |
createMBeanOneRelation(java.lang.String attributeName,
java.lang.String description,
java.lang.Object parentObject,
java.lang.Object childObject)
Creates an one-to-one bean relation linking a parentObject to a childObject with an attribute name
|
void |
notifyLongAttributeChanged(java.lang.String attributeName,
java.lang.Long delta)
Notifies registered listeners of long attribute changes
|
void |
notifyMBeanAttributeChanged(java.lang.String attributeName,
java.lang.Object object,
java.lang.Object oldValue,
java.lang.Object newValue)
Notifies JMX Clients of a change to a specified attribute
|
void |
registerLongAttributeChangedListener(java.lang.String attributeName,
LongAttributeListener longAttributeListener)
Registers listeners for long attribute changes
|
void |
registerMBean(java.lang.Object object)
|
void |
removeMBeanManyRelation(java.lang.String attributeName,
java.lang.Object parentObject,
java.lang.Object childObject)
Removes bean one-to-many relation for attribute between a parentObject and childObject
|
void |
unregisterMBean(java.lang.Object object)
|
void addMBeanManyRelation(java.lang.String attributeName, java.lang.Object parentObject, java.lang.Object childObject)
void createMBeanOneRelation(java.lang.String attributeName, java.lang.String description, java.lang.Object parentObject, java.lang.Object childObject)
attributeName
- relation attribute namedescription
- description provided to JMX client of this attributeparentObject
- JMXBean
annotated object relation is registered withvoid createMBeanManyRelation(java.lang.String attributeName, java.lang.String description, java.lang.Object parentObject)
attributeName
- relation attribute namedescription
- description provided to JMX client of this attributeparentObject
- JMXBean
annotated object relation is registered withvoid notifyLongAttributeChanged(java.lang.String attributeName, java.lang.Long delta)
attributeName
- changed attributedelta
- change in attributevoid registerLongAttributeChangedListener(java.lang.String attributeName, LongAttributeListener longAttributeListener)
attributeName
- attribute to listen for changes tolongAttributeListener
- listener to receive callbacks upon changes to attributevoid notifyMBeanAttributeChanged(java.lang.String attributeName, java.lang.Object object, java.lang.Object oldValue, java.lang.Object newValue)
attributeName
- attribute that has changedobject
- object to which changed attribute belongsoldValue
- original valuenewValue
- updated valuevoid registerMBean(java.lang.Object object)
object
- object annotated with JMXBean
to be addedvoid removeMBeanManyRelation(java.lang.String attributeName, java.lang.Object parentObject, java.lang.Object childObject)
attributeName
- attribute for which to remove linkparentObject
- object from which relation will be removedchildObject
- object to which relation is linkedvoid unregisterMBean(java.lang.Object object)
object
- object annotated with JMXBean
to be removedPlease send bug reports and comments to Caplin support