jdk/src/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 526 61ba2d5ea9da
child 1510 e747d3193ef2
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 526
diff changeset
     2
 * Portions Copyright 2000-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @author    IBM Corp.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * Copyright IBM Corp. 1999-2000.  All rights reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
package javax.management.modelmbean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import static com.sun.jmx.defaults.JmxProperties.MODELMBEAN_LOGGER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import com.sun.jmx.mbeanserver.GetPropertyAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.io.ObjectStreamField;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.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
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * The ModelMBeanConstructorInfo object describes a constructor of the ModelMBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * It is a subclass of MBeanConstructorInfo with the addition of an associated Descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * and an implementation of the DescriptorAccess interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * The fields in the descriptor are defined, but not limited to, the following: <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * name           : constructor name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * descriptorType : must be "operation"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * role           : must be "constructor"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * displayName    : human readable name of constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * visibility            : 1-4 where 1: always visible 4: rarely visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * presentationString :  xml formatted string to describe how to present operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *</PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * <p>The {@code persistPolicy} and {@code currencyTimeLimit} fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * are meaningless for constructors, but are not considered invalid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <p>The default descriptor will have the {@code name}, {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * descriptorType}, {@code displayName} and {@code role} fields.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * default value of the {@code name} and {@code displayName} fields is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * the name of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <p>The <b>serialVersionUID</b> of this class is <code>3862947819818064362L</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
@SuppressWarnings("serial")  // serialVersionUID is not constant
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
public class ModelMBeanConstructorInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    extends MBeanConstructorInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    implements DescriptorAccess {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    // Serialization compatibility stuff:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    // Two serial forms are supported in this class. The selected form depends
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    // on system property "jmx.serial.form":
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    //  - "1.0" for JMX 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    //  - any other value for JMX 1.1 and higher
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    // Serial version for old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    private static final long oldSerialVersionUID = -4440125391095574518L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    // Serial version for new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    private static final long newSerialVersionUID = 3862947819818064362L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    // Serializable fields in old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private static final ObjectStreamField[] oldSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
      new ObjectStreamField("consDescriptor", Descriptor.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
      new ObjectStreamField("currClass", String.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    // Serializable fields in new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    private static final ObjectStreamField[] newSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
      new ObjectStreamField("consDescriptor", Descriptor.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    // Actual serial version and serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    private static final long serialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @serialField consDescriptor Descriptor The {@link Descriptor} containing the metadata for this instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    private static final ObjectStreamField[] serialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    private static boolean compat = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            String form = AccessController.doPrivileged(act);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            compat = (form != null && form.equals("1.0"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            // OK: No compat with 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        if (compat) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            serialPersistentFields = oldSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            serialVersionUID = oldSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            serialPersistentFields = newSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            serialVersionUID = newSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    // END Serialization compatibility stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
         * @serial The {@link Descriptor} containing the metadata for this instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        private Descriptor consDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        private final static String currClass = "ModelMBeanConstructorInfo";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        * Constructs a ModelMBeanConstructorInfo object with a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        * descriptor.  The {@link Descriptor} of the constructed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        * object will include fields contributed by any annotations on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        * the {@code Constructor} object that contain the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        * DescriptorKey} meta-annotation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        * @param description A human readable description of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        * @param constructorMethod The java.lang.reflect.Constructor object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        * describing the MBean constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        public ModelMBeanConstructorInfo(String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                                         Constructor constructorMethod)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                super(description, constructorMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                            ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                            "ModelMBeanConstructorInfo(String,Constructor)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                            "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                consDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                // put getter and setter methods in constructors list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                // create default descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        * Constructs a ModelMBeanConstructorInfo object.  The {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        * Descriptor} of the constructed object will include fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        * contributed by any annotations on the {@code Constructor}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        * object that contain the {@link DescriptorKey}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        * meta-annotation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        * @param description A human readable description of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        * @param constructorMethod The java.lang.reflect.Constructor object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        * describing the ModelMBean constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        * @param descriptor An instance of Descriptor containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        * appropriate metadata for this instance of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        * ModelMBeanConstructorInfo.  If it is null, then a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        * descriptor will be created. If the descriptor does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        * contain all the following fields, the missing ones are added with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        * their default values: displayName, name, role, descriptorType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        * IllegalArgumentException. The descriptor is invalid, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        * descriptor field "name" is present but not equal to name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        * parameter, or descriptor field "descriptorType" is present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        * but not equal to "operation" or descriptor field "role" is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        * present but not equal to "constructor".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        public ModelMBeanConstructorInfo(String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                                         Constructor constructorMethod,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                                         Descriptor descriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
                super(description, constructorMethod);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                // put getter and setter methods in constructors list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                            ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                            "ModelMBeanConstructorInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                            "String,Constructor,Descriptor)", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                consDescriptor = validDescriptor(descriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        * Constructs a ModelMBeanConstructorInfo object with a default descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        * @param name The name of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        * @param description A human readable description of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        * @param signature MBeanParameterInfo object array describing the parameters(arguments) of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        public ModelMBeanConstructorInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                                         String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                                         MBeanParameterInfo[] signature)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                super(name, description, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                // create default descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                            ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                            "ModelMBeanConstructorInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                            "String,String,MBeanParameterInfo[])", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                consDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        * Constructs a ModelMBeanConstructorInfo object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        * @param name The name of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        * @param description A human readable description of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        * @param signature MBeanParameterInfo objects describing the parameters(arguments) of the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        * @param descriptor An instance of Descriptor containing the appropriate metadata
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        *                   for this instance of the MBeanConstructorInfo. If it is null then a default descriptor will be created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        * If the descriptor does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        * contain all the following fields, the missing ones are added with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        * their default values: displayName, name, role, descriptorType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        * IllegalArgumentException. The descriptor is invalid, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        * descriptor field "name" is present but not equal to name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        * parameter, or descriptor field "descriptorType" is present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        * but not equal to "operation" or descriptor field "role" is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        * present but not equal to "constructor".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        public ModelMBeanConstructorInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                                         String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                                         MBeanParameterInfo[] signature,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                                         Descriptor descriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                super(name, description, signature);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                            ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                            "ModelMBeanConstructorInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                            "String,String,MBeanParameterInfo[],Descriptor)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                            "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                consDescriptor = validDescriptor(descriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
         * Constructs a new ModelMBeanConstructorInfo object from this ModelMBeanConstructor Object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
         * @param old the ModelMBeanConstructorInfo to be duplicated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        ModelMBeanConstructorInfo(ModelMBeanConstructorInfo old)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                super(old.getName(), old.getDescription(), old.getSignature());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                            ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                            "ModelMBeanConstructorInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                            "ModelMBeanConstructorInfo)", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                consDescriptor = validDescriptor(consDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        * Creates and returns a new ModelMBeanConstructorInfo which is a duplicate of this ModelMBeanConstructorInfo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        public Object clone ()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                        ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                        "clone()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                return(new ModelMBeanConstructorInfo(this)) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
         * Returns a copy of the associated Descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
         * @return Descriptor associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
         * ModelMBeanConstructorInfo object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
         * @see #setDescriptor
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
        public Descriptor getDescriptor()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                        ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                        "getDescriptor()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            if (consDescriptor == null){
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                consDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
            return((Descriptor)consDescriptor.clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        * Sets associated Descriptor (full replace) of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        * ModelMBeanConstructorInfo.  If the new Descriptor is null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        * then the associated Descriptor reverts to a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        * descriptor.  The Descriptor is validated before it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        * assigned.  If the new Descriptor is invalid, then a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        * RuntimeOperationsException wrapping an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        * IllegalArgumentException is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        * @param inDescriptor replaces the Descriptor associated with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        * the ModelMBeanConstructor. If the descriptor does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        * contain all the following fields, the missing ones are added with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        * their default values: displayName, name, role, descriptorType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        * IllegalArgumentException.  The descriptor is invalid, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        * descriptor field "name" is present but not equal to name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        * parameter, or descriptor field "descriptorType" is present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        * but not equal to "operation" or descriptor field "role" is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        * present but not equal to "constructor".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        * @see #getDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        public void setDescriptor(Descriptor inDescriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                        ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                        "setDescriptor()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            consDescriptor = validDescriptor(inDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        * Returns a string containing the entire contents of the ModelMBeanConstructorInfo in human readable form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        public String toString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                        ModelMBeanConstructorInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                        "toString()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                String retStr =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                    "ModelMBeanConstructorInfo: " + this.getName() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                    " ; Description: " + this.getDescription() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                    " ; Descriptor: " + this.getDescriptor() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                    " ; Signature: ";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                MBeanParameterInfo[] pTypes = this.getSignature();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                for (int i=0; i < pTypes.length; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                        retStr = retStr.concat((pTypes[i]).getType() + ", ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                return retStr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
         * Clones the passed in Descriptor, sets default values, and checks for validity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
         * If the Descriptor is invalid (for instance by having the wrong "name"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
         * this indicates programming error and a RuntimeOperationsException will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
         * The following fields will be defaulted if they are not already set:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
         * displayName=this.getName(), name=this.getName(), descriptorType="operation",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
         * role="constructor"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
         * @param in Descriptor to be checked, or null which is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
         * an empty Descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
         * @exception RuntimeOperationsException if Descriptor is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
   396
           Descriptor clone;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            if (in == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                clone = new DescriptorSupport();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                clone = (Descriptor) in.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
            //Setting defaults.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            if (clone.getFieldValue("name")==null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                clone.setField("name", this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            if (clone.getFieldValue("descriptorType")==null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                clone.setField("descriptorType", "operation");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"operation\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            if (clone.getFieldValue("displayName") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                clone.setField("displayName",this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            if (clone.getFieldValue("role") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                clone.setField("role","constructor");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                MODELMBEAN_LOGGER.finer("Defaulting Descriptor role field to \"constructor\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            //Checking validity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            if (!clone.isValid()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                 throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
                    "The isValid() method of the Descriptor object itself returned false,"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
                    "one or more required fields are invalid. Descriptor:" + clone.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            if (! ((String)clone.getFieldValue("name")).equalsIgnoreCase(this.getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                    throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                    "The Descriptor \"name\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                     " Expected: "+ this.getName() + " , was: " + clone.getFieldValue("name"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            if (! ((String)clone.getFieldValue("descriptorType")).equalsIgnoreCase("operation")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                     throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                    "The Descriptor \"descriptorType\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                     " Expected: \"operation\" ," + " was: " + clone.getFieldValue("descriptorType"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
            if (! ((String)clone.getFieldValue("role")).equalsIgnoreCase("constructor")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
                     throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                    "The Descriptor \"role\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                     " Expected: \"constructor\" ," + " was: " + clone.getFieldValue("role"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            return clone;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * Deserializes a {@link ModelMBeanConstructorInfo} from an {@link ObjectInputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    private void readObject(ObjectInputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
      // New serial form ignores extra field "currClass"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
      in.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * Serializes a {@link ModelMBeanConstructorInfo} to an {@link ObjectOutputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    private void writeObject(ObjectOutputStream out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
      if (compat)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        // Serializes this instance in the old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        ObjectOutputStream.PutField fields = out.putFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
        fields.put("consDescriptor", consDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        fields.put("currClass", currClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        out.writeFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
      else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        // Serializes this instance in the new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        out.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
}