Java Reference
In-Depth Information
Another MBean assembler is InterfaceBasedMBeanInfoAssembler , which exports all methods
defined in the interfaces you specified.
<bean id="assembler" class="org.springframework.jmx.export.assembler.
<property name="managedInterfaces">
Spring also provides MetadataMBeanInfoAssembler to assemble an MBean's management interface
based on the metadata in the bean class. It supports two types of metadata: JDK annotations and
Apache Commons Attributes (behind the scenes, this is accomplished using a strategy interface
JmxAttributeSource ). For a bean class annotated with JDK annotations, you specify an
AnnotationJmxAttributeSource instance as the attribute source of MetadataMBeanInfoAssembler .
<bean id="assembler" class="org.springframework.jmx.export.assembler.
<property name="attributeSource">
<bean class="org.springframework.jmx.export.annotation.
AnnotationJmxAttributeSource" />
Then you annotate your bean class and methods with the annotations @ManagedResource ,
@ManagedAttribute , and @ManagedOperation for MetadataMBeanInfoAssembler to assemble the
management interface for this bean. The annotations are easily interpreted. They expose the element
that they annotate. If you have a JavaBeans-compliant property, JMX will use the term attribute . Classes
themselves are referred to as resources . In JMX, methods will be called operations . Knowing that, it's easy
to see what the following code does:
package com.apress.springenterpriserecipes.replicator;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
@ManagedResource(description = "File replicator")
public class FileReplicatorImpl implements FileReplicator {
@ManagedAttribute(description = "Get source directory")
public String getSrcDir() {
Search WWH ::

Custom Search