| java.lang.Object javax.management.StandardMBean
All known Subclasses: example.jmx.standard.Test1_2,
StandardMBean | public class StandardMBean implements DynamicMBean,MBeanRegistration(Code) | | 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:
- Using the public constructor
StandardMBean.StandardMBean(java.lang.Object,java.lang.Class)StandardMBean(impl,interface) :
MBeanServer mbs;
...
Impl impl = new Impl(...);
StandardMBean mbean = new StandardMBean(impl, Intf.class);
mbs.registerMBean(mbean, objectName);
- Subclassing StandardMBean:
public class Impl extends StandardMBean implements Intf {
public Impl() {
super(Intf.class);
}
// 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.
since: JMX 1.2 author: Young Yang |
Constructor Summary | |
public | StandardMBean(Object implementation, Class mbeanInterface) Make a DynamicMBean out of the object
implementation, using the specified
mbeanInterface class.
Parameters: implementation - The implementation of this MBean. Parameters: mbeanInterface - The Management Interface exported by thisMBean's implementation. | protected | StandardMBean(Class mbeanInterface) Make a DynamicMBean out of this, using the specified
mbeanInterface class.
Call
StandardMBean.StandardMBean(java.lang.Object,java.lang.Class)this(this,mbeanInterface) . |
Method Summary | |
protected synchronized void | cacheMBeanInfo(MBeanInfo info) Customization hook:
cache the MBeanInfo built for this object.
Subclasses may redefine this method in order to implement
their own caching policy. | public Object | getAttribute(String attribute) | public AttributeList | getAttributes(String[] attributes) | protected MBeanInfo | getCachedMBeanInfo() Customization hook:
Return the MBeanInfo cached for this object.
Subclasses may redefine this method in order to implement their
own caching policy. | protected String | getClassName(MBeanInfo info) 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. | protected MBeanConstructorInfo[] | getConstructors(MBeanConstructorInfo[] ctors, Object impl) 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. | protected String | getDescription(MBeanInfo info) 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. | protected String | getDescription(MBeanFeatureInfo info) 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. | protected String | getDescription(MBeanAttributeInfo info) 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. | protected String | getDescription(MBeanConstructorInfo info) 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
StandardMBean.getDescription(MBeanFeatureInfo)getDescription((MBeanFeatureInfo) info) .
Parameters: info - The default MBeanConstructorInfo derived by reflection. | protected String | getDescription(MBeanConstructorInfo ctor, MBeanParameterInfo param, int sequence) 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. | protected String | getDescription(MBeanOperationInfo info) 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. | protected String | getDescription(MBeanOperationInfo op, MBeanParameterInfo param, int sequence) 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. | protected int | getImpact(MBeanOperationInfo info) 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. | public synchronized Object | getImplementation() Get the implementation of this MBean. | public synchronized Class | getImplementationClass() Get the class of the implementation of this MBean. | public MBeanInfo | getMBeanInfo() | final public synchronized Class | getMBeanInterface() Get the Management Interface of this MBean. | public MBeanMetaData | getMetaData() | protected MBeanNotificationInfo[] | getNotifications(MBeanInfo info) Customization hook:
Get the MBeanNotificationInfo[] that will be used in the MBeanInfo
returned by this MBean.
Subclasses may redefine this method in order to supply their
custom notifications.
Parameters: info - The default MBeanInfo derived by reflection. | protected String | getParameterName(MBeanConstructorInfo ctor, MBeanParameterInfo param, int sequence) 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. | protected String | getParameterName(MBeanOperationInfo op, MBeanParameterInfo param, int sequence) 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. | public Object | invoke(String actionName, Object params, String signature) | public void | postDeregister() | public void | postRegister(Boolean registrationDone) | public void | preDeregister() | public ObjectName | preRegister(MBeanServer server, ObjectName name) | public void | setAttribute(Attribute attribute) | public AttributeList | setAttributes(AttributeList attributes) | public synchronized void | setImplementation(Object implementation) |
StandardMBean | public StandardMBean(Object implementation, Class mbeanInterface) throws NotCompliantMBeanException(Code) | | Make a DynamicMBean out of the object
implementation, using the specified
mbeanInterface class.
Parameters: implementation - The implementation of this MBean. Parameters: mbeanInterface - The Management Interface exported by thisMBean's implementation. If null , then thisobject will use standard JMX design pattern to determinethe management interface associated with the givenimplementation. exception: IllegalArgumentException - if the givenimplementation is null. exception: NotCompliantMBeanException - if the mbeanInterfacedoes not follow JMX design patterns for Management Interfaces, orif the given implementation does not implement thespecified interface. |
cacheMBeanInfo | protected synchronized void cacheMBeanInfo(MBeanInfo info)(Code) | | 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
StandardMBean.getMBeanInfo() is called) or
sharing a unique
MBeanInfo object when several
StandardMBean instances have equal
MBeanInfo values.
Parameters: info - the new MBeanInfo to cache. Anypreviously cached value is discarded. This parameter may benull, in which case there is no new cached value. |
getCachedMBeanInfo | protected MBeanInfo getCachedMBeanInfo()(Code) | | 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.
The cached MBeanInfo, or null if no MBeanInfo is cached. See Also: StandardMBean.cacheMBeanInfo(MBeanInfo) |
getClassName | protected String getClassName(MBeanInfo info)(Code) | | 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
MBeanInfo.getClassName info.getClassName() .
Parameters: info - The default MBeanInfo derived by reflection. the class name for the new MBeanInfo. |
getConstructors | protected MBeanConstructorInfo[] getConstructors(MBeanConstructorInfo[] ctors, Object impl)(Code) | | 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
behaviour, if needed.
Parameters: ctors - The default MBeanConstructorInfo[] derived by reflection. Parameters: impl - The wrapped implementation. If null ispassed, the wrapped implementation is ignored andctors is returned. the MBeanConstructorInfo[] for the new MBeanInfo. |
getDescription | protected String getDescription(MBeanInfo info)(Code) | | 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
MBeanInfo.getDescription info.getDescription() .
Parameters: info - The default MBeanInfo derived by reflection. the description for the new MBeanInfo. |
getDescription | protected String getDescription(MBeanAttributeInfo info)(Code) | | 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
StandardMBean.getDescription(MBeanFeatureInfo)getDescription((MBeanFeatureInfo) info) .
Parameters: info - The default MBeanAttributeInfo derived by reflection. the description for the given MBeanAttributeInfo. |
getDescription | protected String getDescription(MBeanConstructorInfo info)(Code) | | 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
StandardMBean.getDescription(MBeanFeatureInfo)getDescription((MBeanFeatureInfo) info) .
Parameters: info - The default MBeanConstructorInfo derived by reflection. the description for the given MBeanConstructorInfo. |
getDescription | protected String getDescription(MBeanConstructorInfo ctor, MBeanParameterInfo param, int sequence)(Code) | | 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
MBeanParameterInfo.getDescription param.getDescription() .
Parameters: ctor - The default MBeanConstructorInfo derived by reflection. Parameters: param - The default MBeanParameterInfo derived by reflection. Parameters: sequence - The sequence number of the parameter considered("0" for the first parameter, "1" for the second parameter,etc...). the description for the given MBeanParameterInfo. |
getDescription | protected String getDescription(MBeanOperationInfo info)(Code) | | 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
StandardMBean.getDescription(MBeanFeatureInfo)getDescription((MBeanFeatureInfo) info) .
Parameters: info - The default MBeanOperationInfo derived by reflection. the description for the given MBeanOperationInfo. |
getDescription | protected String getDescription(MBeanOperationInfo op, MBeanParameterInfo param, int sequence)(Code) | | 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
MBeanParameterInfo.getDescription param.getDescription() .
Parameters: op - The default MBeanOperationInfo derived by reflection. Parameters: param - The default MBeanParameterInfo derived by reflection. Parameters: sequence - The sequence number of the parameter considered("0" for the first parameter, "1" for the second parameter,etc...). the description for the given MBeanParameterInfo. |
getImpact | protected int getImpact(MBeanOperationInfo info)(Code) | | 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
MBeanOperationInfo.getImpact info.getImpact() .
Parameters: info - The default MBeanOperationInfo derived by reflection. the impact flag for the given MBeanOperationInfo. |
getImplementationClass | public synchronized Class getImplementationClass()(Code) | | Get the class of the implementation of this MBean.
The class of the implementation of this MBean. |
getMBeanInterface | final public synchronized Class getMBeanInterface()(Code) | | Get the Management Interface of this MBean.
The management interface of this MBean. |
getNotifications | protected MBeanNotificationInfo[] getNotifications(MBeanInfo info)(Code) | | Customization hook:
Get the MBeanNotificationInfo[] that will be used in the MBeanInfo
returned by this MBean.
Subclasses may redefine this method in order to supply their
custom notifications.
Parameters: info - The default MBeanInfo derived by reflection. the MBeanNotificationInfo[] for the new MBeanInfo. |
getParameterName | protected String getParameterName(MBeanConstructorInfo ctor, MBeanParameterInfo param, int sequence)(Code) | | 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
MBeanParameterInfo.getName param.getNameSpace() .
Parameters: ctor - The default MBeanConstructorInfo derived by reflection. Parameters: param - The default MBeanParameterInfo derived by reflection. Parameters: sequence - The sequence number of the parameter considered("0" for the first parameter, "1" for the second parameter,etc...). the name for the given MBeanParameterInfo. |
getParameterName | protected String getParameterName(MBeanOperationInfo op, MBeanParameterInfo param, int sequence)(Code) | | 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
MBeanParameterInfo.getName param.getNameSpace() .
Parameters: op - The default MBeanOperationInfo derived by reflection. Parameters: param - The default MBeanParameterInfo derived by reflection. Parameters: sequence - The sequence number of the parameter considered("0" for the first parameter, "1" for the second parameter,etc...). the name to use for the given MBeanParameterInfo. |
postDeregister | public void postDeregister()(Code) | | |
postRegister | public void postRegister(Boolean registrationDone)(Code) | | |
setImplementation | public synchronized void setImplementation(Object implementation) throws NotCompliantMBeanException(Code) | | Replace the implementation object wrapped in this
object.
Parameters: implementation - The new implementation of this MBean.The implementation object must implement the MBeaninterface that was supplied when thisStandardMBean was constructed. exception: IllegalArgumentException - if the givenimplementation is null. exception: NotCompliantMBeanException - if the givenimplementation does not implement the MBeaninterface that was supplied at construction. See Also: StandardMBean.getImplementation |
|
|