diff --git a/spring-framework-reference/src/jmx.xml b/spring-framework-reference/src/jmx.xml index 1620fa16171..d5d2a5e6370 100644 --- a/spring-framework-reference/src/jmx.xml +++ b/spring-framework-reference/src/jmx.xml @@ -421,178 +421,31 @@ public class JmxTestBean implements IJmxTestBean {
- Using source-Level metadata + Using source-Level metadata (JDK 5.0 annotations) Using the MetadataMBeanInfoAssembler you can define the management interfaces for your beans using source level metadata. The reading of metadata is encapsulated by the org.springframework.jmx.export.metadata.JmxAttributeSource - interface. Out of the box, Spring JMX provides support for two - implementations of this interface: - org.springframework.jmx.export.metadata.AttributesJmxAttributeSource - for Commons Attributes and - org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource - for JDK 5.0 annotations. The + interface. Spring JMX provides a default implementation which uses JDK 5.0 annotations, namely + org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource. The MetadataMBeanInfoAssembler must be configured with an implementation instance of the JmxAttributeSource interface for it to - function correctly (there is no default). For the - following example, we will use the Commons Attributes metadata - approach. + function correctly (there is no default). To mark a bean for export to JMX, you should annotate the bean - class with the ManagedResource attribute. In the - case of the Commons Attributes metadata approach this class can be found - in the org.springframework.jmx.metadata package. Each + class with the ManagedResource annotation. Each method you wish to expose as an operation must be marked with the - ManagedOperation attribute and each property you + ManagedOperation annotation and each property you wish to expose must be marked with the - ManagedAttribute attribute. When marking + ManagedAttribute annotation. When marking properties you can omit either the annotation of the getter or the setter to create a write-only or read-only attribute respectively. - The example below shows the JmxTestBean - class that you saw earlier marked with Commons Attributes - metadata: - - - - Here you can see that the JmxTestBean class - is marked with the ManagedResource attribute and - that this ManagedResource attribute is configured - with a set of properties. These properties can be used to configure - various aspects of the MBean that is generated by the - MBeanExporter, and are explained in greater - detail later in section entitled . - - You will also notice that both the age and - name properties are annotated with the - ManagedAttribute attribute, but in the case of - the age property, only the getter is marked. This - will cause both of these properties to be included in the management - interface as attributes, but the age attribute will - be read-only. - - Finally, you will notice that the add(int, int) - method is marked with the ManagedOperation - attribute whereas the dontExposeMe() method is not. - This will cause the management interface to contain only one operation, - add(int, int), when using the - MetadataMBeanInfoAssembler. - - The code below shows how you configure the - MBeanExporter to use the - MetadataMBeanInfoAssembler: - - - - - - - - - - - - - - - - - - - - - - - - - - - -]]> - - Here you can see that an - MetadataMBeanInfoAssembler bean has been - configured with an instance of the - AttributesJmxAttributeSource class and passed to - the MBeanExporter through the assembler property. - This is all that is required to take advantage of metadata-driven - management interfaces for your Spring-exposed MBeans. -
- -
- Using JDK 5.0 Annotations - - To enable the use of JDK 5.0 annotations for management interface - definition, Spring provides a set of annotations that mirror the Commons - Attribute attribute classes and an implementation of the - JmxAttributeSource strategy interface, - the AnnotationsJmxAttributeSource class, that - allows the MBeanInfoAssembler to read - them. - - The example below shows a bean where the management interface is defined - by the presence of JDK 5.0 annotation types: - + The example below shows the annotated version of the + JmxTestBean class that you saw earlier: - As you can see little has changed, other than the basic syntax of - the metadata definitions. + Here you can see that the JmxTestBean class + is marked with the ManagedResource annotation and + that this ManagedResource annotation is configured + with a set of properties. These properties can be used to configure + various aspects of the MBean that is generated by the + MBeanExporter, and are explained in greater + detail later in section entitled . + You will also notice that both the age and + name properties are annotated with the + ManagedAttribute annotation, but in the case of + the age property, only the getter is marked. This + will cause both of these properties to be included in the management + interface as attributes, but the age attribute will + be read-only. + + Finally, you will notice that the add(int, int) + method is marked with the ManagedOperation + attribute whereas the dontExposeMe() method is not. + This will cause the management interface to contain only one operation, + add(int, int), when using the + MetadataMBeanInfoAssembler. + + The configuration below shouws how you configure the + MBeanExporter to use the + MetadataMBeanInfoAssembler: @@ -672,6 +549,15 @@ public class AnnotationTestBean implements IJmxTestBean { ]]> + + + Here you can see that an + MetadataMBeanInfoAssembler bean has been + configured with an instance of the + AnnotationJmxAttributeSource class and passed to + the MBeanExporter through the assembler property. + This is all that is required to take advantage of metadata-driven + management interfaces for your Spring-exposed MBeans.
@@ -690,17 +576,13 @@ public class AnnotationTestBean implements IJmxTestBean { - - Purpose - Commons Attributes Attribute + Annotation - JDK 5.0 Annotation - - Attribute / Annotation Type + Annotation Type @@ -709,8 +591,6 @@ public class AnnotationTestBean implements IJmxTestBean { Mark all instances of a Class as JMX managed resources - ManagedResource - @ManagedResource Class @@ -719,8 +599,6 @@ public class AnnotationTestBean implements IJmxTestBean { Mark a method as a JMX operation - ManagedOperation - @ManagedOperation Method @@ -730,8 +608,6 @@ public class AnnotationTestBean implements IJmxTestBean { Mark a getter or setter as one half of a JMX attribute - ManagedAttribute - @ManagedAttribute Method (only getters and setters) @@ -740,8 +616,6 @@ public class AnnotationTestBean implements IJmxTestBean { Define descriptions for operation parameters - ManagedOperationParameter - @ManagedOperationParameter and @ManagedOperationParameters @@ -924,22 +798,10 @@ public class AnnotationTestBean implements IJmxTestBean { - ]]><!-- (for Commons Attributes-based metadata) --> - - - - - - ]]><!-- (for Java 5+ annotations-based metadata) --> - -->]]> - + + + ]]> @@ -1222,9 +1084,9 @@ public class AnnotationTestBean implements IJmxTestBean { assembler, and attributeSource configuration is no longer needed, since it will always use standard Java annotation-based metadata (autodetection is always enabled as well). In fact, - an even simpler syntax is supported with the inclusion of Spring's - 'context' namespace in Spring 2.5. Rather than defining an - MBeanExporter bean, provide this single element: + an even simpler syntax is supported by Spring's + 'context' namespace.. Rather than defining an + MBeanExporter bean, just provide this single element: ]]>