Show Table of Contents

5.2.3. JBoss XMBeans
XMBeans are the JBoss JMX implementation version of the JMX model MBean. XMBeans have the richness of the dynamic MBean metadata without the tedious programming required by a direct implementation of the
DynamicMBean interface. The JBoss model MBean implementation allows one to specify the management interface of a component through a XML descriptor, hence the X in XMBean. In addition to providing a simple mechanism for describing the metadata required for a dynamic MBean, XMBeans also allow for the specification of attribute persistence, caching behavior, and even advanced customizations like the MBean implementation interceptors. The high level elements of the jboss_xmbean_1_2.dtd for the XMBean descriptor is given in Figure 5.6, “The JBoss 1.0 XMBean DTD Overview (jboss_xmbean_1_2.dtd)”.

Figure 5.6. The JBoss 1.0 XMBean DTD Overview (jboss_xmbean_1_2.dtd)
The
mbean element is the root element of the document containing the required elements for describing the management interface of one MBean (constructors, attributes, operations and notifications). It also includes an optional description element, which can be used to describe the purpose of the MBean, as well as an optional descriptors element which allows for persistence policy specification, attribute caching, etc.
5.2.3.1. Descriptors
The descriptors element contains all the descriptors for a containing element, as subelements. The descriptors suggested in the JMX specification as well as those used by JBoss have predefined elements and attributes, whereas custom descriptors have a generic descriptor element with name and value attributes as show in Figure 5.7, “ The descriptors element content model”.

Figure 5.7. The descriptors element content model
The key descriptors child elements include:
- interceptors: The
interceptorselement specifies a customized stack of interceptors that will be used in place of the default stack. Currently this is only used when specified at the MBean level, but it could define a custom attribute or operation level interceptor stack in the future. The content of the interceptors element specifies a custom interceptor stack. If no interceptors element is specified the standardModelMBeaninterceptors will be used. The standard interceptors are:- org.jboss.mx.interceptor.PersistenceInterceptor
- org.jboss.mx.interceptor.MBeanAttributeInterceptor
- org.jboss.mx.interceptor.ObjectReferenceInterceptor
When specifying a custom interceptor stack you would typically include the standard interceptors along with your own unless you are replacing the corresponding standard interceptor.Each interceptor element content value specifies the fully qualified class name of the interceptor implementation. The class must implement theorg.jboss.mx.interceptor.Interceptorinterface. The interceptor class must also have either a no-arg constructor, or a constructor that accepts ajavax.management.MBeanInfo.The interceptor elements may have any number of attributes that correspond to JavaBean style properties on the interceptor class implementation. For eachinterceptorelement attribute specified, the interceptor class is queried for a matching setter method. The attribute value is converted to the true type of the interceptor class property using thejava.beans.PropertyEditorassociated with the type. It is an error to specify an attribute for which there is no setter orPropertyEditor. - persistence: The
persistenceelement allows the specification of thepersistPolicy,persistPeriod,persistLocation, andpersistNamepersistence attributes suggested by the JMX specification. The persistence element attributes are:- persistPolicy: The
persistPolicyattribute defines when attributes should be persisted and its value must be one of- Never: attribute values are transient values that are never persisted
- OnUpdate: attribute values are persisted whenever they are updated
- OnTimer: attribute values are persisted based on the time given by the
persistPeriod. - NoMoreOftenThan: attribute values are persisted when updated but no more often than the
persistPeriod.
- persistPeriod: The
persistPeriodattribute gives the update frequency in milliseconds if theperisitPolicyattribute isNoMoreOftenThanorOnTimer. - persistLocation: The
persistLocationattribute specifies the location of the persistence store. Its form depends on the JMX persistence implementation. Currently this should refer to a directory into which the attributes will be serialized if using the default JBoss persistence manager. - persistName: The
persistNameattribute can be used in conjunction with thepersistLocationattribute to further qualify the persistent store location. For a directorypersistLocationthepersistNamespecifies the file to which the attributes are stored within the directory.
- currencyTimeLimit: The
currencyTimeLimitelement specifies the time in seconds that a cached value of an attribute remains valid. Its value attribute gives the time in seconds. A value of 0 indicates that an attribute value should always be retrieved from the MBean and never cached. A value of -1 indicates that a cache value is always valid. - display-name: The
display-nameelement specifies the human friendly name of an item. - default: The
defaultelement specifies a default value to use when a field has not been set. Note that this value is not written to the MBean on startup as is the case with thejboss-service.xmlattribute element content value. Rather, the default value is used only if there is no attribute accessor defined, and there is no value element defined. - value: The
valueelement specifies a management attribute's current value. Unlike thedefaultelement, thevalueelement is written through to the MBean on startup provided there is a setter method available. - persistence-manager: The
persistence-managerelement gives the name of a class to use as the persistence manager. Thevalueattribute specifies the class name that supplies theorg.jboss.mx.persistence.PersistenceManagerinterface implementation. The only implementation currently supplied by JBoss is theorg.jboss.mx.persistence.ObjectStreamPersistenceManagerwhich serializes theModelMBeanInfocontent to a file using Java serialization. - descriptor: The
descriptorelement specifies an arbitrary descriptor not known to JBoss. Itsnameattribute specifies the type of the descriptor and itsvalueattribute specifies the descriptor value. Thedescriptorelement allows for the attachment of arbitrary management metadata. - injection: The
injectionelement describes an injection point for receiving information from the microkernel. Each injection point specifies the type and the set method to use to inject the information into the resource. Theinjectionelement supports type attributes:- id: The
idattribute specifies the injection point type. The current injection point types are:- MBeanServerType: An MBeanServerType injection point receives a reference to the MBeanServer that the XMBean is registered with.
- MBeanInfoType: An MBeanInfoType injection point receives a reference to the XMBean ModelMBeanInfo metadata.
- ObjectNameType: The ObjectName injection point receives the ObjectName that the XMBean is registered under.
- setMethod: The setMethod attribute gives the name of the method used to set the injection value on the resource. The set method should accept values of the type corresponding to the injection point type.
Note that any of the constructor, attribute, operation or notification elements may have a
descriptors element to specify the specification defined descriptors as well as arbitrary extension descriptor settings.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.