java.lang.Object | |
↳ | javax.management.StandardMBean |
![]() |
An MBean whose management interface is determined by reflection on a Java interface.
This class brings more flexibility to the notion of Management Interface in the use of Standard MBeans. Straightforward use of the patterns for Standard MBeans described in the JMX Specification means that there is a fixed relationship between the implementation class of an MBean and its management interface (i.e., if the implementation class is Thing, the management interface must be ThingMBean). This class makes it possible to keep the convenience of specifying the management interface with a Java interface, without requiring that there be any naming relationship between the implementation and interface classes.
By making a DynamicMBean out of an MBean, this class makes it possible to select any interface implemented by the MBean as its management interface, provided that it complies with JMX patterns (i.e., attributes defined by getter/setter etc...).
This class also provides hooks that make it possible to supply
custom descriptions and names for the MBeanInfo
returned by
the DynamicMBean interface.
Using this class, an MBean can be created with any implementation class name Impl and with a management interface defined (as for current Standard MBeans) by any interface Intf, in one of two general ways:
StandardMBean(impl,interface)
:
MBeanServer mbs; ... Impl impl = new Impl(...); StandardMBean mbean = new StandardMBean(impl, Intf.class, false); mbs.registerMBean(mbean, objectName);
public class Impl extends StandardMBean implements Intf { public Impl() { super(Intf.class, false); } // implement methods of Intf } [...] MBeanServer mbs; .... Impl impl = new Impl(); mbs.registerMBean(impl, objectName);
In either case, the class Impl must implement the interface Intf.
Standard MBeans based on the naming relationship between implementation and interface classes are of course still available.
This class may also be used to construct MXBeans. The usage
is exactly the same as for Standard MBeans except that in the
examples above, the false
parameter to the constructor or
super(...)
invocation is instead true
.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Make a DynamicMBean out of the object implementation, using the specified mbeanInterface class. | |||||||||||
Make a DynamicMBean out of the object implementation, using the specified mbeanInterface class. |
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Make a DynamicMBean out of this, using the specified mbeanInterface class. | |||||||||||
Make a DynamicMBean out of this, using the specified mbeanInterface class. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Obtain the value of a specific attribute of the Dynamic MBean.
| |||||||||||
Get the values of several attributes of the Dynamic MBean.
| |||||||||||
Get the implementation of this Standard MBean (or MXBean).
| |||||||||||
Get the class of the implementation of this Standard MBean (or MXBean).
| |||||||||||
Get the
MBeanInfo for this MBean. | |||||||||||
Get the Management Interface of this Standard MBean (or MXBean).
| |||||||||||
Allows an action to be invoked on the Dynamic MBean.
| |||||||||||
Allows the MBean to perform any operations needed after having been unregistered in the MBean server. | |||||||||||
Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed. | |||||||||||
Allows the MBean to perform any operations it needs before being unregistered by the MBean server. | |||||||||||
Allows the MBean to perform any operations it needs before being registered in the MBean server. | |||||||||||
Set the value of a specific attribute of the Dynamic MBean.
| |||||||||||
Sets the values of several attributes of the Dynamic MBean.
| |||||||||||
Replace the implementation object wrapped in this object. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Customization hook:
cache the MBeanInfo built for this object.
| |||||||||||
Customization hook:
Return the MBeanInfo cached for this object.
| |||||||||||
Customization hook:
Get the className that will be used in the MBeanInfo returned by
this MBean.
| |||||||||||
Customization hook:
Get the MBeanConstructorInfo[] that will be used in the MBeanInfo
returned by this MBean.
| |||||||||||
Customization hook:
Get the description that will be used for the sequence
MBeanParameterInfo of the MBeanConstructorInfo returned by this MBean.
| |||||||||||
Customization hook:
Get the description that will be used in the MBeanOperationInfo
returned by this MBean.
| |||||||||||
Customization hook:
Get the description that will be used in the MBeanAttributeInfo
returned by this MBean.
| |||||||||||
Customization hook: Get the description that will be used in the MBeanFeatureInfo returned by this MBean. | |||||||||||
Customization hook:
Get the description that will be used for the sequence
MBeanParameterInfo of the MBeanOperationInfo returned by this MBean.
| |||||||||||
Customization hook:
Get the description that will be used in the MBeanInfo returned by
this MBean.
| |||||||||||
Customization hook:
Get the description that will be used in the MBeanConstructorInfo
returned by this MBean.
| |||||||||||
Customization hook:
Get the impact flag of the operation that will be used in
the MBeanOperationInfo returned by this MBean.
| |||||||||||
Customization hook:
Get the name that will be used for the sequence
MBeanParameterInfo of the MBeanConstructorInfo returned by this MBean.
| |||||||||||
Customization hook:
Get the name that will be used for the sequence
MBeanParameterInfo of the MBeanOperationInfo returned by this MBean.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
Make a DynamicMBean out of the object implementation, using the specified mbeanInterface class.
implementation | The implementation of this MBean. |
---|---|
mbeanInterface | The Management Interface exported by this
MBean's implementation. If null , then this
object will use standard JMX design pattern to determine
the management interface associated with the given
implementation. |
IllegalArgumentException | if the given implementation is null. |
---|---|
NotCompliantMBeanException | if the mbeanInterface does not follow JMX design patterns for Management Interfaces, or if the given implementation does not implement the specified interface. |
Make a DynamicMBean out of the object
implementation, using the specified
mbeanInterface class. This constructor can be used
to make either Standard MBeans or MXBeans. Unlike the
constructor StandardMBean(Object, Class)
, it
does not throw NotCompliantMBeanException.
implementation | The implementation of this MBean. |
---|---|
mbeanInterface | The Management Interface exported by this
MBean's implementation. If null , then this
object will use standard JMX design pattern to determine
the management interface associated with the given
implementation. |
isMXBean | If true, the mbeanInterface parameter
names an MXBean interface and the resultant MBean is an MXBean. |
IllegalArgumentException | if the given implementation is null, or if the mbeanInterface does not follow JMX design patterns for Management Interfaces, or if the given implementation does not implement the specified interface. |
---|
Make a DynamicMBean out of this, using the specified mbeanInterface class.
Call this(this,mbeanInterface)
.
This constructor is reserved to subclasses.
mbeanInterface | The Management Interface exported by this MBean. |
---|
NotCompliantMBeanException | if the mbeanInterface does not follow JMX design patterns for Management Interfaces, or if this does not implement the specified interface. |
---|
Make a DynamicMBean out of this, using the specified
mbeanInterface class. This constructor can be used
to make either Standard MBeans or MXBeans. Unlike the
constructor StandardMBean(Object, Class)
, it
does not throw NotCompliantMBeanException.
Call this(this, mbeanInterface, isMXBean)
.
This constructor is reserved to subclasses.
mbeanInterface | The Management Interface exported by this MBean. |
---|---|
isMXBean | If true, the mbeanInterface parameter
names an MXBean interface and the resultant MBean is an MXBean. |
IllegalArgumentException | if the mbeanInterface does not follow JMX design patterns for Management Interfaces, or if this does not implement the specified interface. |
---|
Obtain the value of a specific attribute of the Dynamic MBean.
attribute | The name of the attribute to be retrieved |
---|
Get the values of several attributes of the Dynamic MBean.
attributes | A list of the attributes to be retrieved. |
---|
Get the implementation of this Standard MBean (or MXBean).
Get the class of the implementation of this Standard MBean (or MXBean).
Get the MBeanInfo
for this MBean.
This method implements
DynamicMBean.getMBeanInfo()
.
This method first calls getCachedMBeanInfo()
in order to
retrieve the cached MBeanInfo for this MBean, if any. If the
MBeanInfo returned by getCachedMBeanInfo()
is not null,
then it is returned.
Otherwise, this method builds a default MBeanInfo for this MBean,
using the Management Interface specified for this MBean.
While building the MBeanInfo, this method calls the customization
hooks that make it possible for subclasses to supply their custom
descriptions, parameter names, etc...
Finally, it calls cacheMBeanInfo()
in order to cache the new MBeanInfo.
Get the Management Interface of this Standard MBean (or MXBean).
Allows an action to be invoked on the Dynamic MBean.
actionName | The name of the action to be invoked. |
---|---|
params | An array containing the parameters to be set when the action is invoked. |
signature | An array containing the signature of the action. The class objects will be loaded through the same class loader as the one used for loading the MBean on which the action is invoked. |
Allows the MBean to perform any operations needed after having been unregistered in the MBean server.
The default implementation of this method does nothing for
Standard MBeans. For MXBeans, it removes any information that
was recorded by the preRegister
method.
It is good practice for a subclass that overrides this method
to call the overridden method via super.postRegister(...)
.
This is necessary if this object is an MXBean that is referenced
by attributes or operations in other MXBeans.
Allows the MBean to perform any operations needed after having been registered in the MBean server or after the registration has failed.
The default implementation of this method does nothing for
Standard MBeans. For MXBeans, it undoes any work done by
preRegister
if registration fails.
It is good practice for a subclass that overrides this method
to call the overridden method via super.postRegister(...)
.
This is necessary if this object is an MXBean that is referenced
by attributes or operations in other MXBeans.
registrationDone | Indicates whether or not the MBean has been successfully registered in the MBean server. The value false means that the registration phase has failed. |
---|
Allows the MBean to perform any operations it needs before being unregistered by the MBean server.
The default implementation of this method does nothing.
It is good practice for a subclass that overrides this method
to call the overridden method via super.preDeegister(...)
.
Exception | no checked exceptions are throw by this method
but Exception is declared so that subclasses can override
this method and throw their own exceptions. |
---|
Allows the MBean to perform any operations it needs before being registered in the MBean server. If the name of the MBean is not specified, the MBean can provide a name for its registration. If any exception is raised, the MBean will not be registered in the MBean server.
The default implementation of this method returns the name
parameter. It does nothing else for
Standard MBeans. For MXBeans, it records the MBeanServer
and ObjectName
parameters so they can be used to translate
inter-MXBean references.
It is good practice for a subclass that overrides this method
to call the overridden method via super.preRegister(...)
.
This is necessary if this object is an MXBean that is referenced
by attributes or operations in other MXBeans.
server | The MBean server in which the MBean will be registered. |
---|---|
name | The object name of the MBean. This name is null if
the name parameter to one of the createMBean or
registerMBean methods in the MBeanServer
interface is null. In that case, this method must return a
non-null ObjectName for the new MBean. |
name
parameter is not null, it will usually but not necessarily be
the returned value.IllegalArgumentException | if this is an MXBean and
name is null. |
---|---|
InstanceAlreadyExistsException | if this is an MXBean and it has already been registered under another name (in this MBean Server or another). |
Exception | no other checked exceptions are thrown by
this method but Exception is declared so that subclasses
can override the method and throw their own exceptions. |
Set the value of a specific attribute of the Dynamic MBean.
attribute | The identification of the attribute to be set and the value it is to be set to. |
---|
Sets the values of several attributes of the Dynamic MBean.
attributes | A list of attributes: The identification of the attributes to be set and the values they are to be set to. |
---|
Replace the implementation object wrapped in this object.
implementation | The new implementation of this Standard MBean
(or MXBean). The implementation object must implement
the Standard MBean (or MXBean) interface that was supplied when this
StandardMBean was constructed. |
---|
IllegalArgumentException | if the given implementation is null. |
---|---|
NotCompliantMBeanException | if the given implementation does not implement the Standard MBean (or MXBean) interface that was supplied at construction. |
Customization hook: cache the MBeanInfo built for this object.
Subclasses may redefine this method in order to implement
their own caching policy. The default implementation stores
info
in this instance. A subclass can define
other policies, such as not saving info
(so it is
reconstructed every time getMBeanInfo()
is called) or
sharing a unique MBeanInfo
object when several
StandardMBean
instances have equal MBeanInfo
values.
info | the new MBeanInfo to cache. Any
previously cached value is discarded. This parameter may be
null, in which case there is no new cached value.
|
---|
Customization hook: Return the MBeanInfo cached for this object.
Subclasses may redefine this method in order to implement their
own caching policy. The default implementation stores one
MBeanInfo
object per instance.
Customization hook:
Get the className that will be used in the MBeanInfo returned by
this MBean.
Subclasses may redefine this method in order to supply their
custom class name. The default implementation returns
info.getClassName()
.
info | The default MBeanInfo derived by reflection. |
---|
Customization hook:
Get the MBeanConstructorInfo[] that will be used in the MBeanInfo
returned by this MBean.
By default, this method returns null
if the wrapped
implementation is not this. Indeed, if the wrapped
implementation is not this object itself, it will not be possible
to recreate a wrapped implementation by calling the implementation
constructors through MBeanServer.createMBean(...)
.
Otherwise, if the wrapped implementation is this,
ctors is returned.
Subclasses may redefine this method in order to modify this
behavior, if needed.
ctors | The default MBeanConstructorInfo[] derived by reflection. |
---|---|
impl | The wrapped implementation. If null is
passed, the wrapped implementation is ignored and
ctors is returned. |
Customization hook:
Get the description that will be used for the sequence
MBeanParameterInfo of the MBeanConstructorInfo returned by this MBean.
Subclasses may redefine this method in order to supply their
custom description. The default implementation returns
param.getDescription()
.
ctor | The default MBeanConstructorInfo derived by reflection. |
---|---|
param | The default MBeanParameterInfo derived by reflection. |
sequence | The sequence number of the parameter considered ("0" for the first parameter, "1" for the second parameter, etc...). |
Customization hook:
Get the description that will be used in the MBeanOperationInfo
returned by this MBean.
Subclasses may redefine this method in order to supply their
custom description. The default implementation returns
getDescription((MBeanFeatureInfo) info)
.
info | The default MBeanOperationInfo derived by reflection. |
---|
Customization hook: Get the description that will be used in the MBeanAttributeInfo returned by this MBean.
Subclasses may redefine this method in order to supply their
custom description. The default implementation returns getDescription((MBeanFeatureInfo) info)
.
info | The default MBeanAttributeInfo derived by reflection. |
---|
Customization hook: Get the description that will be used in the MBeanFeatureInfo returned by this MBean.
Subclasses may redefine this method in order to supply
their custom description. The default implementation returns
info.getDescription()
.
This method is called by
getDescription(MBeanAttributeInfo)
,
getDescription(MBeanOperationInfo)
,
getDescription(MBeanConstructorInfo)
.
info | The default MBeanFeatureInfo derived by reflection. |
---|
Customization hook:
Get the description that will be used for the sequence
MBeanParameterInfo of the MBeanOperationInfo returned by this MBean.
Subclasses may redefine this method in order to supply their
custom description. The default implementation returns
param.getDescription()
.
op | The default MBeanOperationInfo derived by reflection. |
---|---|
param | The default MBeanParameterInfo derived by reflection. |
sequence | The sequence number of the parameter considered ("0" for the first parameter, "1" for the second parameter, etc...). |
Customization hook:
Get the description that will be used in the MBeanInfo returned by
this MBean.
Subclasses may redefine this method in order to supply their
custom MBean description. The default implementation returns
info.getDescription()
.
info | The default MBeanInfo derived by reflection. |
---|
Customization hook:
Get the description that will be used in the MBeanConstructorInfo
returned by this MBean.
Subclasses may redefine this method in order to supply their
custom description.
The default implementation returns getDescription((MBeanFeatureInfo) info)
.
info | The default MBeanConstructorInfo derived by reflection. |
---|
Customization hook:
Get the impact flag of the operation that will be used in
the MBeanOperationInfo returned by this MBean.
Subclasses may redefine this method in order to supply their
custom impact flag. The default implementation returns
info.getImpact()
.
info | The default MBeanOperationInfo derived by reflection. |
---|
Customization hook:
Get the name that will be used for the sequence
MBeanParameterInfo of the MBeanConstructorInfo returned by this MBean.
Subclasses may redefine this method in order to supply their
custom parameter name. The default implementation returns
param.getName()
.
ctor | The default MBeanConstructorInfo derived by reflection. |
---|---|
param | The default MBeanParameterInfo derived by reflection. |
sequence | The sequence number of the parameter considered ("0" for the first parameter, "1" for the second parameter, etc...). |
Customization hook:
Get the name that will be used for the sequence
MBeanParameterInfo of the MBeanOperationInfo returned by this MBean.
Subclasses may redefine this method in order to supply their
custom parameter name. The default implementation returns
param.getName()
.
op | The default MBeanOperationInfo derived by reflection. |
---|---|
param | The default MBeanParameterInfo derived by reflection. |
sequence | The sequence number of the parameter considered ("0" for the first parameter, "1" for the second parameter, etc...). |