public class JmxBean extends Object
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>
Constructor and Description |
---|
JmxBean() |
JmxBean(JmxResourceInfo jmxResourceInfo,
Object target) |
Modifier and Type | Method and Description |
---|---|
JmxAttributeFieldInfo[] |
getAttributeFieldInfos() |
JmxAttributeMethodInfo[] |
getAttributeMethodInfos() |
JmxResourceInfo |
getJmxResourceInfo() |
JmxOperationInfo[] |
getOperationInfos() |
Object |
getTarget() |
void |
setAttributeFieldInfos(JmxAttributeFieldInfo[] attributeFieldInfos)
Optional setting which defines the fields to be exposed as attribute via JMX.
|
void |
setAttributeFieldNames(String fieldNames)
Optional setting which defines a comma separated list of field names.
|
void |
setAttributeMethodInfos(JmxAttributeMethodInfo[] attributeMethodInfos)
Optional setting which defines the methods (get/is/set...) to be exposed as attributes via JMX.
|
void |
setAttributeMethodNames(String methodNames)
Optional setting which defines a comma separated list of field names.
|
void |
setJmxResourceInfo(JmxResourceInfo jmxResourceInfo)
Required resource information which helps to make the ObjectName for the bean that we are exposing via JMX.
|
void |
setOperationInfos(JmxOperationInfo[] operationInfos)
Optional setting which defines the additional methods (not get/is/set...) to be exposed as operations via JMX.
|
void |
setOperationNames(String operationNames)
Optional setting which defines a comma separated list of field names.
|
void |
setTarget(Object target)
Required target object which specifies the Spring bean that we are exposing via JMX.
|
public JmxBean()
public JmxBean(JmxResourceInfo jmxResourceInfo, Object target)
public JmxResourceInfo getJmxResourceInfo()
public void setJmxResourceInfo(JmxResourceInfo jmxResourceInfo)
public JmxAttributeFieldInfo[] getAttributeFieldInfos()
public void setAttributeFieldInfos(JmxAttributeFieldInfo[] attributeFieldInfos)
setAttributeFieldNames(String)
.public void setAttributeFieldNames(String fieldNames)
setAttributeFieldInfos(JmxAttributeFieldInfo[])
.public JmxAttributeMethodInfo[] getAttributeMethodInfos()
public void setAttributeMethodInfos(JmxAttributeMethodInfo[] attributeMethodInfos)
setAttributeMethodNames(String)
.public void setAttributeMethodNames(String methodNames)
setAttributeMethodInfos(JmxAttributeMethodInfo[])
.public JmxOperationInfo[] getOperationInfos()
public void setOperationInfos(JmxOperationInfo[] operationInfos)
public void setOperationNames(String operationNames)
setOperationInfos(JmxOperationInfo[])
.public Object getTarget()
public void setTarget(Object target)
This documentation content is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.