Class JmxBean

java.lang.Object
com.j256.simplejmx.spring.JmxBean

public class JmxBean extends Object
With this bean, which is auto-detect by the BeanPublisher, you can configure in Spring a JMX bean for an object that does not use the JmxResource annotation or JmxSelfNaming interface.

For example:

<!-- some random bean defined in your spring files -->
<bean id="someBean" class="your.domain.SomeBean">
   ...
</bean>

<!-- publish information about that bean via JMX -->
<bean id="someBeanJmx" class="com.j256.simplejmx.spring.JmxBean">
   <!-- helps build the ObjectName -->
   <property name="jmxResourceInfo">
      <bean class="com.j256.simplejmx.common.JmxResourceInfo">
         <property name="jmxDomainName" value="your.domain" />
         <property name="jmxBeanName" value="SomeBean" />
      </bean>
   </property>
   <!-- defines the fields that are exposed for JMX -->
   <property name="attributeFieldInfos">
      <array>
         <bean class="com.j256.simplejmx.common.JmxAttributeFieldInfo">
            <property name="name" value="someCounter" />
         </bean>
      </array>
   </property>
   <!-- defines the get/is/set methods exposed -->
   <property name="attributeMethodInfos">
      <array>
         <bean class="com.j256.simplejmx.common.JmxAttributeMethodInfo">
            <property name="methodName" value="getSomeValue" />
         </bean>
      </array>
   </property>
   <!-- defines the operations (i.e. non get/is/set) methods exposed -->
   <property name="operationInfos">
      <array>
         <bean class="com.j256.simplejmx.common.JmxOperationInfo">
            <property name="methodName" value="someMethod" />
         </bean>
      </array>
   </property>
   <property name="target" ref="someBean" />
</bean>
You can also use setAttributeFieldNames(String), setAttributeMethodNames(String), and setOperationNames(String) by injecting a comma-separate list of names.
<bean id="jmxServerJmx" class="com.j256.simplejmx.spring.JmxBean">
   <property name="jmxResourceInfo"> ... </property>
   <!-- defines the fields names that are exposed for JMX -->
   <property name="attributeFieldNames" value="someCounter,someOtherField" />
   <property name="attributeMethodNames" value="getSomeValue" />
   <property name="operationNames" value="methodName" />
   <property name="target" ref="someBean" />
</bean>
Author:
graywatson
  • Constructor Details

  • Method Details

    • getJmxResourceInfo

      public JmxResourceInfo getJmxResourceInfo()
    • setJmxResourceInfo

      public void setJmxResourceInfo(JmxResourceInfo jmxResourceInfo)
      Required resource information which helps to make the ObjectName for the bean that we are exposing via JMX.
    • getAttributeFieldInfos

      public JmxAttributeFieldInfo[] getAttributeFieldInfos()
    • setAttributeFieldInfos

      public void setAttributeFieldInfos(JmxAttributeFieldInfo[] attributeFieldInfos)
      Optional setting which defines the fields to be exposed as attribute via JMX. If you just need to list the field names then you should use setAttributeFieldNames(String).
    • setAttributeFieldNames

      public void setAttributeFieldNames(String fieldNames)
      Optional setting which defines a comma separated list of field names. If you want descriptions then you should use setAttributeFieldInfos(JmxAttributeFieldInfo[]).
    • getAttributeMethodInfos

      public JmxAttributeMethodInfo[] getAttributeMethodInfos()
    • setAttributeMethodInfos

      public void setAttributeMethodInfos(JmxAttributeMethodInfo[] attributeMethodInfos)
      Optional setting which defines the methods (get/is/set...) to be exposed as attributes via JMX. If you just need to list the method names then you should use setAttributeMethodNames(String).
    • setAttributeMethodNames

      public void setAttributeMethodNames(String methodNames)
      Optional setting which defines a comma separated list of field names. If you want descriptions then you should use setAttributeMethodInfos(JmxAttributeMethodInfo[]).
    • getOperationInfos

      public JmxOperationInfo[] getOperationInfos()
    • setOperationInfos

      public void setOperationInfos(JmxOperationInfo[] operationInfos)
      Optional setting which defines the additional methods (not get/is/set...) to be exposed as operations via JMX.
    • setOperationNames

      public void setOperationNames(String operationNames)
      Optional setting which defines a comma separated list of field names. If you want descriptions then you should use setOperationInfos(JmxOperationInfo[]).
    • getTarget

      public Object getTarget()
    • setTarget

      public void setTarget(Object target)
      Required target object which specifies the Spring bean that we are exposing via JMX.