java.lang.Objectjavax.management.StandardMBean
public class 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(...); mbs.registerMBean(mbean, objectName);
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.
| Constructor Summary | |
|---|---|
protected |
StandardMBean(Class mbeanInterface)
Make a DynamicMBean out of this, using the specified mbeanInterface class. |
|
StandardMBean(Object implementation,
Class mbeanInterface)
Make a DynamicMBean out of the object implementation, using the specified mbeanInterface class. |
| Method Summary | |
|---|---|
protected void |
cacheMBeanInfo(MBeanInfo info)
Customization hook: cache the MBeanInfo built for this object. |
Object |
getAttribute(String attribute)
Obtain the value of a specific attribute of the Dynamic MBean. |
AttributeList |
getAttributes(String[] attributes)
Get the values of several attributes of the Dynamic MBean. |
protected MBeanInfo |
getCachedMBeanInfo()
Customization hook: Return the MBeanInfo cached for this object. |
protected String |
getClassName(MBeanInfo info)
Customization hook: Get the className that will be used in the MBeanInfo returned by this MBean. |
protected MBeanConstructorInfo[] |
getConstructors(MBeanConstructorInfo[] ctors,
Object impl)
Customization hook: Get the MBeanConstructorInfo[] that will be used in the MBeanInfo returned by this MBean. |
protected String |
getDescription(MBeanAttributeInfo info)
Customization hook: Get the description that will be used in the MBeanAttributeInfo returned by this MBean. |
protected String |
getDescription(MBeanConstructorInfo info)
Customization hook: Get the description that will be used in the MBeanConstructorInfo returned by this MBean. |
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. |
protected String |
getDescription(MBeanFeatureInfo info)
Customization hook: Get the description that will be used in the MBeanFeatureInfo returned by this MBean. |
protected String |
getDescription(MBeanInfo info)
Customization hook: Get the description that will be used in the MBeanInfo returned by this MBean. |
protected String |
getDescription(MBeanOperationInfo info)
Customization hook: Get the description that will be used in the MBeanOperationInfo returned by this MBean. |
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. |
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. |
Object |
getImplementation()
Get the implementation of this MBean. |
Class |
getImplementationClass()
Get the class of the implementation of this MBean. |
MBeanInfo |
getMBeanInfo()
Get the MBeanInfo for this MBean. |
Class |
getMBeanInterface()
Get the Management Interface of this MBean. |
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. |
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. |
Object |
invoke(String actionName,
Object[] params,
String[] signature)
Allows an action to be invoked on the Dynamic MBean. |
void |
setAttribute(Attribute attribute)
Set the value of a specific attribute of the Dynamic MBean. |
AttributeList |
setAttributes(AttributeList attributes)
Sets the values of several attributes of the Dynamic MBean. |
void |
setImplementation(Object implementation)
Replace the implementation object wrapped in this object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StandardMBean(Object implementation, Class mbeanInterface) throws NotCompliantMBeanException
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.protected StandardMBean(Class mbeanInterface) throws NotCompliantMBeanException
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.| Method Detail |
|---|
public void setImplementation(Object implementation) throws NotCompliantMBeanException
Replace the implementation object wrapped in this object.
implementation - The new implementation of this MBean.
The implementation object must implement the MBean
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 MBean
interface that was supplied at construction.getImplementation()public Object getImplementation()
setImplementation(java.lang.Object)public final Class getMBeanInterface()
public Class getImplementationClass()
public Object getAttribute(String attribute) throws AttributeNotFoundException, MBeanException, ReflectionException
DynamicMBean
getAttribute in interface DynamicMBeanattribute - The name of the attribute to be retrieved
AttributeNotFoundException
MBeanException - Wraps a java.lang.Exception thrown by the MBean's getter.
ReflectionException - Wraps a java.lang.Exception thrown while trying to invoke the getter.DynamicMBean.setAttribute(javax.management.Attribute)public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
DynamicMBean
setAttribute in interface DynamicMBeanattribute - The identification of the attribute to
be set and the value it is to be set to.
AttributeNotFoundException
InvalidAttributeValueException
MBeanException - Wraps a java.lang.Exception thrown by the MBean's setter.
ReflectionException - Wraps a java.lang.Exception thrown while trying to invoke the MBean's setter.DynamicMBean.getAttribute(java.lang.String)public AttributeList getAttributes(String[] attributes)
DynamicMBean
getAttributes in interface DynamicMBeanattributes - A list of the attributes to be retrieved.
DynamicMBean.setAttributes(javax.management.AttributeList)public AttributeList setAttributes(AttributeList attributes)
DynamicMBean
setAttributes in interface DynamicMBeanattributes - A list of attributes: The identification of the
attributes to be set and the values they are to be set to.
DynamicMBean.getAttributes(java.lang.String[])public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException
DynamicMBean
invoke in interface DynamicMBeanactionName - 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.
MBeanException - Wraps a java.lang.Exception thrown by the MBean's invoked method.
ReflectionException - Wraps a java.lang.Exception thrown while trying to invoke the methodpublic MBeanInfo getMBeanInfo()
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.
getMBeanInfo in interface DynamicMBeanprotected String getClassName(MBeanInfo info)
info.getClassName().
info - The default MBeanInfo derived by reflection.
protected String getDescription(MBeanInfo info)
info.getDescription().
info - The default MBeanInfo derived by reflection.
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. The default implementation returns
info.getDescription().
This method is called by
getDescription(MBeanAttributeInfo),
getDescription(MBeanOperationInfo),
getDescription(MBeanConstructorInfo).
info - The default MBeanFeatureInfo derived by reflection.
protected String getDescription(MBeanAttributeInfo info)
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.
protected String getDescription(MBeanConstructorInfo info)
getDescription((MBeanFeatureInfo) info).
info - The default MBeanConstructorInfo derived by reflection.
protected String getDescription(MBeanConstructorInfo ctor, MBeanParameterInfo param, int sequence)
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...).
protected String getParameterName(MBeanConstructorInfo ctor, MBeanParameterInfo param, int sequence)
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...).
protected String getDescription(MBeanOperationInfo info)
getDescription((MBeanFeatureInfo) info).
info - The default MBeanOperationInfo derived by reflection.
protected int getImpact(MBeanOperationInfo info)
info.getImpact().
info - The default MBeanOperationInfo derived by reflection.
protected String getParameterName(MBeanOperationInfo op, MBeanParameterInfo param, int sequence)
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...).
protected String getDescription(MBeanOperationInfo op, MBeanParameterInfo param, int sequence)
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...).
protected MBeanConstructorInfo[] getConstructors(MBeanConstructorInfo[] ctors, Object impl)
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(...).
ctors - The default MBeanConstructorInfo[] derived by reflection.impl - The wrapped implementation. If null is
passed, the wrapped implementation is ignored and
ctors is returned.
protected MBeanInfo getCachedMBeanInfo()
Subclasses may redefine this method in order to implement their
own caching policy. The default implementation stores one
MBeanInfo object per instance.
cacheMBeanInfo(MBeanInfo)protected void cacheMBeanInfo(MBeanInfo info)
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.Ces informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
6 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)