jdk/src/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 526 61ba2d5ea9da
child 1513 d09513aaa9da
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.Method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.util.logging.Level;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import javax.management.Descriptor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import javax.management.DescriptorKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import javax.management.DescriptorAccess;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import javax.management.MBeanAttributeInfo;
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 ModelMBeanAttributeInfo object describes an attribute of the ModelMBean.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * It is a subclass of MBeanAttributeInfo 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
 * The fields in the descriptor are defined, but not limited to, the following: <P>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * name           : attribute name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * descriptorType : must be "attribute"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * value          : current value for attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * default        : default value for attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * displayName    : name of attribute to be used in displays
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * getMethod      : name of operation descriptor for get method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * setMethod      : name of operation descriptor for set method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * protocolMap    : object which implements the Descriptor interface: mappings
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *                  must be appropriate for the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *                  and entries can be updated or augmented at runtime.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * persistPolicy  : OnUpdate|OnTimer|NoMoreOftenThan|OnUnregister|Always|Never
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * persistPeriod  : seconds - frequency of persist cycle. Used when persistPolicy
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *                  is "OnTimer" or "NoMoreOftenThan".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * currencyTimeLimit : how long value is valid, &lt;0 never, =0 always, &gt;0 seconds
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * lastUpdatedTimeStamp : when value was set
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * visibility     : 1-4 where 1: always visible, 4: rarely visible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * presentationString : xml formatted string to allow presentation of data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * The default descriptor contains the name, descriptorType and displayName fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * The default value of the name and displayName fields is the name of the attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * <p><b>Note:</b> because of inconsistencies in previous versions of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * this specification, it is recommended not to use negative or zero
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * values for <code>currencyTimeLimit</code>.  To indicate that a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * cached value is never valid, omit the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * <code>currencyTimeLimit</code> field.  To indicate that it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * always valid, use a very large number for this field.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <p>The <b>serialVersionUID</b> of this class is <code>6181543027787327345L</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
@SuppressWarnings("serial")  // serialVersionUID is not constant
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
public class ModelMBeanAttributeInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    extends MBeanAttributeInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    implements DescriptorAccess {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    // Serialization compatibility stuff:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    // Two serial forms are supported in this class. The selected form depends
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    // on system property "jmx.serial.form":
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    //  - "1.0" for JMX 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    //  - any other value for JMX 1.1 and higher
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    // Serial version for old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private static final long oldSerialVersionUID = 7098036920755973145L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    // Serial version for new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    private static final long newSerialVersionUID = 6181543027787327345L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    // Serializable fields in old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    private static final ObjectStreamField[] oldSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
      new ObjectStreamField("attrDescriptor", Descriptor.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
      new ObjectStreamField("currClass", String.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    // Serializable fields in new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    private static final ObjectStreamField[] newSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
      new ObjectStreamField("attrDescriptor", Descriptor.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    // Actual serial version and serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    private static final long serialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @serialField attrDescriptor Descriptor The {@link Descriptor}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * containing the metadata corresponding to this attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    private static final ObjectStreamField[] serialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    private static boolean compat = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            String form = AccessController.doPrivileged(act);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            compat = (form != null && form.equals("1.0"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            // OK: No compat with 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        if (compat) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            serialPersistentFields = oldSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
            serialVersionUID = oldSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            serialPersistentFields = newSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            serialVersionUID = newSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    // END Serialization compatibility stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
         * @serial The {@link Descriptor} containing the metadata corresponding to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
         * this attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        private Descriptor attrDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        private final static String currClass = "ModelMBeanAttributeInfo";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
         * Constructs a ModelMBeanAttributeInfo object with a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
         * descriptor. The {@link Descriptor} of the constructed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
         * object will include fields contributed by any annotations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
         * on the {@code Method} objects that contain the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
         * DescriptorKey} meta-annotation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
         * @param name The name of the attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
         * @param description A human readable description of the attribute. Optional.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
         * @param getter The method used for reading the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
         *          May be null if the property is write-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
         * @param setter The method used for writing the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
         *          May be null if the attribute is read-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
         * @exception IntrospectionException There is a consistency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
         * problem in the definition of this attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        public ModelMBeanAttributeInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                                       String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                                       Method getter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                                       Method setter)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        throws javax.management.IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                super(name, description, getter, setter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                            ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                            "ModelMBeanAttributeInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                            "String,String,Method,Method)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                            "Entry", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                attrDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                // put getter and setter methods in operations list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                // create default descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
         * Constructs a ModelMBeanAttributeInfo object.  The {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
         * Descriptor} of the constructed object will include fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
         * contributed by any annotations on the {@code Method}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
         * objects that contain the {@link DescriptorKey}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
         * meta-annotation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
         * @param name The name of the attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
         * @param description A human readable description of the attribute. Optional.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
         * @param getter The method used for reading the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
         *          May be null if the property is write-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
         * @param setter The method used for writing the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
         *          May be null if the attribute is read-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
         * @param descriptor An instance of Descriptor containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
         * appropriate metadata for this instance of the Attribute. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
         * it is null, then a default descriptor will be created.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
         * the descriptor does not contain all the following fields,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
         * the missing ones are added with their default values:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
         * displayName, name, descriptorType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
         * @exception IntrospectionException There is a consistency
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
         * problem in the definition of this attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
         * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
         * IllegalArgumentException. The descriptor is invalid, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
         * descriptor field "name" is present but not equal to name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
         * parameter, or descriptor field "descriptorType" is present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
         * but not equal to "attribute".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        public ModelMBeanAttributeInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                                       String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                                       Method getter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                                       Method setter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                                       Descriptor descriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        throws javax.management.IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                super(name, description, getter, setter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                // put getter and setter methods in operations list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                            ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                            "ModelMBeanAttributeInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                            "String,String,Method,Method,Descriptor)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                            "Entry", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                attrDescriptor = validDescriptor(descriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        }
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 ModelMBeanAttributeInfo object with a default descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
         * @param name The name of the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
         * @param type The type or class name of the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
         * @param description A human readable description of the attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
         * @param isReadable True if the attribute has a getter method, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
         * @param isWritable True if the attribute has a setter method, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
         * @param isIs True if the attribute has an "is" getter, false otherwise.
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 ModelMBeanAttributeInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                                       String type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                                       String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                                       boolean isReadable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                                       boolean isWritable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                                       boolean isIs)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                super(name, type, description, isReadable, isWritable, isIs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                // create default descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                            ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                            "ModelMBeanAttributeInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                            "String,String,String,boolean,boolean,boolean)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                            "Entry", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                attrDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
         * Constructs a ModelMBeanAttributeInfo object with a default descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
         * @param name The name of the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
         * @param type The type or class name of the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
         * @param description A human readable description of the attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
         * @param isReadable True if the attribute has a getter method, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
         * @param isWritable True if the attribute has a setter method, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
         * @param isIs True if the attribute has an "is" getter, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
         * @param descriptor An instance of Descriptor containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
         * appropriate metadata for this instance of the Attribute. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
         * it is null then a default descriptor will be created.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
         * the descriptor does not contain all the following fields,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
         * the missing ones are added with their default values:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
         * displayName, name, descriptorType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
         * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
         * IllegalArgumentException. The descriptor is invalid, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
         * descriptor field "name" is present but not equal to name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
         * parameter, or descriptor field "descriptorType" is present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
         * but not equal to "attribute".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        public ModelMBeanAttributeInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                                       String type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                                       String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                                       boolean isReadable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                                       boolean isWritable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                                       boolean isIs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                                       Descriptor descriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                super(name, type, description, isReadable, isWritable, isIs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                            ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                            "ModelMBeanAttributeInfo(String,String,String," +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                            "boolean,boolean,boolean,Descriptor)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                            "Entry", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                attrDescriptor = validDescriptor(descriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
         * Constructs a new ModelMBeanAttributeInfo object from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
         * ModelMBeanAttributeInfo Object.  A default descriptor will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
         * be created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
         * @param inInfo the ModelMBeanAttributeInfo to be duplicated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        public ModelMBeanAttributeInfo(ModelMBeanAttributeInfo inInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                super(inInfo.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                          inInfo.getType(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                          inInfo.getDescription(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                          inInfo.isReadable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                          inInfo.isWritable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                          inInfo.isIs());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                            ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                            "ModelMBeanAttributeInfo(ModelMBeanAttributeInfo)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                            "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                Descriptor newDesc = inInfo.getDescriptor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                attrDescriptor = validDescriptor(newDesc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
         * Gets a copy of the associated Descriptor for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
         * ModelMBeanAttributeInfo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
         * @return Descriptor associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
         * ModelMBeanAttributeInfo object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
         * @see #setDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        public Descriptor getDescriptor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                        ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                        "getDescriptor()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                if (attrDescriptor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                    attrDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                return((Descriptor)attrDescriptor.clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        * Sets associated Descriptor (full replace) for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        * ModelMBeanAttributeDescriptor.  If the new Descriptor is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        * null, then the associated Descriptor reverts to a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        * descriptor.  The Descriptor is validated before it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        * assigned.  If the new Descriptor is invalid, then a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        * RuntimeOperationsException wrapping an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        * IllegalArgumentException is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        * If the descriptor does not contain all the following fields, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        * missing ones are added with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        * their default values: displayName, name, descriptorType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        * @param inDescriptor replaces the Descriptor associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        * ModelMBeanAttributeInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        * IllegalArgumentException for an invalid Descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        * @see #getDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        public void setDescriptor(Descriptor inDescriptor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            attrDescriptor =  validDescriptor(inDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        * Creates and returns a new ModelMBeanAttributeInfo which is a duplicate of this ModelMBeanAttributeInfo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        * @exception RuntimeOperationsException for illegal value for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        * field Names or field Values.  If the descriptor construction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        * fails for any reason, this exception will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        public Object clone()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                        ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
                        "clone()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                return(new ModelMBeanAttributeInfo(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        * Returns a human-readable version of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        * ModelMBeanAttributeInfo instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        public String toString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                "ModelMBeanAttributeInfo: " + this.getName() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                " ; Description: " + this.getDescription() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                " ; Types: " + this.getType() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                " ; isReadable: " + this.isReadable() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                " ; isWritable: " + this.isWritable() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                " ; Descriptor: " + this.getDescriptor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
         * Clones the passed in Descriptor, sets default values, and checks for validity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
         * If the Descriptor is invalid (for instance by having the wrong "name"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
         * this indicates programming error and a RuntimeOperationsException will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
         * The following fields will be defaulted if they are not already set:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
         * displayName=this.getName(),name=this.getName(),descriptorType = "attribute"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
         * @param in Descriptor to be checked, or null which is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
         * an empty Descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
         * @exception RuntimeOperationsException if Descriptor is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
   435
            Descriptor clone;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            if (in == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                clone = new DescriptorSupport();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                clone = (Descriptor) in.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
            //Setting defaults.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
            if (clone.getFieldValue("name")==null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                clone.setField("name", this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
            if (clone.getFieldValue("descriptorType")==null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                clone.setField("descriptorType", "attribute");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"attribute\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
            if (clone.getFieldValue("displayName") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                clone.setField("displayName",this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            //Checking validity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            if (!clone.isValid()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                 throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
                    "The isValid() method of the Descriptor object itself returned false,"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
                    "one or more required fields are invalid. Descriptor:" + clone.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            if (! ((String)clone.getFieldValue("name")).equalsIgnoreCase(this.getName())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                    throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                    "The Descriptor \"name\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                     " Expected: "+ this.getName() + " , was: " + clone.getFieldValue("name"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
            if (! ((String)clone.getFieldValue("descriptorType")).equalsIgnoreCase("attribute")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
                     throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                    "The Descriptor \"descriptorType\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                     " Expected: \"attribute\" ," + " was: " + clone.getFieldValue("descriptorType"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            return clone;
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * Deserializes a {@link ModelMBeanAttributeInfo} from an {@link ObjectInputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    private void readObject(ObjectInputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
      // New serial form ignores extra field "currClass"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
      in.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * Serializes a {@link ModelMBeanAttributeInfo} to an {@link ObjectOutputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    private void writeObject(ObjectOutputStream out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
      if (compat)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        // Serializes this instance in the old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        ObjectOutputStream.PutField fields = out.putFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        fields.put("attrDescriptor", attrDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        fields.put("currClass", currClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        out.writeFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
      else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
        // Serializes this instance in the new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        out.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
}