jdk/src/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java
author rriggs
Tue, 12 Nov 2013 14:03:28 -0500
changeset 21656 d4c777ccb1db
parent 5506 202f599c92aa
child 23010 6dadb192ad81
permissions -rw-r--r--
8028014: Doclint warning/error cleanup in javax.management Summary: Improve generated html by fixing doclint warnings Reviewed-by: sla, jbachorik
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
     2
 * Copyright (c) 2000, 2008, 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;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.util.logging.Level;
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
 *
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 5506
diff changeset
    61
 * <table border="1" cellpadding="5" summary="ModelMBeanConstructorInfo Fields">
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    62
 * <tr><th>Name</th><th>Type</th><th>Meaning</th></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    63
 * <tr><td>name</td><td>String</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    64
 *     <td>Constructor name.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    65
 * <tr><td>descriptorType</td><td>String</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    66
 *     <td>Must be "operation".</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    67
 * <tr><td>role</td><td>String</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    68
 *     <td>Must be "constructor".</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    69
 * <tr><td>displayName</td><td>String</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    70
 *     <td>Human readable name of constructor.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    71
 * <tr><td>visibility</td><td>Number</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    72
 *     <td>1-4 where 1: always visible 4: rarely visible.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    73
 * <tr><td>presentationString</td><td>String</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    74
 *     <td>XML formatted string to describe how to present operation</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    75
 * </table>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <p>The {@code persistPolicy} and {@code currencyTimeLimit} fields
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 1510
diff changeset
    78
 * are meaningless for constructors, but are not considered invalid.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * <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
    81
 * descriptorType}, {@code displayName} and {@code role} fields.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * <p>The <b>serialVersionUID</b> of this class is <code>3862947819818064362L</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
