jdk/src/share/classes/javax/management/MXBean.java
changeset 21656 d4c777ccb1db
parent 18805 b359f8adc8ad
child 23010 6dadb192ad81
equal deleted inserted replaced
21655:55f32ae4f920 21656:d4c777ccb1db
    77 
    77 
    78     @MXBean(false)
    78     @MXBean(false)
    79     public interface MisleadingMXBean {}
    79     public interface MisleadingMXBean {}
    80     </pre>
    80     </pre>
    81 
    81 
    82     <h3 id="MXBean-spec">MXBean specification</a></h3>
    82     <h3 id="MXBean-spec">MXBean specification</h3>
    83 
    83 
    84     <p>The MXBean concept provides a simple way to code an MBean
    84     <p>The MXBean concept provides a simple way to code an MBean
    85       that only references a predefined set of types, the ones defined
    85       that only references a predefined set of types, the ones defined
    86       by {@link javax.management.openmbean}.  In this way, you can be
    86       by {@link javax.management.openmbean}.  In this way, you can be
    87       sure that your MBean will be usable by any client, including
    87       sure that your MBean will be usable by any client, including
    91 
    91 
    92     <p>The concepts are easier to understand by comparison with the
    92     <p>The concepts are easier to understand by comparison with the
    93       Standard MBean concept.  Here is how a managed object might be
    93       Standard MBean concept.  Here is how a managed object might be
    94       represented as a Standard MBean, and as an MXBean:</p>
    94       represented as a Standard MBean, and as an MXBean:</p>
    95 
    95 
    96     <table border="1" cellpadding="5">
    96     <table border="1" cellpadding="5" summary="Standard Bean vs. MXBean">
    97       <tr>
    97       <tr>
    98         <th>Standard MBean</th><th>MXBean</th>
    98         <th>Standard MBean</th><th>MXBean</th>
    99       </tr>
    99       </tr>
   100       <tr>
   100       <tr>
   101         <td><pre>
   101         <td><pre>
   131       might get a <code>used</code> value that was greater than the
   131       might get a <code>used</code> value that was greater than the
   132       <code>max</code> value.</p>
   132       <code>max</code> value.</p>
   133 
   133 
   134     <p>So, we might define <code>MemoryUsage</code> like this:</p>
   134     <p>So, we might define <code>MemoryUsage</code> like this:</p>
   135 
   135 
   136     <table border="1" cellpadding="5">
   136     <table border="1" cellpadding="5" summary="Standard Bean vs. MXBean">
   137       <tr>
   137       <tr>
   138         <th>Standard MBean</th><th>MXBean</th>
   138         <th>Standard MBean</th><th>MXBean</th>
   139       </tr>
   139       </tr>
   140       <tr>
   140       <tr>
   141         <td><pre>
   141         <td><pre>
   193       using only standard classes.</p>
   193       using only standard classes.</p>
   194 
   194 
   195     <p>This becomes clearer if we compare what the clients of the two
   195     <p>This becomes clearer if we compare what the clients of the two
   196       models might look like:</p>
   196       models might look like:</p>
   197 
   197 
   198     <table border="1" cellpadding="5">
   198     <table border="1" cellpadding="5" summary="Standard Bean vs. MXBean">
   199       <tr>
   199       <tr>
   200         <th>Standard MBean</th><th>MXBean</th>
   200         <th>Standard MBean</th><th>MXBean</th>
   201       </tr>
   201       </tr>
   202       <tr>
   202       <tr>
   203         <td><pre>
   203         <td><pre>
   230       class <code>MemoryUsage</code>, then it can construct a
   230       class <code>MemoryUsage</code>, then it can construct a
   231       <em>proxy</em>.  This is the recommended way to interact with
   231       <em>proxy</em>.  This is the recommended way to interact with
   232       managed objects when you know the model beforehand, regardless
   232       managed objects when you know the model beforehand, regardless
   233       of whether you are using Standard MBeans or MXBeans:</p>
   233       of whether you are using Standard MBeans or MXBeans:</p>
   234 
   234 
   235     <table border="1" cellpadding="5">
   235     <table border="1" cellpadding="5" summary="Standard Bean vs. MXBean">
   236       <tr>
   236       <tr>
   237         <th>Standard MBean</th><th>MXBean</th>
   237         <th>Standard MBean</th><th>MXBean</th>
   238       </tr>
   238       </tr>
   239       <tr>
   239       <tr>
   240         <td><pre>
   240         <td><pre>
   263     </table>
   263     </table>
   264 
   264 
   265     <p>Implementing the MemoryPool object works similarly for both
   265     <p>Implementing the MemoryPool object works similarly for both
   266       Standard MBeans and MXBeans.</p>
   266       Standard MBeans and MXBeans.</p>
   267 
   267 
   268     <table border="1" cellpadding="5">
   268     <table border="1" cellpadding="5" summary="Standard Bean vs. MXBean">
   269       <tr>
   269       <tr>
   270         <th>Standard MBean</th><th>MXBean</th>
   270         <th>Standard MBean</th><th>MXBean</th>
   271       </tr>
   271       </tr>
   272       <tr>
   272       <tr>
   273         <td><pre>
   273         <td><pre>
   290     </table>
   290     </table>
   291 
   291 
   292     <p>Registering the MBean in the MBean Server works in the same way
   292     <p>Registering the MBean in the MBean Server works in the same way
   293       in both cases:</p>
   293       in both cases:</p>
   294 
   294 
   295     <table border="1" cellpadding="5">
   295     <table border="1" cellpadding="5" summary="Standard Bean vs. MXBean">
   296       <tr>
   296       <tr>
   297         <th>Standard MBean</th><th>MXBean</th>
   297         <th>Standard MBean</th><th>MXBean</th>
   298       </tr>
   298       </tr>
   299       <tr>
   299       <tr>
   300         <td><pre>
   300         <td><pre>
   476       from type <em>opendata(J)</em> to type <em>J</em>, a null value is
   476       from type <em>opendata(J)</em> to type <em>J</em>, a null value is
   477       mapped to a null value.</p>
   477       mapped to a null value.</p>
   478 
   478 
   479     <p>The following table summarizes the type mapping rules.</p>
   479     <p>The following table summarizes the type mapping rules.</p>
   480 
   480 
   481     <table border="1" cellpadding="5">
   481     <table border="1" cellpadding="5" summary="Type Mapping Rules">
   482       <tr>
   482       <tr>
   483         <th>Java type <em>J</em></th>
   483         <th>Java type <em>J</em></th>
   484         <th><em>opentype(J)</em></th>
   484         <th><em>opentype(J)</em></th>
   485         <th><em>opendata(J)</em></th>
   485         <th><em>opendata(J)</em></th>
   486       </tr>
   486       </tr>
   487       <tbody cellvalign="top">
   487       <tbody valign="top">
   488         <tr>
   488         <tr>
   489           <td>{@code int}, {@code boolean}, etc<br>
   489           <td>{@code int}, {@code boolean}, etc<br>
   490             (the 8 primitive Java types)</td>
   490             (the 8 primitive Java types)</td>
   491           <td>{@code SimpleType.INTEGER},<br>
   491           <td>{@code SimpleType.INTEGER},<br>
   492             {@code SimpleType.BOOLEAN}, etc</td>
   492             {@code SimpleType.BOOLEAN}, etc</td>
   783     <blockquote>
   783     <blockquote>
   784       <code>boolean is<em>Name</em>()</code>
   784       <code>boolean is<em>Name</em>()</code>
   785     </blockquote>
   785     </blockquote>
   786 
   786 
   787     then the item in the {@code CompositeType} is called {@code name}
   787     then the item in the {@code CompositeType} is called {@code name}
   788     and has type {@code SimpleType.BOOLEAN}.</p>
   788     and has type {@code SimpleType.BOOLEAN}.
   789 
   789 
   790     <p>Notice that the first character (or code point) is converted to
   790     <p>Notice that the first character (or code point) is converted to
   791       lower case.  This follows the Java Beans convention, which for
   791       lower case.  This follows the Java Beans convention, which for
   792       historical reasons is different from the Standard MBean
   792       historical reasons is different from the Standard MBean
   793       convention.  In a Standard MBean or MXBean interface, a method
   793       convention.  In a Standard MBean or MXBean interface, a method