jdk/src/share/classes/javax/management/MXBean.java
author emcmanus
Wed, 06 Aug 2008 18:28:53 +0200
changeset 1011 2cc4873fa29f
parent 1004 5ba8217eb504
child 1153 6b88c071a015
permissions -rw-r--r--
6734273: Minor updates to documentation of Custom MXBean Mappings Reviewed-by: dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 687
diff changeset
     2
 * Copyright 2005-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.management;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.lang.annotation.Documented;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.lang.annotation.ElementType;
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
    30
import java.lang.annotation.Inherited;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.lang.annotation.Retention;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.lang.annotation.RetentionPolicy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.lang.annotation.Target;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
// remaining imports are for Javadoc
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.InvalidObjectException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.lang.management.MemoryUsage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.lang.reflect.UndeclaredThrowableException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import javax.management.openmbean.ArrayType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import javax.management.openmbean.CompositeData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import javax.management.openmbean.CompositeDataInvocationHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import javax.management.openmbean.CompositeDataSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import javax.management.openmbean.CompositeDataView;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import javax.management.openmbean.CompositeType;
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    47
import javax.management.openmbean.MXBeanMapping;
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    48
import javax.management.openmbean.MXBeanMappingClass;
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    49
import javax.management.openmbean.MXBeanMappingFactory;
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    50
import javax.management.openmbean.MXBeanMappingFactoryClass;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import javax.management.openmbean.OpenDataException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
import javax.management.openmbean.OpenMBeanInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
import javax.management.openmbean.OpenType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
import javax.management.openmbean.SimpleType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import javax.management.openmbean.TabularData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import javax.management.openmbean.TabularDataSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import javax.management.openmbean.TabularType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
/**
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
    60
    <p>Annotation to mark a class or interface explicitly as being an MXBean,
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
    61
    or as not being an MXBean.  By default, an
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    interface is an MXBean interface if its name ends with {@code
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
    63
    MXBean}, as in {@code SomethingMXBean}.  A class is never an MXBean by
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
    64
    default.</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
    65
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
    66
    <p>The following interfaces are MXBean interfaces:</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    public interface WhatsitMXBean {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    &#64;MXBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public interface Whatsit1Interface {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    &#64;MXBean(true)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public interface Whatsit2Interface {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    <p>The following interfaces are not MXBean interfaces:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    public interface Whatsit3Interface{}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    &#64;MXBean(false)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    public interface MisleadingMXBean {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
    87
    <p>A class can be annotated with {@code @MXBean} to indicate that it
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
    88
    is an MXBean.  In this case, its methods should have <code>&#64;{@link
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
    89
    ManagedAttribute}</code> or <code>&#64;{@link ManagedOperation}</code>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
    90
    annotations, as described for <code>&#64;{@link MBean}</code>.</p>
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
    91
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
    92
    <h3 id="MXBean-spec">MXBean specification</h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    <p>The MXBean concept provides a simple way to code an MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
      that only references a predefined set of types, the ones defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
      by {@link javax.management.openmbean}.  In this way, you can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
      sure that your MBean will be usable by any client, including
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
      remote clients, without any requirement that the client have
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
      access to <em>model-specific classes</em> representing the types
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
      of your MBeans.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    <p>The concepts are easier to understand by comparison with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
      Standard MBean concept.  Here is how a managed object might be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
      represented as a Standard MBean, and as an MXBean:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    <table border="1" cellpadding="5">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        <th>Standard MBean</th><th>MXBean</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
      </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        <td><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
public interface MemoryPool<b>MBean</b> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    String getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    MemoryUsage getUsage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    // ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
          </pre></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        <td><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
public interface MemoryPool<b>MXBean</b> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    String getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    MemoryUsage getUsage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    // ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
          </pre></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
      </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    <p>As you can see, the definitions are very similar.  The only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
      difference is that the convention for naming the interface is to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
      <code><em>Something</em>MXBean</code> for MXBeans, rather than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
      <code><em>Something</em>MBean</code> for Standard MBeans.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    <p>In this managed object, there is an attribute called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
      <code>Usage</code> of type {@link MemoryUsage}.  The point of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
      attribute like this is that it gives a coherent snapshot of a set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
      of data items.  For example, it might include the current amount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
      of used memory in the memory pool, and the current maximum of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
      memory pool.  If these were separate items, obtained with separate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
      {@link MBeanServer#getAttribute getAttribute} calls, then we could
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
      get values seen at different times that were not consistent.  We
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
      might get a <code>used</code> value that was greater than the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
      <code>max</code> value.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    <p>So, we might define <code>MemoryUsage</code> like this:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    <table border="1" cellpadding="5">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        <th>Standard MBean</th><th>MXBean</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
      </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        <td><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
public class MemoryUsage <b>implements Serializable</b> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    // standard JavaBean conventions with getters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public MemoryUsage(long init, long used,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                       long committed, long max) {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    long getInit() {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    long getUsed() {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    long getCommitted() {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    long getMax() {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
          </pre></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        <td><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
public class MemoryUsage {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    // standard JavaBean conventions with getters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    <b>&#64;ConstructorProperties({"init", "used", "committed", "max"})</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public MemoryUsage(long init, long used,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                       long committed, long max) {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    long getInit() {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    long getUsed() {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    long getCommitted() {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    long getMax() {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
          </pre></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
      </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    <p>The definitions are the same in the two cases, except
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
      that with the MXBean, <code>MemoryUsage</code> no longer needs to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
      be marked <code>Serializable</code> (though it can be).  On
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
      the other hand, we have added a {@code @ConstructorProperties} annotation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
      to link the constructor parameters to the corresponding getters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
      We will see more about this below.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    <p><code>MemoryUsage</code> is a <em>model-specific class</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
      With Standard MBeans, a client of the MBean Server cannot access the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
      <code>Usage</code> attribute if it does not know the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
      <code>MemoryUsage</code>.  Suppose the client is a generic console
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
      based on JMX technology.  Then the console would have to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
      configured with the model-specific classes of every application it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
      might connect to.  The problem is even worse for clients that are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
      not written in the Java language.  Then there may not be any way
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
      to tell the client what a <code>MemoryUsage</code> looks like.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    <p>This is where MXBeans differ from Standard MBeans.  Although we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
      define the management interface in almost exactly the same way,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
      the MXBean framework <em>converts</em> model-specific classes into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
      standard classes from the Java platform.  Using arrays and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
      {@link javax.management.openmbean.CompositeData CompositeData} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
      {@link javax.management.openmbean.TabularData TabularData} classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
      from the standard {@link javax.management.openmbean} package, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
      is possible to build data structures of arbitrary complexity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
      using only standard classes.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    <p>This becomes clearer if we compare what the clients of the two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
      models might look like:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    <table border="1" cellpadding="5">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        <th>Standard MBean</th><th>MXBean</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
      </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        <td><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
String name = (String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    mbeanServer.{@link MBeanServer#getAttribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    getAttribute}(objectName, "Name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
<b>MemoryUsage</b> usage = (<b>MemoryUsage</b>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    mbeanServer.getAttribute(objectName, "Usage");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
<b>long used = usage.getUsed();</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
          </pre></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        <td><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
String name = (String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    mbeanServer.{@link MBeanServer#getAttribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    getAttribute}(objectName, "Name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
<b>{@link CompositeData}</b> usage = (<b>CompositeData</b>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    mbeanServer.getAttribute(objectName, "Usage");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
<b>long used = (Long) usage.{@link CompositeData#get get}("used");</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
          </pre></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    <p>For attributes with simple types like <code>String</code>, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
      code is the same.  But for attributes with complex types, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
      Standard MBean code requires the client to know the model-specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
      class <code>MemoryUsage</code>, while the MXBean code requires no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
      non-standard classes.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    <p>The client code shown here is slightly more complicated for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
      MXBean client.  But, if the client does in fact know the model,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
      here the interface <code>MemoryPoolMXBean</code> and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
      class <code>MemoryUsage</code>, then it can construct a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
      <em>proxy</em>.  This is the recommended way to interact with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
      managed objects when you know the model beforehand, regardless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
      of whether you are using Standard MBeans or MXBeans:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    <table border="1" cellpadding="5">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        <th>Standard MBean</th><th>MXBean</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
      </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        <td><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
MemoryPool<b>MBean</b> proxy =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    JMX.<b>{@link JMX#newMBeanProxy(MBeanServerConnection, ObjectName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
              Class) newMBeanProxy}</b>(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        mbeanServer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        objectName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        MemoryPool<b>MBean</b>.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
String name = proxy.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
MemoryUsage usage = proxy.getUsage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
long used = usage.getUsed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
          </pre></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        <td><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
MemoryPool<b>MXBean</b> proxy =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    JMX.<b>{@link JMX#newMXBeanProxy(MBeanServerConnection, ObjectName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
              Class) newMXBeanProxy}</b>(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        mbeanServer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        objectName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        MemoryPool<b>MXBean</b>.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
String name = proxy.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
MemoryUsage usage = proxy.getUsage();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
long used = usage.getUsed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
          </pre></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
      </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    <p>Implementing the MemoryPool object works similarly for both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
      Standard MBeans and MXBeans.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    <table border="1" cellpadding="5">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        <th>Standard MBean</th><th>MXBean</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
      </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        <td><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
public class MemoryPool
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        implements MemoryPool<b>MBean</b> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    public String getName() {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    public MemoryUsage getUsage() {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    // ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
          </pre></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        <td><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
public class MemoryPool
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        implements MemoryPool<b>MXBean</b> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    public String getName() {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    public MemoryUsage getUsage() {...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    // ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
          </pre></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
      </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    <p>Registering the MBean in the MBean Server works in the same way
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
      in both cases:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    <table border="1" cellpadding="5">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        <th>Standard MBean</th><th>MXBean</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
      </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        <td><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    MemoryPool<b>MBean</b> pool = new MemoryPool();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    mbeanServer.{@link MBeanServer#registerMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    registerMBean}(pool, objectName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
          </pre></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        <td><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    MemoryPool<b>MXBean</b> pool = new MemoryPool();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    mbeanServer.{@link MBeanServer#registerMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    registerMBean}(pool, objectName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
          </pre></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
      </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   328
    <h2 id="mxbean-def">Definition of an MXBean</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    <p>An MXBean is a kind of MBean.  An MXBean object can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
      registered directly in the MBean Server, or it can be used as an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
      argument to {@link StandardMBean} and the resultant MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
      registered in the MBean Server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    <p>When an object is registered in the MBean Server using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
      {@code registerMBean} or {@code createMBean} methods of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
      {@link MBeanServer} interface, the object's class is examined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
      to determine what type of MBean it is:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
      <li>If the class implements the interface {@link DynamicMBean}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        then the MBean is a Dynamic MBean.  Note that the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        {@code StandardMBean} implements this interface, so this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        case applies to a Standard MBean or MXBean created using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        the class {@code StandardMBean}.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
      <li>Otherwise, if the class matches the Standard MBean naming
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        conventions, then the MBean is a Standard MBean.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
      <li>Otherwise, it may be an MXBean.  The set of interfaces
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        implemented by the object is examined for interfaces that:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
          <li>have a class name <code><em>S</em>MXBean</code> where
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            <code><em>S</em></code> is any non-empty string, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            do not have an annotation {@code @MXBean(false)}; and/or</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
          <li>have an annotation {@code @MXBean(true)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            or just {@code @MXBean}.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        If there is exactly one such interface, or if there is one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        such interface that is a subinterface of all the others, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        the object is an MXBean.  The interface in question is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        <em>MXBean interface</em>.  In the example above, the MXBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        interface is {@code MemoryPoolMXBean}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
      <li>If none of these conditions is met, the MBean is invalid and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        the attempt to register it will generate {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        NotCompliantMBeanException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    <p>Every Java type that appears as the parameter or return type of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
      method in an MXBean interface must be <em>convertible</em> using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
      the rules below.  Additionally, parameters must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
      <em>reconstructible</em> as defined below.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    <p>An attempt to construct an MXBean that does not conform to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
      above rules will produce an exception.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   381
    <h2 id="naming-conv">Naming conventions</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    <p>The same naming conventions are applied to the methods in an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
      MXBean as in a Standard MBean:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    <ol>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
      <li>A method <code><em>T</em> get<em>N</em>()</code>, where
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        <code><em>T</em></code> is a Java type (not <code>void</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        and <code><em>N</em></code> is a non-empty string, specifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        that there is a readable attribute called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        <code><em>N</em></code>.  The Java type and Open type of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        attribute are determined by the mapping rules below.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        The method {@code final Class getClass()} inherited from {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        Object} is ignored when looking for getters.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
      <li>A method <code>boolean is<em>N</em>()</code> specifies that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        there is a readable attribute called <code><em>N</em></code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        with Java type <code>boolean</code> and Open type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        <code>SimpleType.Boolean</code>.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
      <li>A method <code>void set<em>N</em>(<em>T</em> x)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
        specifies that there is a writeable attribute called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        <code><em>N</em></code>.  The Java type and Open type of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        attribute are determined by the mapping rules below.  (Of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        course, the name <code>x</code> of the parameter is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        irrelevant.)</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
      <li>Every other method specifies that there is an operation with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        the same name as the method.  The Java type and Open type of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        return value and of each parameter are determined by the mapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        rules below.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    </ol>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    <p>The rules for <code>get<em>N</em></code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
      <code>is<em>N</em></code> collectively define the notion of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
      <em>getter</em>.  The rule for <code>set<em>N</em></code> defines
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
      the notion of a <em>setter</em>.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    <p>It is an error for there to be two getters with the same name, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
      two setters with the same name.  If there is a getter and a setter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
      for the same name, then the type <code><em>T</em></code> in both
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
      must be the same.  In this case the attribute is read/write.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
      there is only a getter or only a setter, the attribute is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
      read-only or write-only respectively.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   427
    <h2 id="mapping-rules">Type mapping rules</h2>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    <p>An MXBean is a kind of Open MBean, as defined by the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
      javax.management.openmbean} package.  This means that the types of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
      attributes, operation parameters, and operation return values must
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
      all be describable using <em>Open Types</em>, that is the four
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
      standard subclasses of {@link javax.management.openmbean.OpenType}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
      MXBeans achieve this by mapping Java types into Open Types.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    <p>For every Java type <em>J</em>, the MXBean mapping is described
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
      by the following information:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
      <li>The corresponding Open Type, <em>opentype(J)</em>.  This is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        an instance of a subclass of {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        javax.management.openmbean.OpenType}.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
      <li>The <em>mapped</em> Java type, <em>opendata(J)</em>, which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        always the same for any given <em>opentype(J)</em>.  This is a Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        class.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
      <li>How a value is converted from type <em>J</em> to type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        <em>opendata(J)</em>.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
      <li>How a value is converted from type <em>opendata(J)</em> to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        type <em>J</em>, if it can be.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    <p>For example, for the Java type {@code List<String>}:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
      <li>The Open Type, <em>opentype(</em>{@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        List<String>}<em>)</em>, is {@link ArrayType}<code>(1, </code>{@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
          SimpleType#STRING}<code>)</code>, representing a 1-dimensional
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
          array of <code>String</code>s.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
      <li>The mapped Java type, <em>opendata(</em>{@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        List<String>}<em>)</em>, is {@code String[]}.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
      <li>A {@code List<String>} can be converted to a {@code String[]}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
          using {@link List#toArray(Object[]) List.toArray(new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
          String[0])}.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
      <li>A {@code String[]} can be converted to a {@code List<String>}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
          using {@link Arrays#asList Arrays.asList}.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    <p>If no mapping rules exist to derive <em>opentype(J)</em> from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
      <em>J</em>, then <em>J</em> cannot be the type of a method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
      parameter or return value in an MXBean interface.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    <p>If there is a way to convert <em>opendata(J)</em> back to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
      <em>J</em> then we say that <em>J</em> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
      <em>reconstructible</em>.  All method parameters in an MXBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
      interface must be reconstructible, because when the MXBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
      framework is invoking a method it will need to convert those
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
      parameters from <em>opendata(J)</em> to <em>J</em>.  In a proxy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
      generated by {@link JMX#newMXBeanProxy(MBeanServerConnection,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
      ObjectName, Class) JMX.newMXBeanProxy}, it is the return values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
      of the methods in the MXBean interface that must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
      reconstructible.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    <p>Null values are allowed for all Java types and Open Types,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
      except primitive Java types where they are not possible.  When
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
      converting from type <em>J</em> to type <em>opendata(J)</em> or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
      from type <em>opendata(J)</em> to type <em>J</em>, a null value is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
      mapped to a null value.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   489
    <p>In addition to the default type mapping rules, you can specify
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   490
      custom type mappings, as described <a
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   491
      href="#custom">below</a>.</p>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   492
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   493
    <p>The following table summarizes the default type mapping rules.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    <table border="1" cellpadding="5">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
      <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        <th>Java type <em>J</em></th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        <th><em>opentype(J)</em></th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        <th><em>opendata(J)</em></th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
      </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
      <tbody cellvalign="top">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
          <td>{@code int}, {@code boolean}, etc<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
            (the 8 primitive Java types)</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
          <td>{@code SimpleType.INTEGER},<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            {@code SimpleType.BOOLEAN}, etc</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
          <td>{@code Integer}, {@code Boolean}, etc<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            (the corresponding boxed types)</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
          <td>{@code Integer}, {@code ObjectName}, etc<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            (the types covered by {@link SimpleType})</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
          <td>the corresponding {@code SimpleType}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
          <td><em>J</em>, the same type</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
          <td>{@code int[]} etc<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            (a one-dimensional array with<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            primitive element type)</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
          <td>{@code ArrayType.getPrimitiveArrayType(int[].class)} etc</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
          <td><em>J</em>, the same type</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
          <td><em>E</em>{@code []}<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            (an array with non-primitive element type <em>E</em>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
              this includes {@code int[][]}, where <em>E</em> is {@code int[]})</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
          <td>{@code ArrayType.getArrayType(}<em>opentype(E)</em>{@code )}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
          <td><em>opendata(E)</em>{@code []}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
          <td>{@code List<}<em>E</em>{@code >}<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            {@code Set<}<em>E</em>{@code >}<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            {@code SortedSet<}<em>E</em>{@code >} (see below)</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
          <td>same as for <em>E</em>{@code []}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
          <td>same as for <em>E</em>{@code []}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
          <td>An enumeration <em>E</em><br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            (declared in Java as {@code enum }<em>E</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
            {@code {...}})</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
          <td>{@code SimpleType.STRING}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
          <td>{@code String}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
          <td>{@code Map<}<em>K</em>,<em>V</em>{@code >}<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            {@code SortedMap<}<em>K</em>,<em>V</em>{@code >}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
          <td>{@link TabularType}<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
            (see below)</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
          <td>{@link TabularData}<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            (see below)</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
          <td>An MXBean interface</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
          <td>{@code SimpleType.OBJECTNAME}<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            (see below)</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
          <td>{@link ObjectName}<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            (see below)</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
          <td>Any other type</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
          <td>{@link CompositeType},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
            if possible<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            (see below)</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
          <td>{@link CompositeData}</td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
      </tbody>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    <p>The following sections give further details of these rules.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    <h3>Mappings for primitive types</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    <p>The 8 primitive Java types
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
      ({@code boolean}, {@code byte}, {@code short}, {@code int}, {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
      long}, {@code float}, {@code double}, {@code char}) are mapped to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
      corresponding boxed types from {@code java.lang}, namely {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
      Boolean}, {@code Byte}, etc.  The Open Type is the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
      {@code SimpleType}.  Thus, <em>opentype(</em>{@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
      long}<em>)</em> is {@code SimpleType.LONG}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
      <em>opendata(</em>{@code long}<em>)</em> is {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
      java.lang.Long}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    <p>An array of primitive type such as {@code long[]} can be represented
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
      directly as an Open Type.  Thus, <em>openType(</em>{@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
      long[]}<em>)</em> is {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
      ArrayType.getPrimitiveArrayType(long[].class)}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
      <em>opendata(</em>{@code long[]}<em>)</em> is {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
      long[]}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    <p>In practice, the difference between a plain {@code int} and {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
      Integer}, etc, does not show up because operations in the JMX API
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
      are always on Java objects, not primitives.  However, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
      difference <em>does</em> show up with arrays.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    <h3>Mappings for collections ({@code List<}<em>E</em>{@code >} etc)</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    <p>A {@code List<}<em>E</em>{@code >} or {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
      Set<}<em>E</em>{@code >}, such as {@code List<String>} or {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
        Set<ObjectName>}, is mapped in the same way as an array of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
          same element type, such as {@code String[]} or {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
          ObjectName[]}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    <p>A {@code SortedSet<}<em>E</em>{@code >} is also mapped in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
      same way as an <em>E</em>{@code []}, but it is only convertible if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
      <em>E</em> is a class or interface that implements {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
      java.lang.Comparable}.  Thus, a {@code SortedSet<String>} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        {@code SortedSet<Integer>} is convertible, but a {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
          SortedSet<int[]>} or {@code SortedSet<List<String>>} is not.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
                conversion of a {@code SortedSet} instance will fail with an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
                {@code IllegalArgumentException} if it has a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                non-null {@link java.util.SortedSet#comparator()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                comparator()}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    <p>A {@code List<}<em>E</em>{@code >} is reconstructed as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
      {@code java.util.ArrayList<}<em>E</em>{@code >};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
      a {@code Set<}<em>E</em>{@code >} as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
      {@code java.util.HashSet<}<em>E</em>{@code >};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
      a {@code SortedSet<}<em>E</em>{@code >} as a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
      {@code java.util.TreeSet<}<em>E</em>{@code >}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
    <h3>Mappings for maps ({@code Map<}<em>K</em>,<em>V</em>{@code >} etc)</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    <p>A {@code Map<}<em>K</em>,<em>V</em>{@code >} or {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
      SortedMap<}<em>K</em>,<em>V</em>{@code >}, for example {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
      Map<String,ObjectName>}, has Open Type {@link TabularType} and is mapped
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
        to a {@link TabularData}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
        The {@code TabularType} has two items called {@code key} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        {@code value}.  The Open Type of {@code key} is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        <em>opentype(K)</em>, and the Open Type of {@code value} is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        <em>opentype(V)</em>.  The index of the {@code TabularType} is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        single item {@code key}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    <p>For example, the {@code TabularType} for a {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
      Map<String,ObjectName>} might be constructed with code like
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        this:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
String typeName =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    "java.util.Map&lt;java.lang.String, javax.management.ObjectName&gt;";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
String[] keyValue =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    new String[] {"key", "value"};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
OpenType[] openTypes =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    new OpenType[] {SimpleType.STRING, SimpleType.OBJECTNAME};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
CompositeType rowType =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    new CompositeType(typeName, typeName, keyValue, keyValue, openTypes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
TabularType tabularType =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    new TabularType(typeName, typeName, rowType, new String[] {"key"});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    <p>The {@code typeName} here is determined by the <a href="#type-names">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
      type name rules</a> detailed below.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    <p>A {@code SortedMap<}<em>K</em>,<em>V</em>{@code >} is mapped in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
      same way, but it is only convertible if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
      <em>K</em> is a class or interface that implements {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
      java.lang.Comparable}.  Thus, a {@code SortedMap<String,int[]>}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        is convertible, but a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        {@code SortedMap<int[],String>} is not.  The conversion of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
          {@code SortedMap} instance will fail with an {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
          IllegalArgumentException} if it has a non-null {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
          java.util.SortedMap#comparator() comparator()}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    <p>A {@code Map<}<em>K</em>,<em>V</em>{@code >} is reconstructed as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
      a {@code java.util.HashMap<}<em>K</em>,<em>V</em>{@code >};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
      a {@code SortedMap<}<em>K</em>,<em>V</em>{@code >} as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
      a {@code java.util.TreeMap<}<em>K</em>,<em>V</em>{@code >}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    <p>{@code TabularData} is an interface.  The concrete class that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
      used to represent a {@code Map<}<em>K</em>,<em>V</em>{@code >} as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
      Open Data is {@link TabularDataSupport},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
      or another class implementing {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
      TabularData} that serializes as {@code TabularDataSupport}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   676
    <h3 id="mxbean-map">Mappings for MXBean interfaces</h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    <p>An MXBean interface, or a type referenced within an MXBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
      interface, can reference another MXBean interface, <em>J</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
      Then <em>opentype(J)</em> is {@code SimpleType.OBJECTNAME} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
      <em>opendata(J)</em> is {@code ObjectName}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    <p>For example, suppose you have two MXBean interfaces like this:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
public interface ProductMXBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    public ModuleMXBean[] getModules();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
public interface ModuleMXBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    public ProductMXBean getProduct();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    <p>The object implementing the {@code ModuleMXBean} interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
      returns from its {@code getProduct} method an object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
      implementing the {@code ProductMXBean} interface.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
      {@code ModuleMXBean} object and the returned {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
      ProductMXBean} objects must both be registered as MXBeans in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
      same MBean Server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    <p>The method {@code ModuleMXBean.getProduct()} defines an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
      attribute called {@code Product}.  The Open Type for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
      attribute is {@code SimpleType.OBJECTNAME}, and the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
      {@code ObjectName} value will be the name under which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
      referenced {@code ProductMXBean} is registered in the MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
      Server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
    <p>If you make an MXBean proxy for a {@code ModuleMXBean} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
      call its {@code getProduct()} method, the proxy will map the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
      {@code ObjectName} back into a {@code ProductMXBean} by making
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
      another MXBean proxy.  More formally, when a proxy made with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
      {@link JMX#newMXBeanProxy(MBeanServerConnection, ObjectName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
       Class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
      JMX.newMXBeanProxy(mbeanServerConnection, objectNameX,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
      interfaceX)} needs to map {@code objectNameY} back into {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
      interfaceY}, another MXBean interface, it does so with {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
      JMX.newMXBeanProxy(mbeanServerConnection, objectNameY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
      interfaceY)}.  The implementation may return a proxy that was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
      previously created by a call to {@code JMX.newMXBeanProxy}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
      with the same parameters, or it may create a new proxy.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    <p>The reverse mapping is illustrated by the following change to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
      {@code ModuleMXBean} interface:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
public interface ModuleMXBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    public ProductMXBean getProduct();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    public void setProduct(ProductMXBean c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
    </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    <p>The presence of the {@code setProduct} method now means that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
      {@code Product} attribute is read/write.  As before, the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
      of this attribute is an {@code ObjectName}.  When the attribute is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
      set, the {@code ObjectName} must be converted into the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
      {@code ProductMXBean} object that the {@code setProduct} method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
      expects.  This object will be an MXBean proxy for the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
      {@code ObjectName} in the same MBean Server.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    <p>If you make an MXBean proxy for a {@code ModuleMXBean} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
      call its {@code setProduct} method, the proxy will map its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
      {@code ProductMXBean} argument back into an {@code ObjectName}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
      This will only work if the argument is in fact another proxy,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
      for a {@code ProductMXBean} in the same {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
      MBeanServerConnection}.  The proxy can have been returned from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
      another proxy (like {@code ModuleMXBean.getProduct()} which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
      returns a proxy for a {@code ProductMXBean}); or it can have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
      been created by {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
      JMX#newMXBeanProxy(MBeanServerConnection, ObjectName, Class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
      JMX.newMXBeanProxy}; or it can have been created using {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
      java.lang.reflect.Proxy Proxy} with an invocation handler that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
      is {@link MBeanServerInvocationHandler} or a subclass.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    <p>If the same MXBean were registered under two different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
      {@code ObjectName}s, a reference to that MXBean from another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
      MXBean would be ambiguous.  Therefore, if an MXBean object is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
      already registered in an MBean Server and an attempt is made to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
      register it in the same MBean Server under another name, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
      result is an {@link InstanceAlreadyExistsException}.  Registering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
      the same MBean object under more than one name is discouraged in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
      general, notably because it does not work well for MBeans that are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
      {@link NotificationBroadcaster}s.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
   765
    <h3 id="composite-map">Mappings for other types</h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    <p>Given a Java class or interface <em>J</em> that does not match the other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
      rules in the table above, the MXBean framework will attempt to map
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
      it to a {@link CompositeType} as follows.  The type name of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
      {@code CompositeType} is determined by the <a href="#type-names">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
      type name rules</a> below.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    <p>The class is examined for getters using the conventions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
      <a href="#naming-conv">above</a>.  (Getters must be public
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
      instance methods.)  If there are no getters, or if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
      any getter has a type that is not convertible, then <em>J</em> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
      not convertible.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    <p>If there is at least one getter and every getter has a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
      convertible type, then <em>opentype(J)</em> is a {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
      CompositeType} with one item for every getter.  If the getter is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
      <code><em>T</em> get<em>Name</em>()</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
    </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    then the item in the {@code CompositeType} is called {@code name}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    and has type <em>opentype(T)</em>.  For example, if the item is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
      <code>String getOwner()</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    then the item is called {@code owner} and has Open Type {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    SimpleType.STRING}.  If the getter is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
      <code>boolean is<em>Name</em>()</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
    </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    then the item in the {@code CompositeType} is called {@code name}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
    and has type {@code SimpleType.BOOLEAN}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    <p>Notice that the first character (or code point) is converted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
      lower case.  This follows the Java Beans convention, which for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
      historical reasons is different from the Standard MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
      convention.  In a Standard MBean or MXBean interface, a method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
      {@code getOwner} defines an attribute called {@code Owner}, while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
      in a Java Bean or mapped {@code CompositeType}, a method {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
      getOwner} defines a property or item called {@code owner}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    <p>If two methods produce the same item name (for example, {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
      getOwner} and {@code isOwner}, or {@code getOwner} and {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
      getowner}) then the type is not convertible.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    <p>When the Open Type is {@code CompositeType}, the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
      mapped Java type (<em>opendata(J)</em>) is {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
      CompositeData}.  The mapping from an instance of <em>J</em> to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
      {@code CompositeData} corresponding to the {@code CompositeType}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
      just described is done as follows.  First, if <em>J</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
      implements the interface {@link CompositeDataView}, then that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
      interface's {@link CompositeDataView#toCompositeData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
      toCompositeData} method is called to do the conversion.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
      Otherwise, the {@code CompositeData} is constructed by calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
      the getter for each item and converting it to the corresponding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
      Open Data type.  Thus, a getter such as</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
      {@code List<String> getNames()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
    <p>will have been mapped to an item with name "{@code names}" and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
      Open Type {@code ArrayType(1, SimpleType.STRING)}.  The conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
      to {@code CompositeData} will call {@code getNames()} and convert
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
      the resultant {@code List<String>} into a {@code String[]} for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        item "{@code names}".</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    <p>{@code CompositeData} is an interface.  The concrete class that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
      used to represent a type as Open Data is {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
      CompositeDataSupport}, or another class implementing {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
      CompositeData} that serializes as {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
      CompositeDataSupport}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
    <h4>Reconstructing an instance of Java type <em>J</em> from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
      a {@code CompositeData}</h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    <p>If <em>opendata(J)</em> is {@code CompositeData} for a Java type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
      <em>J</em>, then either an instance of <em>J</em> can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
      reconstructed from a {@code CompositeData}, or <em>J</em> is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
      reconstructible.  If any item in the {@code CompositeData} is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
      reconstructible, then <em>J</em> is not reconstructible either.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    <p>For any given <em>J</em>, the following rules are consulted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
      determine how to reconstruct instances of <em>J</em> from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
      {@code CompositeData}.  The first applicable rule in the list is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
      the one that will be used.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    <ol>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
      <li><p>If <em>J</em> has a method<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        {@code public static }<em>J </em>{@code from(CompositeData cd)}<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        then that method is called to reconstruct an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        <em>J</em>.</p></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
      <li><p>Otherwise, if <em>J</em> has at least one public
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 834
diff changeset
   867
        constructor with a {@link java.beans.ConstructorProperties
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 834
diff changeset
   868
        ConstructorProperties} annotation, then one
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        of those constructors (not necessarily always the same one)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        will be called to reconstruct an instance of <em>J</em>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        Every such annotation must list as many strings as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        constructor has parameters; each string must name a property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        corresponding to a getter of <em>J</em>; and the type of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        getter must be the same as the corresponding constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        parameter.  It is not an error for there to be getters that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        are not mentioned in the {@code ConstructorProperties} annotation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
        (these may correspond to information that is not needed to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        reconstruct the object).</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        <p>An instance of <em>J</em> is reconstructed by calling a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        constructor with the appropriate reconstructed items from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        {@code CompositeData}.  The constructor to be called will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        determined at runtime based on the items actually present in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        the {@code CompositeData}, given that this {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        CompositeData} might come from an earlier version of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        <em>J</em> where not all the items were present.  A
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
        constructor is <em>applicable</em> if all the properties named
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
        in its {@code ConstructorProperties} annotation are present as items
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
        in the {@code CompositeData}.  If no constructor is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
        applicable, then the attempt to reconstruct <em>J</em> fails.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        <p>For any possible combination of properties, it must be the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        case that either (a) there are no applicable constructors, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        (b) there is exactly one applicable constructor, or (c) one of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
        the applicable constructors names a proper superset of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        properties named by each other applicable constructor.  (In
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        other words, there should never be ambiguity over which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
        constructor to choose.)  If this condition is not true, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
        <em>J</em> is not reconstructible.</p></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
      <li><p>Otherwise, if <em>J</em> has a public no-arg constructor, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        for every getter in <em>J</em> with type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
        <em>T</em> and name <em>N</em> there is a corresponding setter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        with the same name and type, then an instance of <em>J</em> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
        constructed with the no-arg constructor and the setters are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
        called with the reconstructed items from the {@code CompositeData}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        to restore the values.  For example, if there is a method<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        {@code public List<String> getNames()}<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
          then there must also be a method<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
          {@code public void setNames(List<String> names)}<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
            for this rule to apply.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
        <p>If the {@code CompositeData} came from an earlier version of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
        <em>J</em>, some items might not be present.  In this case,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
        the corresponding setters will not be called.</p></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
      <li><p>Otherwise, if <em>J</em> is an interface that has no methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
        other than getters, an instance of <em>J</em> is constructed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        using a {@link java.lang.reflect.Proxy} with a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
        CompositeDataInvocationHandler} backed by the {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        CompositeData} being converted.</p></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
      <li><p>Otherwise, <em>J</em> is not reconstructible.</p></li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    </ol>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
    <p>Here are examples showing different ways to code a type {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
      NamedNumber} that consists of an {@code int} and a {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
      String}.  In each case, the {@code CompositeType} looks like this:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
    <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
      <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
{@link CompositeType}(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    "NamedNumber",                      // typeName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
    "NamedNumber",                      // description
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
    new String[] {"number", "name"},    // itemNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    new String[] {"number", "name"},    // itemDescriptions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
    new OpenType[] {SimpleType.INTEGER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                    SimpleType.STRING}  // itemTypes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
      </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
    </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
    <ol>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
      <li>Static {@code from} method:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
        <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
          <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
public class NamedNumber {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
    public int getNumber() {return number;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
    public String getName() {return name;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
    private NamedNumber(int number, String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        this.number = number;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
    <b>public static NamedNumber from(CompositeData cd)</b> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        return new NamedNumber((Integer) cd.get("number"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
                               (String) cd.get("name"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
    private final int number;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
    private final String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
          </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
      </li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
      <li>Public constructor with <code>&#64;ConstructorProperties</code> annotation:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
          <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
public class NamedNumber {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
    public int getNumber() {return number;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
    public String getName() {return name;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
    <b>&#64;ConstructorProperties({"number", "name"})
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
    public NamedNumber(int number, String name)</b> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
        this.number = number;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
        this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
    private final int number;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
    private final String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
          </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
        </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
      </li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
      <li>Setter for every getter:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
        <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
          <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
public class NamedNumber {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
    public int getNumber() {return number;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
    public void <b>setNumber</b>(int number) {this.number = number;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    public String getName() {return name;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
    public void <b>setName</b>(String name) {this.name = name;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
    <b>public NamedNumber()</b> {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    private int number;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
    private String name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
          </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
        </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
      </li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
      <li>Interface with only getters:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
          <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
public interface NamedNumber {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
    public int getNumber();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
    public String getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
          </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
        </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
      </li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
    </ol>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
    <p>It is usually better for classes that simply represent a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
      collection of data to be <em>immutable</em>.  An instance of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
      immutable class cannot be changed after it has been constructed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
      Notice that {@code CompositeData} itself is immutable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
      Immutability has many advantages, notably with regard to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
      thread-safety and security.  So the approach using setters should
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
      generally be avoided if possible.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
    <h3>Recursive types</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
    <p>Recursive (self-referential) types cannot be used in MXBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
      interfaces.  This is a consequence of the immutability of {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
      CompositeType}.  For example, the following type could not be the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
      type of an attribute, because it refers to itself:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
    <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
public interface <b>Node</b> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
    public String getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
    public int getPriority();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
    public <b>Node</b> getNext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
</pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
    <p>It is always possible to rewrite recursive types like this so
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
      they are no longer recursive.  Doing so may require introducing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
      new types.  For example:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
    <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
public interface <b>NodeList</b> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
    public List&lt;Node&gt; getNodes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
public interface Node {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
    public String getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
    public int getPriority();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
</pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1054
    <p>Alternatively, you can define a custom mapping for your recursive
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1055
      type; see the next section.</p>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1056
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1057
    <h3 id="custom">Custom MXBean type mappings</h3>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1058
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1059
    <p>You can augment or replace the default type mappings described
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1060
      above with custom mappings.  An example appears in the
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1061
      documentation for {@link MXBeanMapping}.</p>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1062
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1063
    <p>If an MXBean uses custom mappings, then an MXBean proxy for
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1064
      that MXBean must use the same mappings for correct behavior.
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1065
      This requires more careful synchronization between client and
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1066
      server than is necessary with the default mappings.  For example
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1067
      it typically requires the client to have the same implementation
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1068
      of any {@link MXBeanMapping} subclasses as the server.  For this
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1069
      reason, custom mappings should be avoided if possible.</p>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1070
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1071
    <p>Every MXBean has an associated {@link MXBeanMappingFactory}.
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1072
      Call this <code><em>f</em></code>.  Then every type that appears
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1073
      in that MXBean has an associated {@link MXBeanMapping}
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1074
      determined by <code><em>f</em></code>.  If the type is
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1075
      <code><em>J</em></code>, say, then the mapping is {@link
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1076
      MXBeanMappingFactory#mappingForType
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1077
      <em>f</em>.mappingForType}<code>(<em>J</em>,
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1078
      <em>f</em>)</code>.</p>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1079
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1080
    <p>The {@code MXBeanMappingFactory} <code><em>f</em></code> for an
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1081
      MXBean is determined as follows.</p>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1082
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1083
    <ul>
1011
2cc4873fa29f 6734273: Minor updates to documentation of Custom MXBean Mappings
emcmanus
parents: 1004
diff changeset
  1084
      <li><p>If a {@link JMX.MBeanOptions} argument is supplied to
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1085
          the {@link StandardMBean} constructor that makes an MXBean,
1011
2cc4873fa29f 6734273: Minor updates to documentation of Custom MXBean Mappings
emcmanus
parents: 1004
diff changeset
  1086
          or to the {@link JMX#newMBeanProxy(MBeanServerConnection,
2cc4873fa29f 6734273: Minor updates to documentation of Custom MXBean Mappings
emcmanus
parents: 1004
diff changeset
  1087
          ObjectName, Class, JMX.MBeanOptions) JMX.newMBeanProxy}
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1088
          method, and the {@code MBeanOptions} object defines a non-null
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1089
          {@code MXBeanMappingFactory}, then that is the value of
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1090
          <code><em>f</em></code>.</p></li>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1091
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1092
      <li><p>Otherwise, if the MXBean interface has an {@link
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1093
          MXBeanMappingFactoryClass} annotation, then that annotation
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1094
          must identify a subclass of {@code MXBeanMappingFactory}
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1095
          with a no-argument constructor.  Then
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1096
          <code><em>f</em></code> is the result of calling this
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1097
          constructor.  If the class does not have a no-argument
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1098
          constructor, or if calling the constructor produces an
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1099
          exception, then the MXBean is invalid and an attempt to
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1100
          register it in the MBean Server will produce a {@link
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1101
          NotCompliantMBeanException}.</p>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1102
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1103
        <p>This annotation is not inherited from any parent
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1104
          interfaces.  If an MXBean interface has this annotation,
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1105
          then usually any MXBean subinterfaces must repeat the same
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1106
          annotation for correct behavior.</p></li>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1107
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1108
      <li><p>Otherwise, if the package in which the MXBean interface
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1109
          appears has an {@code MXBeanMappingFactoryClass} annotation,
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1110
          then <code><em>f</em></code> is determined as if that
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1111
          annotation appeared on the MXBean interface.</p></li>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1112
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1113
      <li><p>Otherwise, <code><em>f</em></code> is the default mapping
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1114
          factory, {@link MXBeanMappingFactory#DEFAULT}.</p></li>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1115
    </ul>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1116
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1117
    <p>The default mapping factory recognizes the {@link
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1118
      MXBeanMappingClass} annotation on a class or interface.  If
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1119
      <code><em>J</em></code> is a class or interface that has such an
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1120
      annotation, then the {@code MXBeanMapping} for
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1121
      <code><em>J</em></code> produced by the default mapping factory
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1122
      will be determined by the value of the annotation as described
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1123
      in its {@linkplain MXBeanMappingClass documentation}.</p>
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1124
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
    <h3>MBeanInfo contents for an MXBean</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
    <p>An MXBean is a type of Open MBean.  However, for compatibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
      reasons, its {@link MBeanInfo} is not an {@link OpenMBeanInfo}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
      In particular, when the type of an attribute, parameter, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
      operation return value is a primitive type such as {@code int},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
      or is {@code void} (for a return type), then the attribute,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
      parameter, or operation will be represented respectively by an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
      {@link MBeanAttributeInfo}, {@link MBeanParameterInfo}, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
      {@link MBeanOperationInfo} whose {@code getType()} or {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
      getReturnType()} returns the primitive name ("{@code int}" etc).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
      This is so even though the mapping rules above specify that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
      <em>opendata</em> mapping is the wrapped type ({@code Integer}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
      etc).</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
    <p>The array of public constructors returned by {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
      MBeanInfo#getConstructors()} for an MXBean that is directly
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
      registered in the MBean Server will contain all of the public
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
      constructors of that MXBean.  If the class of the MXBean is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
      public then its constructors are not considered public either.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
      The list returned for an MXBean that is constructed using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
      {@link StandardMBean} class is derived in the same way as for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
      Standard MBeans.  Regardless of how the MXBean was constructed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
      its constructor parameters are not subject to MXBean mapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
      rules and do not have a corresponding {@code OpenType}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
    <p>The array of notification types returned by {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
      MBeanInfo#getNotifications()} for an MXBean that is directly
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
      registered in the MBean Server will be empty if the MXBean does
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
      not implement the {@link NotificationBroadcaster} interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
      Otherwise, it will be the result of calling {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
      NotificationBroadcaster#getNotificationInfo()} at the time the MXBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
      was registered.  Even if the result of this method changes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
      subsequently, the result of {@code MBeanInfo.getNotifications()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
      will not.  The list returned for an MXBean that is constructed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
      using the {@link StandardMBean} or {@link StandardEmitterMBean}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
      class is derived in the same way as for Standard MBeans.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
    <p>The {@link Descriptor} for all of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
      {@code MBeanAttributeInfo}, {@code MBeanParameterInfo}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
      {@code MBeanOperationInfo} objects contained in the {@code MBeanInfo}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
      will have a field {@code openType} whose value is the {@link OpenType}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
      specified by the mapping rules above.  So even when {@code getType()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
      is "{@code int}", {@code getDescriptor().getField("openType")} will
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
      be {@link SimpleType#INTEGER}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
    <p>The {@code Descriptor} for each of these objects will also have a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
      field {@code originalType} that is a string representing the Java type
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
      that appeared in the MXBean interface.  The format of this string
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
      is described in the section <a href="#type-names">Type Names</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
      below.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
    <p>The {@code Descriptor} for the {@code MBeanInfo} will have a field
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
      {@code mxbean} whose value is the string "{@code true}".</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1181
    <h3 id="type-names">Type Names</h3>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
    <p>Sometimes the unmapped type <em>T</em> of a method parameter or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
    return value in an MXBean must be represented as a string.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
    <em>T</em> is a non-generic type, this string is the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
    returned by {@link Class#getName()}.  Otherwise it is the value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
    <em>genericstring(T)</em>, defined as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
    <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
      <li>If <em>T</em> is a non-generic non-array type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
      <em>genericstring(T)</em> is the value returned by {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
      Class#getName()}, for example {@code "int"} or {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
      "java.lang.String"}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
      <li>If <em>T</em> is an array <em>E[]</em>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
      <em>genericstring(T)</em> is <em>genericstring(E)</em> followed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
      by {@code "[]"}.  For example, <em>genericstring({@code int[]})</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
      is {@code "int[]"}, and <em>genericstring({@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
      List<String>[][]})</em> is {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
      "java.util.List<java.lang.String>[][]"}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
    <li>Otherwise, <em>T</em> is a parameterized type such as {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
    List<String>} and <em>genericstring(T)</em> consists of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
    following: the fully-qualified name of the parameterized type as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
    returned by {@code Class.getName()}; a left angle bracket ({@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
    "<"}); <em>genericstring(A)</em> where <em>A</em> is the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
    type parameter; if there is a second type parameter <em>B</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
    then {@code ", "} (a comma and a single space) followed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
    <em>genericstring(B)</em>; a right angle bracket ({@code ">"}).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
    </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
    <p>Note that if a method returns {@code int[]}, this will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
      represented by the string {@code "[I"} returned by {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
      Class.getName()}, but if a method returns {@code List<int[]>},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
      this will be represented by the string {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
      "java.util.List<int[]>"}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
    <h3>Exceptions</h3>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
    <p>A problem with mapping <em>from</em> Java types <em>to</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
      Open types is signaled with an {@link OpenDataException}.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
      can happen when an MXBean interface is being analyzed, for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
      example if it references a type like {@link java.util.Random
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
      java.util.Random} that has no getters.  Or it can happen when an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
      instance is being converted (a return value from a method in an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
      MXBean or a parameter to a method in an MXBean proxy), for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
      example when converting from {@code SortedSet<String>} to {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
      String[]} if the {@code SortedSet} has a non-null {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
      Comparator}.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
    <p>A problem with mapping <em>to</em> Java types <em>from</em>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
      Open types is signaled with an {@link InvalidObjectException}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
      This can happen when an MXBean interface is being analyzed, for
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
      example if it references a type that is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
      <em>reconstructible</em> according to the rules above, in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
      context where a reconstructible type is required.  Or it can
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
      happen when an instance is being converted (a parameter to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
      method in an MXBean or a return value from a method in an MXBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
      proxy), for example from a String to an Enum if there is no Enum
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
      constant with that name.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
    <p>Depending on the context, the {@code OpenDataException} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
      {@code InvalidObjectException} may be wrapped in another
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
      exception such as {@link RuntimeMBeanException} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
      UndeclaredThrowableException}.  For every thrown exception,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
      the condition <em>C</em> will be true: "<em>e</em> is {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
      OpenDataException} or {@code InvalidObjectException} (as
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
      appropriate), or <em>C</em> is true of <em>e</em>.{@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
      Throwable#getCause() getCause()}".</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
687
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1253
   @see MXBeanMapping
874e25a9844a 6562936: Support custom type mappings in MXBeans
emcmanus
parents: 2
diff changeset
  1254
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
   @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1258
/*
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1259
 * This annotation is @Inherited because if an MXBean is defined as a
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1260
 * class using annotations, then its subclasses are also MXBeans.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1261
 * For example:
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1262
 * @MXBean
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1263
 * public class Super {
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1264
 *     @ManagedAttribute
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1265
 *     public String getName() {...}
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1266
 * }
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1267
 * public class Sub extends Super {}
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1268
 * Here Sub is an MXBean.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1269
 *
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1270
 * The @Inherited annotation has no effect when applied to an interface.
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1271
 */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
@Documented
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
@Retention(RetentionPolicy.RUNTIME)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
@Target(ElementType.TYPE)
833
bfa2bef7517c 6323980: Annotations to simplify MBean development
emcmanus
parents: 687
diff changeset
  1275
@Inherited
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
public @interface MXBean {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
       True if the annotated interface is an MXBean interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
       @return true if the annotated interface is an MXBean interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
    boolean value() default true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
}