From 362926daf07583b809e59790f9243ebf7afa5189 Mon Sep 17 00:00:00 2001 From: Luke Taylor Date: Fri, 13 Nov 2009 17:18:13 +0000 Subject: [PATCH] SPR-6338: Rewrite of source-level JMX metadata to remove references to commons attributes git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@2431 50f2f4bb-b051-0410-bef5-90022cba6387 --- spring-framework-reference/src/jmx.xml | 234 +++++-------------------- 1 file changed, 48 insertions(+), 186 deletions(-) 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,60 +421,46 @@ 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: - + The example below shows the annotated version of the + JmxTestBean class that you saw earlier: Here you can see that the JmxTestBean class - is marked with the ManagedResource attribute and - that this ManagedResource attribute is configured + 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 @@ -524,7 +506,7 @@ public class JmxTestBean implements IJmxTestBean { You will also notice that both the age and name properties are annotated with the - ManagedAttribute attribute, but in the case of + 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 @@ -537,114 +519,9 @@ public class JmxTestBean implements IJmxTestBean { add(int, int), when using the MetadataMBeanInfoAssembler. - The code below shows how you configure the + The configuration below shouws 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: - - - - As you can see little has changed, other than the basic syntax of - the metadata definitions. - @@ -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 - - JDK 5.0 Annotation + 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: ]]>