src/java.management/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java
author prr
Mon, 04 Nov 2019 10:01:55 -0800
changeset 59176 f5adbf111424
parent 47216 71c04702a3d5
permissions -rw-r--r--
8233097: Fontmetrics for large Fonts has zero width Reviewed-by: jdv, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
     2
 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    23
 * questions.
2
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.lang.reflect.Constructor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.security.AccessController;
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
    42
import java.lang.System.Logger.Level;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import javax.management.Descriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import javax.management.DescriptorAccess;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import javax.management.DescriptorKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import javax.management.MBeanConstructorInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import javax.management.MBeanParameterInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import javax.management.RuntimeOperationsException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
/**
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    52
 * <p>The ModelMBeanConstructorInfo object describes a constructor of the ModelMBean.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * It is a subclass of MBeanConstructorInfo with the addition of an associated Descriptor
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    54
 * and an implementation of the DescriptorAccess interface.</p>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    55
 *
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    56
 * <P id="descriptor">
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    57
 * The fields in the descriptor are defined, but not limited to, the following.
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    58
 * Note that when the Type in this table is Number, a String that is the decimal
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    59
 * representation of a Long can also be used.</P>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    60
 *
45130
469dceb426cc 8179631: Fix Html5 errors in java.management, jdk.management, jdk.jdi and jdk.attach
ksrini
parents: 44858
diff changeset
    61
 * <table class="striped">
44858
7183899b064b 8179415: Update java.management and java.management.rmi to be HTML-5 friendly
ksrini
parents: 43235
diff changeset
    62
 * <caption style="display:none">ModelMBeanConstructorInfo Fields</caption>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 45130
diff changeset
    63
 * <thead>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 45130
diff changeset
    64
 * <tr><th scope="col">Name</th><th scope="col">Type</th><th scope="col">Meaning</th></tr>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 45130
diff changeset
    65
 * </thead>
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 45130
diff changeset
    66
 * <tbody style="text-align:left">
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 45130
diff changeset
    67
 * <tr><th scope="row">name</th><td>String</td>
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    68
 *     <td>Constructor name.</td></tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 45130
diff changeset
    69
 * <tr><th scope="row">descriptorType</th><td>String</td>
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    70
 *     <td>Must be "operation".</td></tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 45130
diff changeset
    71
 * <tr><th scope="row">role</th><td>String</td>
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    72
 *     <td>Must be "constructor".</td></tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 45130
diff changeset
    73
 * <tr><th scope="row">displayName</th><td>String</td>
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    74
 *     <td>Human readable name of constructor.</td></tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 45130
diff changeset
    75
 * <tr><th scope="row">visibility</th><td>Number</td>
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    76
 *     <td>1-4 where 1: always visible 4: rarely visible.</td></tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 45130
diff changeset
    77
 * <tr><th scope="row">presentationString</th><td>String</td>
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    78
 *     <td>XML formatted string to describe how to present operation</td></tr>
47028
6df65183aa1f 8186932: Fix accessibility issues in the java.management module
jjg
parents: 45130
diff changeset
    79
 * </tbody>
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    80
 * </table>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <p>The {@code persistPolicy} and {@code currencyTimeLimit} fields
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    83
 * are meaningless for constructors, but are not considered invalid.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * <p>The default descriptor will have the {@code name}, {@code
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
    86
 * descriptorType}, {@code displayName} and {@code role} fields.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * <p>The <b>serialVersionUID</b> of this class is <code>3862947819818064362L</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
@SuppressWarnings("serial")  // serialVersionUID is not constant
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
public class ModelMBeanConstructorInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    extends MBeanConstructorInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    implements DescriptorAccess {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    // Serialization compatibility stuff:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    // Two serial forms are supported in this class. The selected form depends
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    // on system property "jmx.serial.form":
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    //  - "1.0" for JMX 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    //  - any other value for JMX 1.1 and higher
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    // Serial version for old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    private static final long oldSerialVersionUID = -4440125391095574518L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    // Serial version for new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    private static final long newSerialVersionUID = 3862947819818064362L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    // Serializable fields in old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    private static final ObjectStreamField[] oldSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
      new ObjectStreamField("consDescriptor", Descriptor.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
      new ObjectStreamField("currClass", String.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    // Serializable fields in new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    private static final ObjectStreamField[] newSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
      new ObjectStreamField("consDescriptor", Descriptor.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    // Actual serial version and serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    private static final long serialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @serialField consDescriptor Descriptor The {@link Descriptor} containing the metadata for this instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    private static final ObjectStreamField[] serialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    private static boolean compat = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            String form = AccessController.doPrivileged(act);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            compat = (form != null && form.equals("1.0"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            // OK: No compat with 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        if (compat) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            serialPersistentFields = oldSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            serialVersionUID = oldSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            serialPersistentFields = newSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            serialVersionUID = newSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    // END Serialization compatibility stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
         * @serial The {@link Descriptor} containing the metadata for this instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        private Descriptor consDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        private final static String currClass = "ModelMBeanConstructorInfo";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        * Constructs a ModelMBeanConstructorInfo object with a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        * descriptor.  The {@link Descriptor} of the constructed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        * object will include fields contributed by any annotations on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        * the {@code Constructor} object that contain the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        * DescriptorKey} meta-annotation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        * @param description A human readable description of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        * @param constructorMethod The java.lang.reflect.Constructor object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        * describing the MBean constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        public ModelMBeanConstructorInfo(String description,
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 715
diff changeset
   169
                                         Constructor<?> constructorMethod)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                super(description, constructorMethod);
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   172
                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   173
                    MODELMBEAN_LOGGER.log(Level.TRACE,
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   174
                            "ModelMBeanConstructorInfo(String,Constructor) " +
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                            "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                consDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                // put getter and setter methods in constructors list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                // create default descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        * Constructs a ModelMBeanConstructorInfo object.  The {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        * Descriptor} of the constructed object will include fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        * contributed by any annotations on the {@code Constructor}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        * object that contain the {@link DescriptorKey}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        * meta-annotation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        * @param description A human readable description of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        * @param constructorMethod The java.lang.reflect.Constructor object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        * describing the ModelMBean constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        * @param descriptor An instance of Descriptor containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        * appropriate metadata for this instance of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        * ModelMBeanConstructorInfo.  If it is null, then a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        * descriptor will be created. If the descriptor does not
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   198
        * contain the field "displayName" this field is added in the
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   199
        * descriptor with its default value.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        * IllegalArgumentException. The descriptor is invalid, or
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   203
        * descriptor field "name" is not equal to name
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   204
        * parameter, or descriptor field "descriptorType" is
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   205
        * not equal to "operation" or descriptor field "role" is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        * present but not equal to "constructor".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        public ModelMBeanConstructorInfo(String description,
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 715
diff changeset
   210
                                         Constructor<?> constructorMethod,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                                         Descriptor descriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                super(description, constructorMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                // put getter and setter methods in constructors list
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   216
                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   217
                    MODELMBEAN_LOGGER.log(Level.TRACE,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                            "ModelMBeanConstructorInfo(" +
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   219
                            "String,Constructor,Descriptor) Entry");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                consDescriptor = validDescriptor(descriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        * Constructs a ModelMBeanConstructorInfo object with a default descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        * @param name The name of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        * @param description A human readable description of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        * @param signature MBeanParameterInfo object array describing the parameters(arguments) of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        public ModelMBeanConstructorInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                                         String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                                         MBeanParameterInfo[] signature)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                super(name, description, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                // create default descriptor
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   238
                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   239
                    MODELMBEAN_LOGGER.log(Level.TRACE,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                            "ModelMBeanConstructorInfo(" +
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   241
                            "String,String,MBeanParameterInfo[]) Entry");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                consDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        * Constructs a ModelMBeanConstructorInfo object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        * @param name The name of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        * @param description A human readable description of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        * @param signature MBeanParameterInfo objects describing the parameters(arguments) of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        * @param descriptor An instance of Descriptor containing the appropriate metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        *                   for this instance of the MBeanConstructorInfo. If it is null then a default descriptor will be created.
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   253
        * If the descriptor does not contain the field "displayName" this field
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   254
        * is added in the descriptor with its default value.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        * IllegalArgumentException. The descriptor is invalid, or
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   258
        * descriptor field "name" is not equal to name
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   259
        * parameter, or descriptor field "descriptorType" is
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   260
        * not equal to "operation" or descriptor field "role" is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        * present but not equal to "constructor".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        public ModelMBeanConstructorInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                                         String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                                         MBeanParameterInfo[] signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                                         Descriptor descriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                super(name, description, signature);
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   270
                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   271
                    MODELMBEAN_LOGGER.log(Level.TRACE,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                            "ModelMBeanConstructorInfo(" +
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   273
                            "String,String,MBeanParameterInfo[],Descriptor) " +
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                            "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                consDescriptor = validDescriptor(descriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
         * Constructs a new ModelMBeanConstructorInfo object from this ModelMBeanConstructor Object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
         * @param old the ModelMBeanConstructorInfo to be duplicated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        ModelMBeanConstructorInfo(ModelMBeanConstructorInfo old)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                super(old.getName(), old.getDescription(), old.getSignature());
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   288
                if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   289
                    MODELMBEAN_LOGGER.log(Level.TRACE,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                            "ModelMBeanConstructorInfo(" +
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   291
                            "ModelMBeanConstructorInfo) Entry");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                consDescriptor = validDescriptor(consDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        * Creates and returns a new ModelMBeanConstructorInfo which is a duplicate of this ModelMBeanConstructorInfo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        */
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   300
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        public Object clone ()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        {
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   303
            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   304
                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                return(new ModelMBeanConstructorInfo(this)) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
         * Returns a copy of the associated Descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
         * @return Descriptor associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
         * ModelMBeanConstructorInfo object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
         * @see #setDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   319
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        public Descriptor getDescriptor()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        {
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   322
            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   323
                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            if (consDescriptor == null){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                consDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            return((Descriptor)consDescriptor.clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        * Sets associated Descriptor (full replace) of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        * ModelMBeanConstructorInfo.  If the new Descriptor is null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        * then the associated Descriptor reverts to a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        * descriptor.  The Descriptor is validated before it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        * assigned.  If the new Descriptor is invalid, then a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        * RuntimeOperationsException wrapping an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        * IllegalArgumentException is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        * @param inDescriptor replaces the Descriptor associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        * the ModelMBeanConstructor. If the descriptor does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        * contain all the following fields, the missing ones are added with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        * their default values: displayName, name, role, descriptorType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        * IllegalArgumentException.  The descriptor is invalid, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        * descriptor field "name" is present but not equal to name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        * parameter, or descriptor field "descriptorType" is present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        * but not equal to "operation" or descriptor field "role" is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        * present but not equal to "constructor".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        * @see #getDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        public void setDescriptor(Descriptor inDescriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        {
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   355
            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   356
                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
            consDescriptor = validDescriptor(inDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        * Returns a string containing the entire contents of the ModelMBeanConstructorInfo in human readable form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        */
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   364
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        public String toString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        {
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   367
            if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) {
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   368
                MODELMBEAN_LOGGER.log(Level.TRACE, "Entry");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                String retStr =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                    "ModelMBeanConstructorInfo: " + this.getName() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                    " ; Description: " + this.getDescription() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                    " ; Descriptor: " + this.getDescriptor() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                    " ; Signature: ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                MBeanParameterInfo[] pTypes = this.getSignature();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                for (int i=0; i < pTypes.length; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                        retStr = retStr.concat((pTypes[i]).getType() + ", ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                return retStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
         * Clones the passed in Descriptor, sets default values, and checks for validity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
         * If the Descriptor is invalid (for instance by having the wrong "name"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
         * this indicates programming error and a RuntimeOperationsException will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
         * The following fields will be defaulted if they are not already set:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
         * displayName=this.getName(), name=this.getName(), descriptorType="operation",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
         * role="constructor"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
         * @param in Descriptor to be checked, or null which is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
         * an empty Descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
         * @exception RuntimeOperationsException if Descriptor is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   399
            Descriptor clone;
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   400
            boolean defaulted = (in == null);
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   401
            if (defaulted) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                clone = new DescriptorSupport();
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   403
                MODELMBEAN_LOGGER.log(Level.TRACE, "Null Descriptor, creating new.");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                clone = (Descriptor) in.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            //Setting defaults.
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   409
            if (defaulted && clone.getFieldValue("name")==null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                clone.setField("name", this.getName());
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   411
                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor name to " + this.getName());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            }
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   413
            if (defaulted && clone.getFieldValue("descriptorType")==null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                clone.setField("descriptorType", "operation");
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   415
                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting descriptorType to \"operation\"");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            if (clone.getFieldValue("displayName") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                clone.setField("displayName",this.getName());
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   419
                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor displayName to " + this.getName());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            if (clone.getFieldValue("role") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                clone.setField("role","constructor");
43235
da1786d695b6 8172971: java.management could use System.Logger
dfuchs
parents: 25859
diff changeset
   423
                MODELMBEAN_LOGGER.log(Level.TRACE, "Defaulting Descriptor role field to \"constructor\"");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            //Checking validity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            if (!clone.isValid()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
                 throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                    "The isValid() method of the Descriptor object itself returned false,"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                    "one or more required fields are invalid. Descriptor:" + clone.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            }
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   432
            if (!getName().equalsIgnoreCase((String) clone.getFieldValue("name"))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                    throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                    "The Descriptor \"name\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                     " Expected: "+ this.getName() + " , was: " + clone.getFieldValue("name"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            }
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   437
            if (!"operation".equalsIgnoreCase((String) clone.getFieldValue("descriptorType"))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                     throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                    "The Descriptor \"descriptorType\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                     " Expected: \"operation\" ," + " was: " + clone.getFieldValue("descriptorType"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            if (! ((String)clone.getFieldValue("role")).equalsIgnoreCase("constructor")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                     throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                    "The Descriptor \"role\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                     " Expected: \"constructor\" ," + " was: " + clone.getFieldValue("role"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            return clone;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * Deserializes a {@link ModelMBeanConstructorInfo} from an {@link ObjectInputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    private void readObject(ObjectInputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
      // New serial form ignores extra field "currClass"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
      in.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * Serializes a {@link ModelMBeanConstructorInfo} to an {@link ObjectOutputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    private void writeObject(ObjectOutputStream out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
      if (compat)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        // Serializes this instance in the old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        ObjectOutputStream.PutField fields = out.putFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        fields.put("consDescriptor", consDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        fields.put("currClass", currClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        out.writeFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
      else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        // Serializes this instance in the new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        out.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
}