jdk/src/share/classes/javax/management/MXBean.java
changeset 834 dc74d4ddc28e
parent 715 f16baef3a20e
parent 833 bfa2bef7517c
child 1004 5ba8217eb504
--- a/jdk/src/share/classes/javax/management/MXBean.java	Sat Jul 05 23:29:16 2008 -0700
+++ b/jdk/src/share/classes/javax/management/MXBean.java	Wed Jul 09 09:56:00 2008 -0700
@@ -27,6 +27,7 @@
 
 import java.lang.annotation.Documented;
 import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
@@ -57,11 +58,13 @@
 import javax.management.openmbean.TabularType;
 
 /**
-    <p>Annotation to mark an interface explicitly as being an MXBean
-    interface, or as not being an MXBean interface.  By default, an
+    <p>Annotation to mark a class or interface explicitly as being an MXBean,
+    or as not being an MXBean.  By default, an
     interface is an MXBean interface if its name ends with {@code
-    MXBean}, as in {@code SomethingMXBean}.  The following interfaces
-    are MXBean interfaces:</p>
+    MXBean}, as in {@code SomethingMXBean}.  A class is never an MXBean by
+    default.</p>
+
+    <p>The following interfaces are MXBean interfaces:</p>
 
     <pre>
     public interface WhatsitMXBean {}
@@ -82,6 +85,11 @@
     public interface MisleadingMXBean {}
     </pre>
 
+    <p>A class can be annotated with {@code @MXBean} to indicate that it
+    is an MXBean.  In this case, its methods should have <code>&#64;{@link
+    ManagedAttribute}</code> or <code>&#64;{@link ManagedOperation}</code>
+    annotations, as described for <code>&#64;{@link MBean}</code>.</p>
+
     <h3 id="MXBean-spec">MXBean specification</h3>
 
     <p>The MXBean concept provides a simple way to code an MBean
@@ -1246,9 +1254,24 @@
    @since 1.6
 */
 
+/*
+ * This annotation is @Inherited because if an MXBean is defined as a
+ * class using annotations, then its subclasses are also MXBeans.
+ * For example:
+ * @MXBean
+ * public class Super {
+ *     @ManagedAttribute
+ *     public String getName() {...}
+ * }
+ * public class Sub extends Super {}
+ * Here Sub is an MXBean.
+ *
+ * The @Inherited annotation has no effect when applied to an interface.
+ */
 @Documented
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.TYPE)
+@Inherited
 public @interface MXBean {
     /**
        True if the annotated interface is an MXBean interface.