jdk/src/share/classes/javax/management/MBeanInfo.java
author xdono
Mon, 15 Dec 2008 16:55:25 -0800
changeset 1639 a97859015238
parent 1570 4165709c91e3
child 4156 acaa49a2768a
permissions -rw-r--r--
6785258: Update copyright year Summary: Update copyright for files that have been modified starting July 2008 to Dec 2008 Reviewed-by: katleman, ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1639
a97859015238 6785258: Update copyright year
xdono
parents: 1570
diff changeset
     2
 * Copyright 1999-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
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
    28
import com.sun.jmx.mbeanserver.Util;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.StreamCorruptedException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.lang.reflect.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.Arrays;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.WeakHashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
    41
import java.util.HashMap;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
    42
import java.util.Locale;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
    43
import java.util.MissingResourceException;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
    44
import java.util.ResourceBundle;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
    45
import java.util.logging.Level;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
    46
import java.util.logging.Logger;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import static javax.management.ImmutableDescriptor.nonNullDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <p>Describes the management interface exposed by an MBean; that is,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * the set of attributes and operations which are available for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * management operations.  Instances of this class are immutable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * Subclasses may be mutable but this is not recommended.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    55
 * <p id="info-changed">Usually the {@code MBeanInfo} for any given MBean does
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    56
 * not change over the lifetime of that MBean.  Dynamic MBeans can change their
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    57
 * {@code MBeanInfo} and in that case it is recommended that they emit a {@link
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    58
 * Notification} with a {@linkplain Notification#getType() type} of {@code
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    59
 * "jmx.mbean.info.changed"} and a {@linkplain Notification#getUserData()
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    60
 * userData} that is the new {@code MBeanInfo}.  This is not required, but
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    61
 * provides a conventional way for clients of the MBean to discover the change.
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    62
 * See also the <a href="Descriptor.html#immutableInfo">immutableInfo</a> and
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    63
 * <a href="Descriptor.html#infoTimeout">infoTimeout</a> fields in the {@code
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    64
 * MBeanInfo} {@link Descriptor}.</p>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    65
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * <p>The contents of the <code>MBeanInfo</code> for a Dynamic MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * are determined by its {@link DynamicMBean#getMBeanInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * getMBeanInfo()} method.  This includes Open MBeans and Model
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * MBeans, which are kinds of Dynamic MBeans.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * <p>The contents of the <code>MBeanInfo</code> for a Standard MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * are determined by the MBean server as follows:</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * <li>{@link #getClassName()} returns the Java class name of the MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * <li>{@link #getConstructors()} returns the list of all public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * constructors in that object;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <li>{@link #getAttributes()} returns the list of all attributes
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    83
 * whose existence is deduced as follows:
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    84
 * <ul>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    85
 * <li>if the Standard MBean is defined with an MBean interface,
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    86
 * from <code>get<i>Name</i></code>, <code>is<i>Name</i></code>, or
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    87
 * <code>set<i>Name</i></code> methods that conform to the conventions
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * for Standard MBeans;
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    89
 * <li>if the Standard MBean is defined with the {@link MBean &#64;MBean} or
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    90
 * {@link MXBean &#64;MXBean} annotation on a class, from methods with the
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    91
 * {@link ManagedAttribute &#64;ManagedAttribute} annotation;
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    92
 * </ul>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 *
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    94
 * <li>{@link #getOperations()} returns the list of all operations whose
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    95
 * existence is deduced as follows:
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    96
 * <ul>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    97
 * <li>if the Standard MBean is defined with an MBean interface, from methods in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * the MBean interface that do not represent attributes;
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    99
 * <li>if the Standard MBean is defined with the {@link MBean &#64;MBean} or
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   100
 * {@link MXBean &#64;MXBean} annotation on a class, from methods with the
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   101
 * {@link ManagedOperation &#64;ManagedOperation} annotation;
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   102
 * </ul>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 *
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   104
 * <li>{@link #getNotifications()} returns:
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   105
 * <ul>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   106
 * <li>if the MBean implements the {@link NotificationBroadcaster} interface,
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   107
 * the result of calling {@link
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * NotificationBroadcaster#getNotificationInfo()} on it;
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   109
 * <li>otherwise, if there is a {@link NotificationInfo &#64;NotificationInfo}
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   110
 * or {@link NotificationInfos &#64;NotificationInfos} annotation on the
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   111
 * MBean interface or <code>&#64;MBean</code> or <code>&#64;MXBean</code>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   112
 * class, the array implied by those annotations;
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   113
 * <li>otherwise an empty array;
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   114
 * </ul>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * <li>{@link #getDescriptor()} returns a descriptor containing the contents
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   117
 * of any descriptor annotations in the MBean interface (see
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   118
 * {@link DescriptorFields &#64;DescriptorFields} and
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   119
 * {@link DescriptorKey &#64;DescriptorKey}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * <p>The description returned by {@link #getDescription()} and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * descriptions of the contained attributes and operations are determined
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
   125
 * by the corresponding {@link Description} annotations if any;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * otherwise their contents are not specified.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * <p>The remaining details of the <code>MBeanInfo</code> for a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * Standard MBean are not specified.  This includes the description of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 * any contained constructors, and notifications; the names
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * of parameters to constructors and operations; and the descriptions of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 * constructor parameters.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
public class MBeanInfo implements Cloneable, Serializable, DescriptorRead {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    /* Serial version */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    static final long serialVersionUID = -6451021435135161911L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @serial The Descriptor for the MBean.  This field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * can be null, which is equivalent to an empty Descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    private transient Descriptor descriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @serial The human readable description of the class.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    private final String description;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @serial The MBean qualified name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    private final String className;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @serial The MBean attribute descriptors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    private final MBeanAttributeInfo[] attributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @serial The MBean operation descriptors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    private final MBeanOperationInfo[] operations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @serial The MBean constructor descriptors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    private final MBeanConstructorInfo[] constructors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @serial The MBean notification descriptors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    private final MBeanNotificationInfo[] notifications;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    private transient int hashCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * <p>True if this class is known not to override the array-valued
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * getters of MBeanInfo.  Obviously true for MBeanInfo itself, and true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * for a subclass where we succeed in reflecting on the methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * and discover they are not overridden.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * <p>The purpose of this variable is to avoid cloning the arrays
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * when doing operations like {@link #equals} where we know they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * will not be changed.  If a subclass overrides a getter, we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * cannot access the corresponding array directly.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    private final transient boolean arrayGettersSafe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * Constructs an <CODE>MBeanInfo</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @param className The name of the Java class of the MBean described
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * by this <CODE>MBeanInfo</CODE>.  This value may be any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * syntactically legal Java class name.  It does not have to be a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * Java class known to the MBean server or to the MBean's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * ClassLoader.  If it is a Java class known to the MBean's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * ClassLoader, it is recommended but not required that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * class's public methods include those that would appear in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * Standard MBean implementing the attributes and operations in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * this MBeanInfo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @param description A human readable description of the MBean (optional).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @param attributes The list of exposed attributes of the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * This may be null with the same effect as a zero-length array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @param constructors The list of public constructors of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * MBean.  This may be null with the same effect as a zero-length
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @param operations The list of operations of the MBean.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * may be null with the same effect as a zero-length array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @param notifications The list of notifications emitted.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * may be null with the same effect as a zero-length array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    public MBeanInfo(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                     String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                     MBeanAttributeInfo[] attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                     MBeanConstructorInfo[] constructors,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                     MBeanOperationInfo[] operations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                     MBeanNotificationInfo[] notifications)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
            throws IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        this(className, description, attributes, constructors, operations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
             notifications, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * Constructs an <CODE>MBeanInfo</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @param className The name of the Java class of the MBean described
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * by this <CODE>MBeanInfo</CODE>.  This value may be any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * syntactically legal Java class name.  It does not have to be a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * Java class known to the MBean server or to the MBean's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * ClassLoader.  If it is a Java class known to the MBean's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * ClassLoader, it is recommended but not required that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * class's public methods include those that would appear in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * Standard MBean implementing the attributes and operations in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * this MBeanInfo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * @param description A human readable description of the MBean (optional).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * @param attributes The list of exposed attributes of the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * This may be null with the same effect as a zero-length array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @param constructors The list of public constructors of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * MBean.  This may be null with the same effect as a zero-length
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @param operations The list of operations of the MBean.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * may be null with the same effect as a zero-length array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * @param notifications The list of notifications emitted.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * may be null with the same effect as a zero-length array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @param descriptor The descriptor for the MBean.  This may be null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * which is equivalent to an empty descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public MBeanInfo(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                     String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                     MBeanAttributeInfo[] attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                     MBeanConstructorInfo[] constructors,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                     MBeanOperationInfo[] operations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                     MBeanNotificationInfo[] notifications,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                     Descriptor descriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            throws IllegalArgumentException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        this.className = className;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        this.description = description;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        if (attributes == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
            attributes = MBeanAttributeInfo.NO_ATTRIBUTES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        this.attributes = attributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        if (operations == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            operations = MBeanOperationInfo.NO_OPERATIONS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        this.operations = operations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        if (constructors == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            constructors = MBeanConstructorInfo.NO_CONSTRUCTORS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        this.constructors = constructors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        if (notifications == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            notifications = MBeanNotificationInfo.NO_NOTIFICATIONS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        this.notifications = notifications;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        if (descriptor == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        this.descriptor = descriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        this.arrayGettersSafe =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                arrayGettersSafe(this.getClass(), MBeanInfo.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * <p>Returns a shallow clone of this instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * The clone is obtained by simply calling <tt>super.clone()</tt>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * thus calling the default native shallow cloning mechanism
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * implemented by <tt>Object.clone()</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * No deeper cloning of any internal field is made.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * <p>Since this class is immutable, the clone method is chiefly of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * interest to subclasses.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     */
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   300
     @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     public Object clone () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
         try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
             return super.clone() ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
         } catch (CloneNotSupportedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
             // should not happen as this class is cloneable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
             return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * Returns the name of the Java class of the MBean described by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * this <CODE>MBeanInfo</CODE>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * @return the class name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    public String getClassName()  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        return className;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * Returns a human readable description of the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * @return the description.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    public String getDescription()  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        return description;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * Returns the list of attributes exposed for management.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * Each attribute is described by an <CODE>MBeanAttributeInfo</CODE> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * The returned array is a shallow copy of the internal array,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * which means that it is a copy of the internal array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * references to the <CODE>MBeanAttributeInfo</CODE> objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * but that each referenced <CODE>MBeanAttributeInfo</CODE> object is not copied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * @return  An array of <CODE>MBeanAttributeInfo</CODE> objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    public MBeanAttributeInfo[] getAttributes()   {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        MBeanAttributeInfo[] as = nonNullAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        if (as.length == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            return as;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            return as.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    private MBeanAttributeInfo[] fastGetAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        if (arrayGettersSafe)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            return nonNullAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            return getAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * Return the value of the attributes field, or an empty array if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * the field is null.  This can't happen with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * normally-constructed instance of this class, but can if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * instance was deserialized from another implementation that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * allows the field to be null.  It would be simpler if we enforced
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * the class invariant that these fields cannot be null by writing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * a readObject() method, but that would require us to define the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * various array fields as non-final, which is annoying because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * conceptually they are indeed final.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    private MBeanAttributeInfo[] nonNullAttributes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        return (attributes == null) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            MBeanAttributeInfo.NO_ATTRIBUTES : attributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * Returns the list of operations  of the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * Each operation is described by an <CODE>MBeanOperationInfo</CODE> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * The returned array is a shallow copy of the internal array,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * which means that it is a copy of the internal array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * references to the <CODE>MBeanOperationInfo</CODE> objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * but that each referenced <CODE>MBeanOperationInfo</CODE> object is not copied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * @return  An array of <CODE>MBeanOperationInfo</CODE> objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    public MBeanOperationInfo[] getOperations()  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        MBeanOperationInfo[] os = nonNullOperations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        if (os.length == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            return os;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            return os.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    private MBeanOperationInfo[] fastGetOperations() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        if (arrayGettersSafe)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
            return nonNullOperations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            return getOperations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    private MBeanOperationInfo[] nonNullOperations() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        return (operations == null) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            MBeanOperationInfo.NO_OPERATIONS : operations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * <p>Returns the list of the public constructors of the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * Each constructor is described by an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * <CODE>MBeanConstructorInfo</CODE> object.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * <p>The returned array is a shallow copy of the internal array,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * which means that it is a copy of the internal array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * references to the <CODE>MBeanConstructorInfo</CODE> objects but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * that each referenced <CODE>MBeanConstructorInfo</CODE> object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * is not copied.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * <p>The returned list is not necessarily exhaustive.  That is,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * the MBean may have a public constructor that is not in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * list.  In this case, the MBean server can construct another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * instance of this MBean's class using that constructor, even
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * though it is not listed here.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * @return  An array of <CODE>MBeanConstructorInfo</CODE> objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    public MBeanConstructorInfo[] getConstructors()  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        MBeanConstructorInfo[] cs = nonNullConstructors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        if (cs.length == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            return cs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            return cs.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    private MBeanConstructorInfo[] fastGetConstructors() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        if (arrayGettersSafe)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            return nonNullConstructors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            return getConstructors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    private MBeanConstructorInfo[] nonNullConstructors() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        return (constructors == null) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            MBeanConstructorInfo.NO_CONSTRUCTORS : constructors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * Returns the list of the notifications emitted by the MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * Each notification is described by an <CODE>MBeanNotificationInfo</CODE> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * The returned array is a shallow copy of the internal array,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * which means that it is a copy of the internal array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * references to the <CODE>MBeanNotificationInfo</CODE> objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * but that each referenced <CODE>MBeanNotificationInfo</CODE> object is not copied.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * @return  An array of <CODE>MBeanNotificationInfo</CODE> objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    public MBeanNotificationInfo[] getNotifications()  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        MBeanNotificationInfo[] ns = nonNullNotifications();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        if (ns.length == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            return ns;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            return ns.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    private MBeanNotificationInfo[] fastGetNotifications() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        if (arrayGettersSafe)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            return nonNullNotifications();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            return getNotifications();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    private MBeanNotificationInfo[] nonNullNotifications() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        return (notifications == null) ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            MBeanNotificationInfo.NO_NOTIFICATIONS : notifications;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * Get the descriptor of this MBeanInfo.  Changing the returned value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * will have no affect on the original descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * @return a descriptor that is either immutable or a copy of the original.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    public Descriptor getDescriptor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        return (Descriptor) nonNullDescriptor(descriptor).clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   485
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            getClass().getName() + "[" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            "description=" + getDescription() + ", " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            "attributes=" + Arrays.asList(fastGetAttributes()) + ", " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            "constructors=" + Arrays.asList(fastGetConstructors()) + ", " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            "operations=" + Arrays.asList(fastGetOperations()) + ", " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            "notifications=" + Arrays.asList(fastGetNotifications()) + ", " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            "descriptor=" + getDescriptor() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * <p>Compare this MBeanInfo to another.  Two MBeanInfo objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * are equal if and only if they return equal values for {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * #getClassName()}, for {@link #getDescription()}, and for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * {@link #getDescriptor()}, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * arrays returned by the two objects for {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * #getAttributes()}, {@link #getOperations()}, {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * #getConstructors()}, and {@link #getNotifications()} are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * pairwise equal.  Here "equal" means {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * Object#equals(Object)}, not identity.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * <p>If two MBeanInfo objects return the same values in one of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * their arrays but in a different order then they are not equal.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * @param o the object to compare to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * @return true if and only if <code>o</code> is an MBeanInfo that is equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * to this one according to the rules above.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     */
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   517
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    public boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        if (o == this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        if (!(o instanceof MBeanInfo))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        MBeanInfo p = (MBeanInfo) o;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        if (!isEqual(getClassName(),  p.getClassName()) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
                !isEqual(getDescription(), p.getDescription()) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
                !getDescriptor().equals(p.getDescriptor())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            (Arrays.equals(p.fastGetAttributes(), fastGetAttributes()) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
             Arrays.equals(p.fastGetOperations(), fastGetOperations()) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
             Arrays.equals(p.fastGetConstructors(), fastGetConstructors()) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
             Arrays.equals(p.fastGetNotifications(), fastGetNotifications()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   537
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        /* Since computing the hashCode is quite expensive, we cache it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
           If by some terrible misfortune the computed value is 0, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
           caching won't work and we will recompute it every time.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
           We don't bother synchronizing, because, at worst, n different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
           threads will compute the same hashCode at the same time.  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        if (hashCode != 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            return hashCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        hashCode =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            getClassName().hashCode() ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            getDescriptor().hashCode() ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            arrayHashCode(fastGetAttributes()) ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            arrayHashCode(fastGetOperations()) ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
            arrayHashCode(fastGetConstructors()) ^
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            arrayHashCode(fastGetNotifications());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        return hashCode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    private static int arrayHashCode(Object[] array) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        int hash = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        for (int i = 0; i < array.length; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
            hash ^= array[i].hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
        return hash;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * Cached results of previous calls to arrayGettersSafe.  This is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * a WeakHashMap so that we don't prevent a class from being
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * garbage collected just because we know whether it's immutable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     */
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 2
diff changeset
   571
    private static final Map<Class<?>, Boolean> arrayGettersSafeMap =
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 2
diff changeset
   572
        new WeakHashMap<Class<?>, Boolean>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * Return true if <code>subclass</code> is known to preserve the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * immutability of <code>immutableClass</code>.  The class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * <code>immutableClass</code> is a reference class that is known
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * to be immutable.  The subclass <code>subclass</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * considered immutable if it does not override any public method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * of <code>immutableClass</code> whose name begins with "get".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * This is obviously not an infallible test for immutability,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * but it works for the public interfaces of the MBean*Info classes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    */
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 2
diff changeset
   584
    static boolean arrayGettersSafe(Class<?> subclass, Class<?> immutableClass) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        if (subclass == immutableClass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        synchronized (arrayGettersSafeMap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            Boolean safe = arrayGettersSafeMap.get(subclass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            if (safe == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                    ArrayGettersSafeAction action =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                        new ArrayGettersSafeAction(subclass, immutableClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                    safe = AccessController.doPrivileged(action);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                } catch (Exception e) { // e.g. SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                    /* We don't know, so we assume it isn't.  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                    safe = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                arrayGettersSafeMap.put(subclass, safe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            return safe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * The PrivilegedAction stuff is probably overkill.  We can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * pretty sure the caller does have the required privileges -- a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * JMX user that can't do reflection can't even use Standard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * MBeans!  But there's probably a performance gain by not having
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * to check the whole call stack.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    private static class ArrayGettersSafeAction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            implements PrivilegedAction<Boolean> {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
        private final Class<?> subclass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        private final Class<?> immutableClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        ArrayGettersSafeAction(Class<?> subclass, Class<?> immutableClass) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
            this.subclass = subclass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
            this.immutableClass = immutableClass;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        public Boolean run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            Method[] methods = immutableClass.getMethods();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            for (int i = 0; i < methods.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                Method method = methods[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                String methodName = method.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                if (methodName.startsWith("get") &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                        method.getParameterTypes().length == 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                        method.getReturnType().isArray()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                        Method submethod =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
                            subclass.getMethod(methodName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                        if (!submethod.equals(method))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                    } catch (NoSuchMethodException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    private static boolean isEqual(String s1, String s2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        boolean ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        if (s1 == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            ret = (s2 == null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            ret = s1.equals(s2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
        return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * Serializes an {@link MBeanInfo} to an {@link ObjectOutputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * @serialData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * For compatibility reasons, an object of this class is serialized as follows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * The method {@link ObjectOutputStream#defaultWriteObject defaultWriteObject()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     * is called first to serialize the object except the field {@code descriptor}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * which is declared as transient. The field {@code descriptor} is serialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * as follows:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     *     <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     *     <li> If {@code descriptor} is an instance of the class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     *        {@link ImmutableDescriptor}, the method {@link ObjectOutputStream#write
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     *        write(int val)} is called to write a byte with the value {@code 1},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     *        then the method {@link ObjectOutputStream#writeObject writeObject(Object obj)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     *        is called twice to serialize the field names and the field values of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     *        {@code descriptor}, respectively as a {@code String[]} and an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     *        {@code Object[]};</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     *     <li> Otherwise, the method {@link ObjectOutputStream#write write(int val)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     *        is called to write a byte with the value {@code 0}, then the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     *        {@link ObjectOutputStream#writeObject writeObject(Object obj)} is called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     *        to serialize the field {@code descriptor} directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     *     </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    private void writeObject(ObjectOutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        out.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        if (descriptor.getClass() == ImmutableDescriptor.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            out.write(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
            final String[] names = descriptor.getFieldNames();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
            out.writeObject(names);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
            out.writeObject(descriptor.getFieldValues(names));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
            out.write(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            out.writeObject(descriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * Deserializes an {@link MBeanInfo} from an {@link ObjectInputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * @serialData
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * For compatibility reasons, an object of this class is deserialized as follows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * The method {@link ObjectInputStream#defaultReadObject defaultReadObject()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * is called first to deserialize the object except the field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * {@code descriptor}, which is not serialized in the default way. Then the method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * {@link ObjectInputStream#read read()} is called to read a byte, the field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * {@code descriptor} is deserialized according to the value of the byte value:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     *    <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     *    <li>1. The method {@link ObjectInputStream#readObject readObject()}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     *       is called twice to obtain the field names (a {@code String[]}) and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     *       the field values (a {@code Object[]}) of the {@code descriptor}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     *       The two obtained values then are used to construct
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     *       an {@link ImmutableDescriptor} instance for the field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     *       {@code descriptor};</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     *    <li>0. The value for the field {@code descriptor} is obtained directly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     *       by calling the method {@link ObjectInputStream#readObject readObject()}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     *       If the obtained value is null, the field {@code descriptor} is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     *       {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR};</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     *    <li>-1. This means that there is no byte to read and that the object is from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     *       an earlier version of the JMX API. The field {@code descriptor} is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     *       {@link ImmutableDescriptor#EMPTY_DESCRIPTOR EMPTY_DESCRIPTOR}.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     *    <li>Any other value. A {@link StreamCorruptedException} is thrown.</li>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     *    </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    private void readObject(ObjectInputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        in.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        switch (in.read()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        case 1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
            final String[] names = (String[])in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
            if (names.length == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
                final Object[] values = (Object[])in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
                descriptor = new ImmutableDescriptor(names, values);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        case 0:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
            descriptor = (Descriptor)in.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
            if (descriptor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
                descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
        case -1: // from an earlier version of the JMX API
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
            descriptor = ImmutableDescriptor.EMPTY_DESCRIPTOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
            throw new StreamCorruptedException("Got unexpected byte.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    }
1570
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   761
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   762
    /**
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   763
     * <p>Return an {@code MBeanInfo} object that is the same as this one
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   764
     * except that its descriptions are localized in the given locale.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   765
     * This means the text returned by {@link MBeanInfo#getDescription}
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   766
     * (the description of the MBean itself), and the text returned by the
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   767
     * {@link MBeanFeatureInfo#getDescription getDescription()} method
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   768
     * for every {@linkplain MBeanAttributeInfo attribute}, {@linkplain
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   769
     * MBeanOperationInfo operation}, {@linkplain MBeanConstructorInfo
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   770
     * constructor}, and {@linkplain MBeanNotificationInfo notification}
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   771
     * contained in the {@code MBeanInfo}.</p>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   772
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   773
     * <p>Here is how the description {@code this.getDescription()} is
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   774
     * localized.</p>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   775
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   776
     * <p>First, if the {@linkplain #getDescriptor() descriptor}
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   777
     * of this {@code MBeanInfo} contains a field <code><a
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   778
     * href="Descriptor.html#locale">"locale"</a></code>, and the value of
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   779
     * the field is the same as {@code locale.toString()}, then this {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   780
     * MBeanInfo} is returned. Otherwise, localization proceeds as follows,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   781
     * and the {@code "locale"} field in the returned {@code MBeanInfo} will
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   782
     * be {@code locale.toString()}.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   783
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   784
     * <p>A <em>{@code className}</em> is determined. If this
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   785
     * {@code MBeanInfo} contains a descriptor with the field
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   786
     * <a href="Descriptor.html#interfaceClassName">{@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   787
     * "interfaceClassName"}</a>, then the value of that field is the
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   788
     * {@code className}. Otherwise, it is {@link #getClassName()}.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   789
     * Everything before the last period (.) in the {@code className} is
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   790
     * the <em>{@code package}</em>, and everything after is the <em>{@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   791
     * simpleClassName}</em>. (If there is no period, then the {@code package}
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   792
     * is empty and the {@code simpleClassName} is the same as the {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   793
     * className}.)</p>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   794
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   795
     * <p>A <em>{@code resourceKey}</em> is determined. If this {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   796
     * MBeanInfo} contains a {@linkplain MBeanInfo#getDescriptor() descriptor}
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   797
     * with a field {@link JMX#DESCRIPTION_RESOURCE_KEY_FIELD
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   798
     * "descriptionResourceKey"}, the value of the field is
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   799
     * the {@code resourceKey}. Otherwise, the {@code resourceKey} is {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   800
     * simpleClassName + ".mbean"}.</p>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   801
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   802
     * <p>A <em>{@code resourceBundleBaseName}</em> is determined. If
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   803
     * this {@code MBeanInfo} contains a descriptor with a field {@link
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   804
     * JMX#DESCRIPTION_RESOURCE_BUNDLE_BASE_NAME_FIELD
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   805
     * "descriptionResourceBundleBaseName"}, the value of the field
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   806
     * is the {@code resourceBundleBaseName}. Otherwise, the {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   807
     * resourceBundleBaseName} is {@code package + ".MBeanDescriptions"}.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   808
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   809
     * <p>Then, a {@link java.util.ResourceBundle ResourceBundle} is
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   810
     * determined, using<br> {@link java.util.ResourceBundle#getBundle(String,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   811
     * Locale, ClassLoader) ResourceBundle.getBundle(resourceBundleBaseName,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   812
     * locale, loader)}. If this succeeds, and if {@link
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   813
     * java.util.ResourceBundle#getString(String) getString(resourceKey)}
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   814
     * returns a string, then that string is the localized description.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   815
     * Otherwise, the original description is unchanged.</p>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   816
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   817
     * <p>A localized description for an {@code MBeanAttributeInfo} is
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   818
     * obtained similarly. The default {@code resourceBundleBaseName}
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   819
     * is the same as above. The default description and the
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   820
     * descriptor fields {@code "descriptionResourceKey"} and {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   821
     * "descriptionResourceBundleBaseName"} come from the {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   822
     * MBeanAttributeInfo} rather than the {@code MBeanInfo}. If the
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   823
     * attribute's {@linkplain MBeanFeatureInfo#getName() name} is {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   824
     * Foo} then its default {@code resourceKey} is {@code simpleClassName +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   825
     * ".attribute.Foo"}.</p>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   826
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   827
     * <p>Similar rules apply for operations, constructors, and notifications.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   828
     * If the name of the operation, constructor, or notification is {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   829
     * Foo} then the default {@code resourceKey} is respectively {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   830
     * simpleClassName + ".operation.Foo"}, {@code simpleClassName +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   831
     * ".constructor.Foo"}, or {@code simpleClassName + ".notification.Foo"}.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   832
     * If two operations or constructors have the same name (overloading) then
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   833
     * they have the same default {@code resourceKey}; if different localized
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   834
     * descriptions are needed then a non-default key must be supplied using
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   835
     * {@code "descriptionResourceKey"}.</p>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   836
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   837
     * <p>Similar rules also apply for descriptions of parameters ({@link
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   838
     * MBeanParameterInfo}). The default {@code resourceKey} for a parameter
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   839
     * whose {@linkplain MBeanFeatureInfo#getName() name} is {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   840
     * Bar} in an operation or constructor called {@code Foo} is {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   841
     * simpleClassName + ".operation.Foo.Bar"} or {@code simpleClassName +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   842
     * ".constructor.Foo.Bar"} respectively.</p>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   843
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   844
     * <h4>Example</h4>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   845
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   846
     * <p>Suppose you have an MBean defined by these two Java source files:</p>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   847
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   848
     * <pre>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   849
     * // ConfigurationMBean.java
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   850
     * package com.example;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   851
     * public interface ConfigurationMBean {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   852
     *     public String getName();
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   853
     *     public void save(String fileName);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   854
     * }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   855
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   856
     * // Configuration.java
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   857
     * package com.example;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   858
     * public class Configuration implements ConfigurationMBean {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   859
     *     public Configuration(String defaultName) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   860
     *         ...
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   861
     *     }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   862
     *     ...
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   863
     * }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   864
     * </pre>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   865
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   866
     * <p>Then you could define the default descriptions for the MBean, by
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   867
     * including a resource bundle called {@code com/example/MBeanDescriptions}
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   868
     * with the compiled classes. Most often this is done by creating a file
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   869
     * {@code MBeanDescriptions.properties} in the same directory as {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   870
     * ConfigurationMBean.java}. Make sure that this file is copied into the
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   871
     * same place as the compiled classes; in typical build environments that
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   872
     * will be true by default.</p>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   873
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   874
     * <p>The file {@code com/example/MBeanDescriptions.properties} might
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   875
     * look like this:</p>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   876
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   877
     * <pre>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   878
     * # Description of the MBean
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   879
     * ConfigurationMBean.mbean = Configuration manager
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   880
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   881
     * # Description of the Name attribute
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   882
     * ConfigurationMBean.attribute.Name = The name of the configuration
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   883
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   884
     * # Description of the save operation
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   885
     * ConfigurationMBean.operation.save = Save the configuration to a file
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   886
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   887
     * # Description of the parameter to the save operation.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   888
     * # Parameter names from the original Java source are not available,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   889
     * # so the default names are p1, p2, etc.  If the names were available,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   890
     * # this would be ConfigurationMBean.operation.save.fileName
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   891
     * ConfigurationMBean.operation.save.p1 = The name of the file
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   892
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   893
     * # Description of the constructor.  The default name of a constructor is
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   894
     * # its fully-qualified class name.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   895
     * ConfigurationMBean.constructor.com.example.Configuration = <!--
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   896
     * -->Constructor with name of default file
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   897
     * # Description of the constructor parameter.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   898
     * ConfigurationMBean.constructor.com.example.Configuration.p1 = <!--
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   899
     * -->Name of the default file
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   900
     * </pre>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   901
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   902
     * <p>Starting with this file, you could create descriptions for the French
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   903
     * locale by creating {@code com/example/MBeanDescriptions_fr.properties}.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   904
     * The keys in this file are the same as before but the text has been
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   905
     * translated:
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   906
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   907
     * <pre>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   908
     * ConfigurationMBean.mbean = Gestionnaire de configuration
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   909
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   910
     * ConfigurationMBean.attribute.Name = Le nom de la configuration
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   911
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   912
     * ConfigurationMBean.operation.save = Sauvegarder la configuration <!--
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   913
     * -->dans un fichier
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   914
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   915
     * ConfigurationMBean.operation.save.p1 = Le nom du fichier
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   916
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   917
     * ConfigurationMBean.constructor.com.example.Configuration = <!--
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   918
     * -->Constructeur avec nom du fichier par d&eacute;faut
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   919
     * ConfigurationMBean.constructor.com.example.Configuration.p1 = <!--
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   920
     * -->Nom du fichier par d&eacute;faut
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   921
     * </pre>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   922
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   923
     * <p>The descriptions in {@code MBeanDescriptions.properties} and
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   924
     * {@code MBeanDescriptions_fr.properties} will only be consulted if
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   925
     * {@code localizeDescriptions} is called, perhaps because the
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   926
     * MBean Server has been wrapped by {@link
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   927
     * ClientContext#newLocalizeMBeanInfoForwarder} or because the
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   928
     * connector server has been created with the {@link
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   929
     * javax.management.remote.JMXConnectorServer#LOCALIZE_MBEAN_INFO_FORWARDER
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   930
     * LOCALIZE_MBEAN_INFO_FORWARDER} option. If you want descriptions
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   931
     * even when there is no localization step, then you should consider
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   932
     * using {@link Description &#64;Description} annotations. Annotations
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   933
     * provide descriptions by default but are overridden if {@code
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   934
     * localizeDescriptions} is called.</p>
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   935
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   936
     * @param locale the target locale for descriptions.  Cannot be null.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   937
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   938
     * @param loader the {@code ClassLoader} to use for looking up resource
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   939
     * bundles.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   940
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   941
     * @return an {@code MBeanInfo} with descriptions appropriately localized.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   942
     *
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   943
     * @throws NullPointerException if {@code locale} is null.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   944
     */
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   945
    public MBeanInfo localizeDescriptions(Locale locale, ClassLoader loader) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   946
        if (locale == null)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   947
            throw new NullPointerException("locale");
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   948
        Descriptor d = getDescriptor();
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   949
        String mbiLocaleString = (String) d.getFieldValue(JMX.LOCALE_FIELD);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   950
        if (locale.toString().equals(mbiLocaleString))
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   951
            return this;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   952
        return new Rewriter(this, locale, loader).getMBeanInfo();
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   953
    }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   954
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   955
    private static class Rewriter {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   956
        private final MBeanInfo mbi;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   957
        private final ClassLoader loader;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   958
        private final Locale locale;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   959
        private final String packageName;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   960
        private final String simpleClassNamePlusDot;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   961
        private ResourceBundle defaultBundle;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   962
        private boolean defaultBundleLoaded;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   963
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   964
        // ResourceBundle.getBundle throws NullPointerException
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   965
        // if the loader is null, even though that is perfectly
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   966
        // valid and means the bootstrap loader.  So we work
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   967
        // around with a ClassLoader that is equivalent to the
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   968
        // bootstrap loader but is not null.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   969
        private static final ClassLoader bootstrapLoader =
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   970
                new ClassLoader(null) {};
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   971
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   972
        Rewriter(MBeanInfo mbi, Locale locale, ClassLoader loader) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   973
            this.mbi = mbi;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   974
            this.locale = locale;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   975
            if (loader == null)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   976
                loader = bootstrapLoader;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   977
            this.loader = loader;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   978
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   979
            String intfName = (String)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   980
                    mbi.getDescriptor().getFieldValue("interfaceClassName");
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   981
            if (intfName == null)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   982
                intfName = mbi.getClassName();
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   983
            int lastDot = intfName.lastIndexOf('.');
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   984
            this.packageName = intfName.substring(0, lastDot + 1);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   985
            this.simpleClassNamePlusDot = intfName.substring(lastDot + 1) + ".";
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   986
            // Inner classes show up as Outer$Inner so won't match the dot.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   987
            // When there is no dot, lastDot is -1,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   988
            // packageName is empty, and simpleClassNamePlusDot is intfName.
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   989
        }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   990
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   991
        MBeanInfo getMBeanInfo() {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   992
            MBeanAttributeInfo[] mbais =
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   993
                    rewrite(mbi.getAttributes(), "attribute.");
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   994
            MBeanOperationInfo[] mbois =
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   995
                    rewrite(mbi.getOperations(), "operation.");
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   996
            MBeanConstructorInfo[] mbcis =
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   997
                    rewrite(mbi.getConstructors(), "constructor.");
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   998
            MBeanNotificationInfo[] mbnis =
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
   999
                    rewrite(mbi.getNotifications(), "notification.");
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1000
            Descriptor d = mbi.getDescriptor();
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1001
            d = changeLocale(d);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1002
            String description = getDescription(d, "mbean", "");
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1003
            if (description == null)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1004
                description = mbi.getDescription();
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1005
            return new MBeanInfo(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1006
                    mbi.getClassName(), description,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1007
                    mbais, mbcis, mbois, mbnis, d);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1008
        }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1009
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1010
        private Descriptor changeLocale(Descriptor d) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1011
            if (d.getFieldValue(JMX.LOCALE_FIELD) != null) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1012
                Map<String, Object> map = new HashMap<String, Object>();
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1013
                for (String field : d.getFieldNames())
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1014
                    map.put(field, d.getFieldValue(field));
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1015
                map.remove(JMX.LOCALE_FIELD);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1016
                d = new ImmutableDescriptor(map);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1017
            }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1018
            return ImmutableDescriptor.union(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1019
                    d, new ImmutableDescriptor(JMX.LOCALE_FIELD + "=" + locale));
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1020
        }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1021
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1022
        private String getDescription(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1023
                Descriptor d, String defaultPrefix, String defaultSuffix) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1024
            ResourceBundle bundle = bundleFromDescriptor(d);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1025
            if (bundle == null)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1026
                return null;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1027
            String key =
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1028
                    (String) d.getFieldValue(JMX.DESCRIPTION_RESOURCE_KEY_FIELD);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1029
            if (key == null)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1030
                key = simpleClassNamePlusDot + defaultPrefix + defaultSuffix;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1031
            return descriptionFromResource(bundle, key);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1032
        }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1033
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1034
        private <T extends MBeanFeatureInfo> T[] rewrite(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1035
                T[] features, String resourcePrefix) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1036
            for (int i = 0; i < features.length; i++) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1037
                T feature = features[i];
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1038
                Descriptor d = feature.getDescriptor();
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1039
                String description =
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1040
                        getDescription(d, resourcePrefix, feature.getName());
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1041
                if (description != null &&
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1042
                        !description.equals(feature.getDescription())) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1043
                    features[i] = setDescription(feature, description);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1044
                }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1045
            }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1046
            return features;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1047
        }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1048
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1049
        private <T extends MBeanFeatureInfo> T setDescription(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1050
                T feature, String description) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1051
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1052
            Object newf;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1053
            String name = feature.getName();
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1054
            Descriptor d = feature.getDescriptor();
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1055
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1056
            if (feature instanceof MBeanAttributeInfo) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1057
                MBeanAttributeInfo mbai = (MBeanAttributeInfo) feature;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1058
                newf = new MBeanAttributeInfo(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1059
                        name, mbai.getType(), description,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1060
                        mbai.isReadable(), mbai.isWritable(), mbai.isIs(),
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1061
                        d);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1062
            } else if (feature instanceof MBeanOperationInfo) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1063
                MBeanOperationInfo mboi = (MBeanOperationInfo) feature;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1064
                MBeanParameterInfo[] sig = rewrite(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1065
                        mboi.getSignature(), "operation." + name + ".");
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1066
                newf = new MBeanOperationInfo(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1067
                        name, description, sig,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1068
                        mboi.getReturnType(), mboi.getImpact(), d);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1069
            } else if (feature instanceof MBeanConstructorInfo) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1070
                MBeanConstructorInfo mbci = (MBeanConstructorInfo) feature;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1071
                MBeanParameterInfo[] sig = rewrite(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1072
                        mbci.getSignature(), "constructor." + name + ".");
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1073
                newf = new MBeanConstructorInfo(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1074
                        name, description, sig, d);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1075
            } else if (feature instanceof MBeanNotificationInfo) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1076
                MBeanNotificationInfo mbni = (MBeanNotificationInfo) feature;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1077
                newf = new MBeanNotificationInfo(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1078
                        mbni.getNotifTypes(), name, description, d);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1079
            } else if (feature instanceof MBeanParameterInfo) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1080
                MBeanParameterInfo mbpi = (MBeanParameterInfo) feature;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1081
                newf = new MBeanParameterInfo(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1082
                        name, mbpi.getType(), description, d);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1083
            } else {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1084
                logger().log(Level.FINE, "Unknown feature type: " +
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1085
                        feature.getClass());
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1086
                newf = feature;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1087
            }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1088
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1089
            return Util.<T>cast(newf);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1090
        }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1091
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1092
        private ResourceBundle bundleFromDescriptor(Descriptor d) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1093
            String bundleName = (String) d.getFieldValue(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1094
                    JMX.DESCRIPTION_RESOURCE_BUNDLE_BASE_NAME_FIELD);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1095
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1096
            if (bundleName != null)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1097
                return getBundle(bundleName);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1098
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1099
            if (defaultBundleLoaded)
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1100
                return defaultBundle;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1101
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1102
            bundleName = packageName + "MBeanDescriptions";
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1103
            defaultBundle = getBundle(bundleName);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1104
            defaultBundleLoaded = true;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1105
            return defaultBundle;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1106
        }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1107
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1108
        private String descriptionFromResource(
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1109
                ResourceBundle bundle, String key) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1110
            try {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1111
                return bundle.getString(key);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1112
            } catch (MissingResourceException e) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1113
                logger().log(Level.FINEST, "No resource for " + key, e);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1114
            } catch (Exception e) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1115
                logger().log(Level.FINE, "Bad resource for " + key, e);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1116
            }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1117
            return null;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1118
        }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1119
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1120
        private ResourceBundle getBundle(String name) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1121
            try {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1122
                return ResourceBundle.getBundle(name, locale, loader);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1123
            } catch (Exception e) {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1124
                logger().log(Level.FINE,
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1125
                           "Could not load ResourceBundle " + name, e);
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1126
                return null;
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1127
            }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1128
        }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1129
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1130
        private Logger logger() {
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1131
            return Logger.getLogger("javax.management.locale");
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1132
        }
4165709c91e3 5072267: A way to communicate client context such as locale to the JMX server
emcmanus
parents: 1513
diff changeset
  1133
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
}