jdk/src/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java
author emcmanus
Wed, 21 Oct 2009 17:33:18 +0200
changeset 4156 acaa49a2768a
parent 1004 5ba8217eb504
child 5506 202f599c92aa
permissions -rw-r--r--
6851617: Remove JSR 255 (JMX API 2.0) from JDK 7 Summary: See http://weblogs.java.net/blog/2009/06/16/jsr-255-jmx-api-20-postponed Reviewed-by: dfuchs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 526
diff changeset
     2
 * Portions Copyright 2000-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
 * @author    IBM Corp.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * Copyright IBM Corp. 1999-2000.  All rights reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
package javax.management.modelmbean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import static com.sun.jmx.defaults.JmxProperties.MODELMBEAN_LOGGER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import com.sun.jmx.mbeanserver.GetPropertyAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.io.ObjectStreamField;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.util.logging.Level;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import javax.management.Descriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import javax.management.MBeanAttributeInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import javax.management.MBeanConstructorInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import javax.management.MBeanException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import javax.management.MBeanInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import javax.management.MBeanNotificationInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import javax.management.MBeanOperationInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import javax.management.RuntimeOperationsException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * This class represents the meta data for ModelMBeans.  Descriptors have been
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * added on the meta data objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * Java resources wishing to be manageable instantiate the ModelMBean using the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * MBeanServer's createMBean method.  The resource then sets the ModelMBeanInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * and Descriptors for the ModelMBean instance. The attributes and operations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * exposed via the ModelMBeanInfo for the ModelMBean are accessible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * from MBeans, connectors/adaptors like other MBeans. Through the Descriptors,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * values and methods in the managed application can be defined and mapped to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * attributes and operations of the ModelMBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * This mapping can be defined during development in a file or dynamically and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * programmatically at runtime.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * Every ModelMBean which is instantiated in the MBeanServer becomes manageable:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * its attributes and operations
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * become remotely accessible through the connectors/adaptors connected to that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * MBeanServer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * A Java object cannot be registered in the MBeanServer unless it is a JMX
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * compliant MBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * By instantiating a ModelMBean, resources are guaranteed that the MBean is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * valid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * MBeanException and RuntimeOperationsException must be thrown on every public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * method.  This allows for wrapping exceptions from distributed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * communications (RMI, EJB, etc.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * <p>The <b>serialVersionUID</b> of this class is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * <code>-1935722590756516193L</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
@SuppressWarnings("serial")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
public class ModelMBeanInfoSupport extends MBeanInfo implements ModelMBeanInfo {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    // Serialization compatibility stuff:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    // Two serial forms are supported in this class. The selected form depends
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    // on system property "jmx.serial.form":
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    //  - "1.0" for JMX 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    //  - any other value for JMX 1.1 and higher
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    // Serial version for old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private static final long oldSerialVersionUID = -3944083498453227709L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    // Serial version for new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private static final long newSerialVersionUID = -1935722590756516193L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    // Serializable fields in old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    private static final ObjectStreamField[] oldSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        new ObjectStreamField("modelMBeanDescriptor", Descriptor.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                new ObjectStreamField("mmbAttributes", MBeanAttributeInfo[].class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                new ObjectStreamField("mmbConstructors", MBeanConstructorInfo[].class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                new ObjectStreamField("mmbNotifications", MBeanNotificationInfo[].class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                new ObjectStreamField("mmbOperations", MBeanOperationInfo[].class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                new ObjectStreamField("currClass", String.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    // Serializable fields in new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    private static final ObjectStreamField[] newSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        new ObjectStreamField("modelMBeanDescriptor", Descriptor.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
                new ObjectStreamField("modelMBeanAttributes", MBeanAttributeInfo[].class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                new ObjectStreamField("modelMBeanConstructors", MBeanConstructorInfo[].class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                new ObjectStreamField("modelMBeanNotifications", MBeanNotificationInfo[].class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                new ObjectStreamField("modelMBeanOperations", MBeanOperationInfo[].class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    // Actual serial version and serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    private static final long serialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @serialField modelMBeanDescriptor Descriptor The descriptor containing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     *              MBean wide policy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @serialField modelMBeanAttributes ModelMBeanAttributeInfo[] The array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *              {@link ModelMBeanAttributeInfo} objects which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *              have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @serialField modelMBeanConstructors MBeanConstructorInfo[] The array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     *              {@link ModelMBeanConstructorInfo} objects which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *              have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @serialField modelMBeanNotifications MBeanNotificationInfo[] The array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     *              {@link ModelMBeanNotificationInfo} objects which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     *              have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @serialField modelMBeanOperations MBeanOperationInfo[] The array of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     *              {@link ModelMBeanOperationInfo} objects which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     *              have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    private static final ObjectStreamField[] serialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    private static boolean compat = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            String form = AccessController.doPrivileged(act);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            compat = (form != null && form.equals("1.0"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
            // OK: No compat with 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        if (compat) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
            serialPersistentFields = oldSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            serialVersionUID = oldSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            serialPersistentFields = newSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            serialVersionUID = newSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    // END Serialization compatibility stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * @serial The descriptor containing MBean wide policy
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    private Descriptor modelMBeanDescriptor = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    /* The following fields always have the same values as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
       fields inherited from MBeanInfo and are retained only for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
       compatibility.  By rewriting the serialization code we could
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
       get rid of them.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
       These fields can't be final because they are assigned to by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
       readObject().  */
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 array of {@link ModelMBeanAttributeInfo} objects which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *         have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    private MBeanAttributeInfo[] modelMBeanAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @serial The array of {@link ModelMBeanConstructorInfo} objects which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     *         have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    private MBeanConstructorInfo[] modelMBeanConstructors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @serial The array of {@link ModelMBeanNotificationInfo} objects which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     *         have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    private MBeanNotificationInfo[] modelMBeanNotifications;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @serial The array of {@link ModelMBeanOperationInfo} objects which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *         have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    private MBeanOperationInfo[] modelMBeanOperations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    private static final String ATTR = "attribute";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    private static final String OPER = "operation";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    private static final String NOTF = "notification";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    private static final String CONS = "constructor";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    private static final String MMB = "mbean";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    private static final String ALL = "all";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    private static final String currClass = "ModelMBeanInfoSupport";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Constructs a ModelMBeanInfoSupport which is a duplicate of the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * ModelMBeanInfo.  The returned object is a shallow copy of the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * object.  Neither the Descriptor nor the contained arrays
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * ({@code ModelMBeanAttributeInfo[]} etc) are cloned.  This method is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * chiefly of interest to modify the Descriptor of the returned instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * via {@link #setDescriptor setDescriptor} without affecting the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * Descriptor of the original object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @param mbi the ModelMBeanInfo instance from which the ModelMBeanInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * being created is initialized.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    public ModelMBeanInfoSupport(ModelMBeanInfo  mbi) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        super(mbi.getClassName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                mbi.getDescription(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                mbi.getAttributes(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                mbi.getConstructors(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                mbi.getOperations(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                mbi.getNotifications());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        modelMBeanAttributes = mbi.getAttributes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        modelMBeanConstructors = mbi.getConstructors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        modelMBeanOperations = mbi.getOperations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        modelMBeanNotifications = mbi.getNotifications();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            Descriptor mbeandescriptor = mbi.getMBeanDescriptor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            modelMBeanDescriptor = validDescriptor(mbeandescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        } catch (MBeanException mbe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            modelMBeanDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                        ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                        "ModelMBeanInfo(ModelMBeanInfo)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                        "Could not get a valid modelMBeanDescriptor, " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                        "setting a default Descriptor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                    "ModelMBeanInfo(ModelMBeanInfo)", "Exit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * Creates a ModelMBeanInfoSupport with the provided information,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * but the descriptor is a default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * The default descriptor is: name=className, descriptorType="mbean",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * displayName=className, persistPolicy="never", log="F", visibility="1"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @param className classname of the MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * @param description human readable description of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * ModelMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @param attributes array of ModelMBeanAttributeInfo objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * which have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @param constructors array of ModelMBeanConstructorInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * objects which have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * @param operations array of ModelMBeanOperationInfo objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * which have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * @param notifications array of ModelMBeanNotificationInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * objects which have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    public ModelMBeanInfoSupport(String className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
            String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            ModelMBeanAttributeInfo[] attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            ModelMBeanConstructorInfo[] constructors,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            ModelMBeanOperationInfo[] operations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            ModelMBeanNotificationInfo[] notifications) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        this(className, description, attributes, constructors,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                operations, notifications, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * Creates a ModelMBeanInfoSupport with the provided information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * and the descriptor given in parameter.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @param className classname of the MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * @param description human readable description of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * ModelMBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * @param attributes array of ModelMBeanAttributeInfo objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * which have descriptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @param constructors array of ModelMBeanConstructorInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * objects which have descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @param operations array of ModelMBeanOperationInfo objects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * which have descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @param notifications array of ModelMBeanNotificationInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * objects which have descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @param mbeandescriptor descriptor to be used as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * MBeanDescriptor containing MBean wide policy. If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * descriptor is null, a default descriptor will be constructed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * The default descriptor is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * name=className, descriptorType="mbean", displayName=className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * persistPolicy="never", log="F", visibility="1".  If the descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * does not contain all of these fields, the missing ones are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * added with these default values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * IllegalArgumentException for invalid descriptor passed in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * parameter.  (see {@link #getMBeanDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * getMBeanDescriptor} for the definition of a valid MBean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * descriptor.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    public ModelMBeanInfoSupport(String    className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
            ModelMBeanAttributeInfo[] attributes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            ModelMBeanConstructorInfo[] constructors,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            ModelMBeanOperationInfo[] operations,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            ModelMBeanNotificationInfo[] notifications,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            Descriptor mbeandescriptor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        super(className,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                (attributes != null) ? attributes : NO_ATTRIBUTES,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                (constructors != null) ? constructors : NO_CONSTRUCTORS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                (operations != null) ? operations : NO_OPERATIONS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                (notifications != null) ? notifications : NO_NOTIFICATIONS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        /* The values saved here are possibly null, but we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
           check this everywhere they are referenced.  If at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
           some stage we replace null with an empty array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
           here, as we do in the superclass constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
           parameters, then we must also do this in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
           readObject().  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        modelMBeanAttributes = attributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        modelMBeanConstructors = constructors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        modelMBeanOperations = operations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        modelMBeanNotifications = notifications;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        modelMBeanDescriptor = validDescriptor(mbeandescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                    "ModelMBeanInfoSupport(String,String,ModelMBeanAttributeInfo[]," +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                    "ModelMBeanConstructorInfo[],ModelMBeanOperationInfo[]," +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                    "ModelMBeanNotificationInfo[],Descriptor)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                    "Exit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    private static final ModelMBeanAttributeInfo[] NO_ATTRIBUTES =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            new ModelMBeanAttributeInfo[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    private static final ModelMBeanConstructorInfo[] NO_CONSTRUCTORS =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            new ModelMBeanConstructorInfo[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    private static final ModelMBeanNotificationInfo[] NO_NOTIFICATIONS =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            new ModelMBeanNotificationInfo[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    private static final ModelMBeanOperationInfo[] NO_OPERATIONS =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            new ModelMBeanOperationInfo[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    // Java doc inherited from MOdelMBeanInfo interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * Returns a shallow clone of this instance.  Neither the Descriptor nor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * the contained arrays ({@code ModelMBeanAttributeInfo[]} etc) are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * cloned.  This method is chiefly of interest to modify the Descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * of the clone via {@link #setDescriptor setDescriptor} without affecting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * the Descriptor of the original object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @return a shallow clone of this instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    public Object clone() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        return(new ModelMBeanInfoSupport(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    public Descriptor[] getDescriptors(String inDescriptorType)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    throws MBeanException, RuntimeOperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                    "getDescriptors(String)", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
   376
        if ((inDescriptorType == null) || (inDescriptorType.equals(""))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            inDescriptorType = "all";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        // if no descriptors of that type, will return empty array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        final Descriptor[] retList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        if (inDescriptorType.equalsIgnoreCase(MMB)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            retList = new Descriptor[] {modelMBeanDescriptor};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        } else if (inDescriptorType.equalsIgnoreCase(ATTR)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            final MBeanAttributeInfo[] attrList = modelMBeanAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            int numAttrs = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            if (attrList != null) numAttrs = attrList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            retList = new Descriptor[numAttrs];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            for (int i=0; i < numAttrs; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                retList[i] = (((ModelMBeanAttributeInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                    attrList[i]).getDescriptor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        } else if (inDescriptorType.equalsIgnoreCase(OPER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            final MBeanOperationInfo[] operList = modelMBeanOperations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            int numOpers = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            if (operList != null) numOpers = operList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            retList = new Descriptor[numOpers];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            for (int i=0; i < numOpers; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                retList[i] = (((ModelMBeanOperationInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                    operList[i]).getDescriptor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        } else if (inDescriptorType.equalsIgnoreCase(CONS)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            final MBeanConstructorInfo[] consList =  modelMBeanConstructors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            int numCons = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            if (consList != null) numCons = consList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            retList = new Descriptor[numCons];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            for (int i=0; i < numCons; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                retList[i] = (((ModelMBeanConstructorInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                    consList[i]).getDescriptor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        } else if (inDescriptorType.equalsIgnoreCase(NOTF)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            final MBeanNotificationInfo[] notifList = modelMBeanNotifications;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            int numNotifs = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            if (notifList != null) numNotifs = notifList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            retList = new Descriptor[numNotifs];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            for (int i=0; i < numNotifs; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                retList[i] = (((ModelMBeanNotificationInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                    notifList[i]).getDescriptor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        } else if (inDescriptorType.equalsIgnoreCase(ALL)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            final MBeanAttributeInfo[] attrList = modelMBeanAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            int numAttrs = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            if (attrList != null) numAttrs = attrList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            final MBeanOperationInfo[] operList = modelMBeanOperations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            int numOpers = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            if (operList != null) numOpers = operList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            final MBeanConstructorInfo[] consList = modelMBeanConstructors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            int numCons = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            if (consList != null) numCons = consList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            final MBeanNotificationInfo[] notifList = modelMBeanNotifications;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            int numNotifs = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            if (notifList != null) numNotifs = notifList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            int count = numAttrs + numCons + numOpers + numNotifs + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            retList = new Descriptor[count];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            retList[count-1] = modelMBeanDescriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            int j=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            for (int i=0; i < numAttrs; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                retList[j] = (((ModelMBeanAttributeInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                    attrList[i]).getDescriptor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                j++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            for (int i=0; i < numCons; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                retList[j] = (((ModelMBeanConstructorInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                    consList[i]).getDescriptor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
                j++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            for (int i=0; i < numOpers; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                retList[j] = (((ModelMBeanOperationInfo)operList[i]).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                        getDescriptor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                j++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            for (int i=0; i < numNotifs; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                retList[j] = (((ModelMBeanNotificationInfo)notifList[i]).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                        getDescriptor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                j++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            final IllegalArgumentException iae =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                    new IllegalArgumentException("Descriptor Type is invalid");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            final String msg = "Exception occurred trying to find"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                    " the descriptors of the MBean";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            throw new RuntimeOperationsException(iae,msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                    "getDescriptors(String)", "Exit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        return retList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    public void setDescriptors(Descriptor[] inDescriptors)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    throws MBeanException, RuntimeOperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
                    "setDescriptors(Descriptor[])", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        if (inDescriptors==null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            // throw RuntimeOperationsException - invalid descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
            throw new RuntimeOperationsException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
                    new IllegalArgumentException("Descriptor list is invalid"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                    "Exception occurred trying to set the descriptors " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
                    "of the MBeanInfo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        if (inDescriptors.length == 0) { // empty list, no-op
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        for (int j=0; j < inDescriptors.length; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            setDescriptor(inDescriptors[j],null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
                    "setDescriptors(Descriptor[])", "Exit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * Returns a Descriptor requested by name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * @param inDescriptorName The name of the descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * @return Descriptor containing a descriptor for the ModelMBean with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     *         same name. If no descriptor is found, null is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * @exception MBeanException Wraps a distributed communication Exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * @exception RuntimeOperationsException Wraps an IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     *            for null name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * @see #setDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    public Descriptor getDescriptor(String inDescriptorName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    throws MBeanException, RuntimeOperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
                    "getDescriptor(String)", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        return(getDescriptor(inDescriptorName, null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    public Descriptor getDescriptor(String inDescriptorName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
            String inDescriptorType)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            throws MBeanException, RuntimeOperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        if (inDescriptorName==null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
            // throw RuntimeOperationsException - invalid descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
            throw new RuntimeOperationsException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                    new IllegalArgumentException("Descriptor is invalid"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
                    "Exception occurred trying to set the descriptors of " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
                    "the MBeanInfo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        if (MMB.equalsIgnoreCase(inDescriptorType)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
            return (Descriptor) modelMBeanDescriptor.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            /* The logic here is a bit convoluted, because we are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
               dealing with two possible cases, depending on whether
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
               inDescriptorType is null.  If it's not null, then only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
               one of the following ifs will run, and it will either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
               return a descriptor or null.  If inDescriptorType is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
               null, then all of the following ifs will run until one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
               of them finds a descriptor.  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        if (ATTR.equalsIgnoreCase(inDescriptorType) || inDescriptorType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
            ModelMBeanAttributeInfo attr = getAttribute(inDescriptorName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            if (attr != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                return attr.getDescriptor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
            if (inDescriptorType != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        if (OPER.equalsIgnoreCase(inDescriptorType) || inDescriptorType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
            ModelMBeanOperationInfo oper = getOperation(inDescriptorName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
            if (oper != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                return oper.getDescriptor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            if (inDescriptorType != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        if (CONS.equalsIgnoreCase(inDescriptorType) || inDescriptorType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            ModelMBeanConstructorInfo oper =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                    getConstructor(inDescriptorName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            if (oper != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
                return oper.getDescriptor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            if (inDescriptorType != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
        if (NOTF.equalsIgnoreCase(inDescriptorType) || inDescriptorType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
            ModelMBeanNotificationInfo notif =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                    getNotification(inDescriptorName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            if (notif != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
                return notif.getDescriptor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            if (inDescriptorType != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
                return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        if (inDescriptorType == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        throw new RuntimeOperationsException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
                new IllegalArgumentException("Descriptor Type is invalid"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                "Exception occurred trying to find the descriptors of the MBean");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    }
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
    public void setDescriptor(Descriptor inDescriptor,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
            String inDescriptorType)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
            throws MBeanException, RuntimeOperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        final String excMsg =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                "Exception occurred trying to set the descriptors of the MBean";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
                    "setDescriptor(Descriptor,String)", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        if (inDescriptor==null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
            inDescriptor = new DescriptorSupport();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
1004
5ba8217eb504 5108776: Add reliable event handling to the JMX API
sjiang
parents: 715
diff changeset
   619
        if ((inDescriptorType == null) || (inDescriptorType.equals(""))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            inDescriptorType =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                    (String) inDescriptor.getFieldValue("descriptorType");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            if (inDescriptorType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                   MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                                ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                                "setDescriptor(Descriptor,String)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                                "descriptorType null in both String parameter and Descriptor, defaulting to "+ MMB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                inDescriptorType = MMB;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        String inDescriptorName =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                (String) inDescriptor.getFieldValue("name");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        if (inDescriptorName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                                ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
                                "setDescriptor(Descriptor,String)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                                "descriptor name null, defaulting to "+ this.getClassName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
            inDescriptorName = this.getClassName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        boolean found = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        if (inDescriptorType.equalsIgnoreCase(MMB)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
            setMBeanDescriptor(inDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
            found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        } else if (inDescriptorType.equalsIgnoreCase(ATTR)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
            MBeanAttributeInfo[] attrList =  modelMBeanAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
            int numAttrs = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
            if (attrList != null) numAttrs = attrList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            for (int i=0; i < numAttrs; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                if (inDescriptorName.equals(attrList[i].getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                    found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                    ModelMBeanAttributeInfo mmbai =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                            (ModelMBeanAttributeInfo) attrList[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                    mmbai.setDescriptor(inDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
                        StringBuilder strb = new StringBuilder()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                        .append("Setting descriptor to ").append(inDescriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
                        .append("\t\n local: AttributeInfo descriptor is ")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                        .append(mmbai.getDescriptor())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
                        .append("\t\n modelMBeanInfo: AttributeInfo descriptor is ")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                        .append(this.getDescriptor(inDescriptorName,"attribute"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
                        MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                                ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
                                "setDescriptor(Descriptor,String)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                                strb.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        } else if (inDescriptorType.equalsIgnoreCase(OPER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
            MBeanOperationInfo[] operList =  modelMBeanOperations;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
            int numOpers = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            if (operList != null) numOpers = operList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            for (int i=0; i < numOpers; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                if (inDescriptorName.equals(operList[i].getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                    found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                    ModelMBeanOperationInfo mmboi =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                            (ModelMBeanOperationInfo) operList[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                    mmboi.setDescriptor(inDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        } else if (inDescriptorType.equalsIgnoreCase(CONS)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            MBeanConstructorInfo[] consList =  modelMBeanConstructors;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            int numCons = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            if (consList != null) numCons = consList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            for (int i=0; i < numCons; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                if (inDescriptorName.equals(consList[i].getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                    found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
                    ModelMBeanConstructorInfo mmbci =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                            (ModelMBeanConstructorInfo) consList[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                    mmbci.setDescriptor(inDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        } else if (inDescriptorType.equalsIgnoreCase(NOTF)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            MBeanNotificationInfo[] notifList =  modelMBeanNotifications;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            int numNotifs = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
            if (notifList != null) numNotifs = notifList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
            for (int i=0; i < numNotifs; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
                if (inDescriptorName.equals(notifList[i].getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
                    found = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
                    ModelMBeanNotificationInfo mmbni =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                            (ModelMBeanNotificationInfo) notifList[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                    mmbni.setDescriptor(inDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
            RuntimeException iae =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
                    new IllegalArgumentException("Invalid descriptor type: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
                    inDescriptorType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            throw new RuntimeOperationsException(iae, excMsg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        if (!found) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
            RuntimeException iae =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
                    new IllegalArgumentException("Descriptor name is invalid: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
                    "type=" + inDescriptorType +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
                    "; name=" + inDescriptorName);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            throw new RuntimeOperationsException(iae, excMsg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
                    "setDescriptor(Descriptor,String)", "Exit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    public ModelMBeanAttributeInfo getAttribute(String inName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    throws MBeanException, RuntimeOperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        ModelMBeanAttributeInfo retInfo = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
                    "getAttribute(String)", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        if (inName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
            throw new RuntimeOperationsException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
                    new IllegalArgumentException("Attribute Name is null"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
                    "Exception occurred trying to get the " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
                    "ModelMBeanAttributeInfo of the MBean");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        MBeanAttributeInfo[] attrList = modelMBeanAttributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        int numAttrs = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        if (attrList != null) numAttrs = attrList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        for (int i=0; (i < numAttrs) && (retInfo == null); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
                final StringBuilder strb = new StringBuilder()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
                .append("\t\n this.getAttributes() MBeanAttributeInfo Array ")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                .append(i).append(":")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                .append(((ModelMBeanAttributeInfo)attrList[i]).getDescriptor())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                .append("\t\n this.modelMBeanAttributes MBeanAttributeInfo Array ")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
                .append(i).append(":")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                .append(((ModelMBeanAttributeInfo)modelMBeanAttributes[i]).getDescriptor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
                        ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                        "getAttribute(String)", strb.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            if (inName.equals(attrList[i].getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                retInfo = ((ModelMBeanAttributeInfo)attrList[i].clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
                    "getAttribute(String)", "Exit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        return retInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    public ModelMBeanOperationInfo getOperation(String inName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    throws MBeanException, RuntimeOperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        ModelMBeanOperationInfo retInfo = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                    "getOperation(String)", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
        if (inName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
            throw new RuntimeOperationsException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                    new IllegalArgumentException("inName is null"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                    "Exception occurred trying to get the " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                    "ModelMBeanOperationInfo of the MBean");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        MBeanOperationInfo[] operList = modelMBeanOperations; //this.getOperations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        int numOpers = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        if (operList != null) numOpers = operList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
        for (int i=0; (i < numOpers) && (retInfo == null); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            if (inName.equals(operList[i].getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                retInfo = ((ModelMBeanOperationInfo) operList[i].clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
                    "getOperation(String)", "Exit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        return retInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     * Returns the ModelMBeanConstructorInfo requested by name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     * If no ModelMBeanConstructorInfo exists for this name null is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     * @param inName the name of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     * @return the constructor info for the named constructor, or null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     * if there is none.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     * @exception MBeanException Wraps a distributed communication Exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     * @exception RuntimeOperationsException Wraps an IllegalArgumentException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     *            for a null constructor name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
    public ModelMBeanConstructorInfo getConstructor(String inName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    throws MBeanException, RuntimeOperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        ModelMBeanConstructorInfo retInfo = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                    "getConstructor(String)", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        if (inName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
            throw new RuntimeOperationsException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
                    new IllegalArgumentException("Constructor name is null"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
                    "Exception occurred trying to get the " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
                    "ModelMBeanConstructorInfo of the MBean");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        MBeanConstructorInfo[] consList = modelMBeanConstructors; //this.getConstructors();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        int numCons = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        if (consList != null) numCons = consList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        for (int i=0; (i < numCons) && (retInfo == null); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
            if (inName.equals(consList[i].getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
                retInfo = ((ModelMBeanConstructorInfo) consList[i].clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
                    "getConstructor(String)", "Exit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        return retInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    public ModelMBeanNotificationInfo getNotification(String inName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    throws MBeanException, RuntimeOperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        ModelMBeanNotificationInfo retInfo = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
                    "getNotification(String)", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        if (inName == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
            throw new RuntimeOperationsException(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                    new IllegalArgumentException("Notification name is null"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                    "Exception occurred trying to get the " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
                    "ModelMBeanNotificationInfo of the MBean");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        MBeanNotificationInfo[] notifList = modelMBeanNotifications; //this.getNotifications();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        int numNotifs = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        if (notifList != null) numNotifs = notifList.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        for (int i=0; (i < numNotifs) && (retInfo == null); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
            if (inName.equals(notifList[i].getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                retInfo = ((ModelMBeanNotificationInfo) notifList[i].clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
                    "getNotification(String)", "Exit");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        return retInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    /* We override MBeanInfo.getDescriptor() to return our descriptor. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
    public Descriptor getDescriptor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        return getMBeanDescriptorNoException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    public Descriptor getMBeanDescriptor() throws MBeanException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        return getMBeanDescriptorNoException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
    private Descriptor getMBeanDescriptorNoException() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                    "getMBeanDescriptorNoException()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
        if (modelMBeanDescriptor == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
            modelMBeanDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                    "getMBeanDescriptorNoException()",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                    "Exit, returning: " + modelMBeanDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
        return (Descriptor) modelMBeanDescriptor.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    public void setMBeanDescriptor(Descriptor inMBeanDescriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
    throws MBeanException, RuntimeOperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
        if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
            MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                    ModelMBeanInfoSupport.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                    "setMBeanDescriptor(Descriptor)", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
        modelMBeanDescriptor = validDescriptor(inMBeanDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
     * Clones the passed in Descriptor, sets default values, and checks for validity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     * If the Descriptor is invalid (for instance by having the wrong "name"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     * this indicates programming error and a RuntimeOperationsException will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
     * The following fields will be defaulted if they are not already set:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
     * displayName=className,name=className,descriptorType="mbean",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
     * persistPolicy="never", log="F", visibility="1"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
     * @param in Descriptor to be checked, or null which is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
     * an empty Descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
     * @exception RuntimeOperationsException if Descriptor is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
    private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
   947
        Descriptor clone;
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1004
diff changeset
   948
        boolean defaulted = (in == null);
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1004
diff changeset
   949
        if (defaulted) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
            clone = new DescriptorSupport();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
            MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
            clone = (Descriptor) in.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
        //Setting defaults.
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1004
diff changeset
   957
        if (defaulted && clone.getFieldValue("name")==null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            clone.setField("name", this.getClassName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
            MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getClassName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        }
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1004
diff changeset
   961
        if (defaulted && clone.getFieldValue("descriptorType")==null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
            clone.setField("descriptorType", MMB);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
            MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"" + MMB + "\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        if (clone.getFieldValue("displayName") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
            clone.setField("displayName",this.getClassName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
            MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getClassName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
        if (clone.getFieldValue("persistPolicy") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
            clone.setField("persistPolicy","never");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
            MODELMBEAN_LOGGER.finer("Defaulting Descriptor persistPolicy to \"never\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
        if (clone.getFieldValue("log") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
            clone.setField("log","F");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
            MODELMBEAN_LOGGER.finer("Defaulting Descriptor \"log\" field to \"F\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
        if (clone.getFieldValue("visibility") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
            clone.setField("visibility","1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
            MODELMBEAN_LOGGER.finer("Defaulting Descriptor visibility to 1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
        //Checking validity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
        if (!clone.isValid()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
             throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
                "The isValid() method of the Descriptor object itself returned false,"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                "one or more required fields are invalid. Descriptor:" + clone.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
        if (! ((String)clone.getFieldValue("descriptorType")).equalsIgnoreCase(MMB)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
                 throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                "The Descriptor \"descriptorType\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                 " Expected: "+ MMB + " , was: " + clone.getFieldValue("descriptorType"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
        return clone;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     * Deserializes a {@link ModelMBeanInfoSupport} from an {@link ObjectInputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
    private void readObject(ObjectInputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
    throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
        if (compat) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
            // Read an object serialized in the old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
            ObjectInputStream.GetField fields = in.readFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
            modelMBeanDescriptor =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
                    (Descriptor) fields.get("modelMBeanDescriptor", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
            if (fields.defaulted("modelMBeanDescriptor")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                throw new NullPointerException("modelMBeanDescriptor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
            modelMBeanAttributes =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
                    (MBeanAttributeInfo[]) fields.get("mmbAttributes", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
            if (fields.defaulted("mmbAttributes")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
                throw new NullPointerException("mmbAttributes");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
            modelMBeanConstructors =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
                    (MBeanConstructorInfo[]) fields.get("mmbConstructors", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
            if (fields.defaulted("mmbConstructors")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
                throw new NullPointerException("mmbConstructors");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
            modelMBeanNotifications =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
                    (MBeanNotificationInfo[]) fields.get("mmbNotifications", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
            if (fields.defaulted("mmbNotifications")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
                throw new NullPointerException("mmbNotifications");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
            modelMBeanOperations =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
                    (MBeanOperationInfo[]) fields.get("mmbOperations", null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
            if (fields.defaulted("mmbOperations")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
                throw new NullPointerException("mmbOperations");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
            // Read an object serialized in the new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
            in.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     * Serializes a {@link ModelMBeanInfoSupport} to an {@link ObjectOutputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
    private void writeObject(ObjectOutputStream out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
    throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
        if (compat) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
            // Serializes this instance in the old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
            ObjectOutputStream.PutField fields = out.putFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
            fields.put("modelMBeanDescriptor", modelMBeanDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
            fields.put("mmbAttributes", modelMBeanAttributes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
            fields.put("mmbConstructors", modelMBeanConstructors);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
            fields.put("mmbNotifications", modelMBeanNotifications);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
            fields.put("mmbOperations", modelMBeanOperations);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
            fields.put("currClass", currClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
            out.writeFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
            // Serializes this instance in the new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
            out.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
}