@SuppressWarnings("serial")  // serialVersionUID is not constant
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
public class ModelMBeanConstructorInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    extends MBeanConstructorInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    implements DescriptorAccess {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    // Serialization compatibility stuff:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    // Two serial forms are supported in this class. The selected form depends
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    // on system property "jmx.serial.form":
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    //  - "1.0" for JMX 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    //  - any other value for JMX 1.1 and higher
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    // Serial version for old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    private static final long oldSerialVersionUID = -4440125391095574518L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    // Serial version for new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private static final long newSerialVersionUID = 3862947819818064362L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    // Serializable fields in old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    private static final ObjectStreamField[] oldSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
      new ObjectStreamField("consDescriptor", Descriptor.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
      new ObjectStreamField("currClass", String.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    // Serializable fields in new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    private static final ObjectStreamField[] newSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
      new ObjectStreamField("consDescriptor", Descriptor.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    // Actual serial version and serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    private static final long serialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @serialField consDescriptor Descriptor The {@link Descriptor} containing the metadata for this instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    private static final ObjectStreamField[] serialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    private static boolean compat = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            String form = AccessController.doPrivileged(act);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            compat = (form != null && form.equals("1.0"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            // OK: No compat with 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        if (compat) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            serialPersistentFields = oldSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            serialVersionUID = oldSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            serialPersistentFields = newSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            serialVersionUID = newSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    // END Serialization compatibility stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
         * @serial The {@link Descriptor} containing the metadata for this instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        private Descriptor consDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        private final static String currClass = "ModelMBeanConstructorInfo";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        * Constructs a ModelMBeanConstructorInfo object with a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        * descriptor.  The {@link Descriptor} of the constructed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        * object will include fields contributed by any annotations on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        * the {@code Constructor} object that contain the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        * DescriptorKey} meta-annotation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        * @param description A human readable description of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        * @param constructorMethod The java.lang.reflect.Constructor object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        * describing the MBean constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        public ModelMBeanConstructorInfo(String description,
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 715
diff changeset
   164
                                         Constructor<?> constructorMethod)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                super(description, constructorMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                            ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                            "ModelMBeanConstructorInfo(String,Constructor)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                            "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                consDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                // put getter and setter methods in constructors list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                // create default descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        * Constructs a ModelMBeanConstructorInfo object.  The {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        * Descriptor} of the constructed object will include fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        * contributed by any annotations on the {@code Constructor}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        * object that contain the {@link DescriptorKey}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        * meta-annotation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        * @param description A human readable description of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        * @param constructorMethod The java.lang.reflect.Constructor object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        * describing the ModelMBean constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        * @param descriptor An instance of Descriptor containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        * appropriate metadata for this instance of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        * ModelMBeanConstructorInfo.  If it is null, then a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        * 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
   194
        * 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
   195
        * descriptor with its default value.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        * IllegalArgumentException. The descriptor is invalid, or
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   199
        * 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
   200
        * parameter, or descriptor field "descriptorType" is
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   201
        * not equal to "operation" or descriptor field "role" is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        * present but not equal to "constructor".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        public ModelMBeanConstructorInfo(String description,
1510
e747d3193ef2 6763639: Remove "rawtypes" warnings from JMX code
emcmanus
parents: 715
diff changeset
   206
                                         Constructor<?> constructorMethod,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                                         Descriptor descriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                super(description, constructorMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                // put getter and setter methods in constructors list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                            ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                            "ModelMBeanConstructorInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                            "String,Constructor,Descriptor)", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                consDescriptor = validDescriptor(descriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        * Constructs a ModelMBeanConstructorInfo object with a default descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        * @param name The name of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        * @param description A human readable description of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        * @param signature MBeanParameterInfo object array describing the parameters(arguments) of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        public ModelMBeanConstructorInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                                         String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                                         MBeanParameterInfo[] signature)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                super(name, description, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                // create default descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                            ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                            "ModelMBeanConstructorInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                            "String,String,MBeanParameterInfo[])", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                consDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        * Constructs a ModelMBeanConstructorInfo object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        * @param name The name of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        * @param description A human readable description of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        * @param signature MBeanParameterInfo objects describing the parameters(arguments) of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        * @param descriptor An instance of Descriptor containing the appropriate metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        *                   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
   251
        * 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
   252
        * is added in the descriptor with its default value.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        * IllegalArgumentException. The descriptor is invalid, or
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   256
        * 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
   257
        * parameter, or descriptor field "descriptorType" is
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   258
        * not equal to "operation" or descriptor field "role" is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        * present but not equal to "constructor".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        public ModelMBeanConstructorInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                                         String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                                         MBeanParameterInfo[] signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                                         Descriptor descriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                super(name, description, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                            ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                            "ModelMBeanConstructorInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                            "String,String,MBeanParameterInfo[],Descriptor)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                            "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                consDescriptor = validDescriptor(descriptor);
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
         * Constructs a new ModelMBeanConstructorInfo object from this ModelMBeanConstructor Object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
         * @param old the ModelMBeanConstructorInfo to be duplicated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        ModelMBeanConstructorInfo(ModelMBeanConstructorInfo old)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                super(old.getName(), old.getDescription(), old.getSignature());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                            ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                            "ModelMBeanConstructorInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                            "ModelMBeanConstructorInfo)", "Entry");
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
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                        ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                        "clone()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                return(new ModelMBeanConstructorInfo(this)) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
         * Returns a copy of the associated Descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
         * @return Descriptor associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
         * ModelMBeanConstructorInfo object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
         * @see #setDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   321
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        public Descriptor getDescriptor()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                        ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                        "getDescriptor()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            if (consDescriptor == null){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                consDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            return((Descriptor)consDescriptor.clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        * Sets associated Descriptor (full replace) of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        * ModelMBeanConstructorInfo.  If the new Descriptor is null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        * then the associated Descriptor reverts to a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        * descriptor.  The Descriptor is validated before it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        * assigned.  If the new Descriptor is invalid, then a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        * RuntimeOperationsException wrapping an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        * IllegalArgumentException is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        * @param inDescriptor replaces the Descriptor associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        * the ModelMBeanConstructor. If the descriptor does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        * contain all the following fields, the missing ones are added with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        * their default values: displayName, name, role, descriptorType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        * IllegalArgumentException.  The descriptor is invalid, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        * descriptor field "name" is present but not equal to name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        * parameter, or descriptor field "descriptorType" is present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        * but not equal to "operation" or descriptor field "role" is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        * present but not equal to "constructor".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        * @see #getDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        public void setDescriptor(Descriptor inDescriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                        ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                        "setDescriptor()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            consDescriptor = validDescriptor(inDescriptor);
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
        * Returns a string containing the entire contents of the ModelMBeanConstructorInfo in human readable form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        */
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   370
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        public String toString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                        ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                        "toString()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                String retStr =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                    "ModelMBeanConstructorInfo: " + this.getName() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                    " ; Description: " + this.getDescription() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                    " ; Descriptor: " + this.getDescriptor() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                    " ; Signature: ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                MBeanParameterInfo[] pTypes = this.getSignature();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                for (int i=0; i < pTypes.length; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                        retStr = retStr.concat((pTypes[i]).getType() + ", ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                return retStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
         * Clones the passed in Descriptor, sets default values, and checks for validity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
         * If the Descriptor is invalid (for instance by having the wrong "name"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
         * this indicates programming error and a RuntimeOperationsException will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
         * The following fields will be defaulted if they are not already set:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
         * displayName=this.getName(), name=this.getName(), descriptorType="operation",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
         * role="constructor"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
         * @param in Descriptor to be checked, or null which is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
         * an empty Descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
         * @exception RuntimeOperationsException if Descriptor is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        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
   407
            Descriptor clone;
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   408
            boolean defaulted = (in == null);
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   409
            if (defaulted) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                clone = new DescriptorSupport();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                clone = (Descriptor) in.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            //Setting defaults.
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   417
            if (defaulted && clone.getFieldValue("name")==null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                clone.setField("name", this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            }
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   421
            if (defaulted && clone.getFieldValue("descriptorType")==null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
                clone.setField("descriptorType", "operation");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"operation\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            if (clone.getFieldValue("displayName") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                clone.setField("displayName",this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            if (clone.getFieldValue("role") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                clone.setField("role","constructor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                MODELMBEAN_LOGGER.finer("Defaulting Descriptor role field to \"constructor\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            //Checking validity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            if (!clone.isValid()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                 throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                    "The isValid() method of the Descriptor object itself returned false,"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                    "one or more required fields are invalid. Descriptor:" + clone.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            }
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   440
            if (!getName().equalsIgnoreCase((String) clone.getFieldValue("name"))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                    throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                    "The Descriptor \"name\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                     " Expected: "+ this.getName() + " , was: " + clone.getFieldValue("name"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            }
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   445
            if (!"operation".equalsIgnoreCase((String) clone.getFieldValue("descriptorType"))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                     throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                    "The Descriptor \"descriptorType\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                     " Expected: \"operation\" ," + " was: " + clone.getFieldValue("descriptorType"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            if (! ((String)clone.getFieldValue("role")).equalsIgnoreCase("constructor")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                     throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                    "The Descriptor \"role\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                     " Expected: \"constructor\" ," + " was: " + clone.getFieldValue("role"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            return clone;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * Deserializes a {@link ModelMBeanConstructorInfo} from an {@link ObjectInputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    private void readObject(ObjectInputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
      // New serial form ignores extra field "currClass"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
      in.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * Serializes a {@link ModelMBeanConstructorInfo} to an {@link ObjectOutputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    private void writeObject(ObjectOutputStream out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
      if (compat)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        // Serializes this instance in the old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        ObjectOutputStream.PutField fields = out.putFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        fields.put("consDescriptor", consDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        fields.put("currClass", currClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        out.writeFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
      else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        // Serializes this instance in the new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        out.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
}