jdk/src/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java
author rriggs
Tue, 12 Nov 2013 14:03:28 -0500
changeset 21656 d4c777ccb1db
parent 14342 8435a30053c1
child 23010 6dadb192ad81
permissions -rw-r--r--
8028014: Doclint warning/error cleanup in javax.management Summary: Improve generated html by fixing doclint warnings Reviewed-by: sla, jbachorik
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
14342
8435a30053c1 7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents: 14014
diff changeset
     2
 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4156
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @author    IBM Corp.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * Copyright IBM Corp. 1999-2000.  All rights reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
package javax.management.modelmbean;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import static com.sun.jmx.defaults.JmxProperties.MODELMBEAN_LOGGER;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import com.sun.jmx.mbeanserver.GetPropertyAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.io.ObjectOutputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.io.ObjectStreamField;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.lang.reflect.Method;
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.DescriptorKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import javax.management.DescriptorAccess;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import javax.management.MBeanAttributeInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import javax.management.RuntimeOperationsException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
/**
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    51
 * <p>The ModelMBeanAttributeInfo object describes an attribute of the ModelMBean.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * It is a subclass of MBeanAttributeInfo with the addition of an associated Descriptor
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    53
 * and an implementation of the DescriptorAccess interface.</p>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    54
 *
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    55
 * <P id="descriptor">
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    56
 * The fields in the descriptor are defined, but not limited to, the following.
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    57
 * Note that when the Type in this table is Number, a String that is the decimal
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    58
 * representation of a Long can also be used.</P>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    59
 *
21656
d4c777ccb1db 8028014: Doclint warning/error cleanup in javax.management
rriggs
parents: 14342
diff changeset
    60
 * <table border="1" cellpadding="5" summary="ModelMBeanAttributeInfo Fields">
1513
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    61
 * <tr><th>Name</th><th>Type</th><th>Meaning</th></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    62
 * <tr><td>name</td><td>String</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    63
 *     <td>Attribute name.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    64
 * <tr><td>descriptorType</td><td>String</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    65
 *     <td>Must be "attribute".</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    66
 * <tr id="value-field"><td>value</td><td>Object</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    67
 *     <td>Current (cached) value for attribute.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    68
 * <tr><td>default</td><td>Object</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    69
 *     <td>Default value for attribute.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    70
 * <tr><td>displayName</td><td>String</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    71
 *     <td>Name of attribute to be used in displays.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    72
 * <tr><td>getMethod</td><td>String</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    73
 *     <td>Name of operation descriptor for get method.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    74
 * <tr><td>setMethod</td><td>String</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    75
 *     <td>Name of operation descriptor for set method.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    76
 * <tr><td>protocolMap</td><td>Descriptor</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    77
 *     <td>See the section "Protocol Map Support" in the JMX specification
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    78
 *         document.  Mappings must be appropriate for the attribute and entries
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    79
 *         can be updated or augmented at runtime.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    80
 * <tr><td>persistPolicy</td><td>String</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    81
 *     <td>One of: OnUpdate|OnTimer|NoMoreOftenThan|OnUnregister|Always|Never.
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    82
 *         See the section "MBean Descriptor Fields" in the JMX specification
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    83
 *         document.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    84
 * <tr><td>persistPeriod</td><td>Number</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    85
 *     <td>Frequency of persist cycle in seconds. Used when persistPolicy is
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    86
 *         "OnTimer" or "NoMoreOftenThan".</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    87
 * <tr><td>currencyTimeLimit</td><td>Number</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    88
 *     <td>How long <a href="#value=field">value</a> is valid: &lt;0 never,
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    89
 *         =0 always, &gt;0 seconds.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    90
 * <tr><td>lastUpdatedTimeStamp</td><td>Number</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    91
 *     <td>When <a href="#value-field">value</a> was set.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    92
 * <tr><td>visibility</td><td>Number</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    93
 *     <td>1-4 where 1: always visible, 4: rarely visible.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    94
 * <tr><td>presentationString</td><td>String</td>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    95
 *     <td>XML formatted string to allow presentation of data.</td></tr>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    96
 * </table>
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    97
 *
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    98
 * <p>The default descriptor contains the name, descriptorType and displayName
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
    99
 * fields.  The default value of the name and displayName fields is the name of
d09513aaa9da 6252609: Two different default descriptor forms defined for ModelMBeanInfoSupport
emcmanus
parents: 715
diff changeset
   100
 * the attribute.</p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * <p><b>Note:</b> because of inconsistencies in previous versions of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * this specification, it is recommended not to use negative or zero
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * values for <code>currencyTimeLimit</code>.  To indicate that a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * cached value is never valid, omit the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * <code>currencyTimeLimit</code> field.  To indicate that it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 * always valid, use a very large number for this field.</p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 * <p>The <b>serialVersionUID</b> of this class is <code>6181543027787327345L</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
@SuppressWarnings("serial")  // serialVersionUID is not constant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
public class ModelMBeanAttributeInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    extends MBeanAttributeInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    implements DescriptorAccess {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    // Serialization compatibility stuff:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    // Two serial forms are supported in this class. The selected form depends
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    // on system property "jmx.serial.form":
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    //  - "1.0" for JMX 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    //  - any other value for JMX 1.1 and higher
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    // Serial version for old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    private static final long oldSerialVersionUID = 7098036920755973145L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    // Serial version for new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    private static final long newSerialVersionUID = 6181543027787327345L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    // Serializable fields in old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    private static final ObjectStreamField[] oldSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
      new ObjectStreamField("attrDescriptor", Descriptor.class),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
      new ObjectStreamField("currClass", String.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    // Serializable fields in new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    private static final ObjectStreamField[] newSerialPersistentFields =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
      new ObjectStreamField("attrDescriptor", Descriptor.class)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    // Actual serial version and serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    private static final long serialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @serialField attrDescriptor Descriptor The {@link Descriptor}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * containing the metadata corresponding to this attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    private static final ObjectStreamField[] serialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    private static boolean compat = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            String form = AccessController.doPrivileged(act);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            compat = (form != null && form.equals("1.0"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        } catch (Exception e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            // OK: No compat with 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        if (compat) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            serialPersistentFields = oldSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            serialVersionUID = oldSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            serialPersistentFields = newSerialPersistentFields;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            serialVersionUID = newSerialVersionUID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    // END Serialization compatibility stuff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
         * @serial The {@link Descriptor} containing the metadata corresponding to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
         * this attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        private Descriptor attrDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        private final static String currClass = "ModelMBeanAttributeInfo";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
         * Constructs a ModelMBeanAttributeInfo object with a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
         * descriptor. The {@link Descriptor} of the constructed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
         * object will include fields contributed by any annotations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
         * on the {@code Method} objects that contain the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
         * DescriptorKey} meta-annotation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
         * @param name The name of the attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
         * @param description A human readable description of the attribute. Optional.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
         * @param getter The method used for reading the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
         *          May be null if the property is write-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
         * @param setter The method used for writing the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
         *          May be null if the attribute is read-only.
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 5506
diff changeset
   192
         * @exception javax.management.IntrospectionException There is a consistency
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
         * problem in the definition of this attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        public ModelMBeanAttributeInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
                                       String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
                                       Method getter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
                                       Method setter)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        throws javax.management.IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                super(name, description, getter, setter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                            ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                            "ModelMBeanAttributeInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                            "String,String,Method,Method)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                            "Entry", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                attrDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                // put getter and setter methods in operations list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                // create default descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
         * Constructs a ModelMBeanAttributeInfo object.  The {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
         * Descriptor} of the constructed object will include fields
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
         * contributed by any annotations on the {@code Method}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
         * objects that contain the {@link DescriptorKey}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
         * meta-annotation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
         * @param name The name of the attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
         * @param description A human readable description of the attribute. Optional.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
         * @param getter The method used for reading the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
         *          May be null if the property is write-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
         * @param setter The method used for writing the attribute value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
         *          May be null if the attribute is read-only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
         * @param descriptor An instance of Descriptor containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
         * appropriate metadata for this instance of the Attribute. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
         * it is null, then a default descriptor will be created.  If
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   234
         * the descriptor does not contain the field "displayName" this field is added
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   235
         * in the descriptor with its default value.
14014
da3648e13e67 8000269: Cleanup javadoc warnings
alanb
parents: 5506
diff changeset
   236
         * @exception javax.management.IntrospectionException There is a consistency
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
         * problem in the definition of this attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
         * @exception RuntimeOperationsException Wraps an
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   239
         * IllegalArgumentException. The descriptor is invalid, or descriptor
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   240
         * field "name" is not equal to name parameter, or descriptor field
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   241
         * "descriptorType" is not equal to "attribute".
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        public ModelMBeanAttributeInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                                       String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                                       Method getter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                                       Method setter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                                       Descriptor descriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        throws javax.management.IntrospectionException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                super(name, description, getter, setter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
                // put getter and setter methods in operations list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                            ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                            "ModelMBeanAttributeInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                            "String,String,Method,Method,Descriptor)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                            "Entry", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                attrDescriptor = validDescriptor(descriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
         * Constructs a ModelMBeanAttributeInfo object with a default descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
         * @param name The name of the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
         * @param type The type or class name of the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
         * @param description A human readable description of the attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
         * @param isReadable True if the attribute has a getter method, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
         * @param isWritable True if the attribute has a setter method, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
         * @param isIs True if the attribute has an "is" getter, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        public ModelMBeanAttributeInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                                       String type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                                       String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                                       boolean isReadable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                                       boolean isWritable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                                       boolean isIs)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
                super(name, type, description, isReadable, isWritable, isIs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                // create default descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                            ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                            "ModelMBeanAttributeInfo(" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                            "String,String,String,boolean,boolean,boolean)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                            "Entry", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                attrDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        /**
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   296
         * Constructs a ModelMBeanAttributeInfo object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
         * @param name The name of the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
         * @param type The type or class name of the attribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
         * @param description A human readable description of the attribute.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
         * @param isReadable True if the attribute has a getter method, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
         * @param isWritable True if the attribute has a setter method, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
         * @param isIs True if the attribute has an "is" getter, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
         * @param descriptor An instance of Descriptor containing the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
         * appropriate metadata for this instance of the Attribute. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
         * it is null then a default descriptor will be created.  If
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   307
         * the descriptor does not contain the field "displayName" this field
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   308
         * is added in the descriptor with its default value.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
         * @exception RuntimeOperationsException Wraps an
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   310
         * IllegalArgumentException. The descriptor is invalid, or descriptor
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   311
         * field "name" is not equal to name parameter, or descriptor field
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   312
         * "descriptorType" is not equal to "attribute".
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        public ModelMBeanAttributeInfo(String name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                                       String type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                                       String description,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                                       boolean isReadable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                                       boolean isWritable,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                                       boolean isIs,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                                       Descriptor descriptor)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                super(name, type, description, isReadable, isWritable, isIs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                            ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                            "ModelMBeanAttributeInfo(String,String,String," +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                            "boolean,boolean,boolean,Descriptor)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                            "Entry", name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                attrDescriptor = validDescriptor(descriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
         * Constructs a new ModelMBeanAttributeInfo object from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
         * ModelMBeanAttributeInfo Object.  A default descriptor will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
         * be created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
         * @param inInfo the ModelMBeanAttributeInfo to be duplicated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        public ModelMBeanAttributeInfo(ModelMBeanAttributeInfo inInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                super(inInfo.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                          inInfo.getType(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                          inInfo.getDescription(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                          inInfo.isReadable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                          inInfo.isWritable(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                          inInfo.isIs());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                    MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                            ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                            "ModelMBeanAttributeInfo(ModelMBeanAttributeInfo)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                            "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                Descriptor newDesc = inInfo.getDescriptor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                attrDescriptor = validDescriptor(newDesc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
         * Gets a copy of the associated Descriptor for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
         * ModelMBeanAttributeInfo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
         * @return Descriptor associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
         * ModelMBeanAttributeInfo object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
         * @see #setDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        public Descriptor getDescriptor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                        ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                        "getDescriptor()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                if (attrDescriptor == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                    attrDescriptor = validDescriptor(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
                return((Descriptor)attrDescriptor.clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        * Sets associated Descriptor (full replace) for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        * ModelMBeanAttributeDescriptor.  If the new Descriptor is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        * null, then the associated Descriptor reverts to a default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        * descriptor.  The Descriptor is validated before it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        * assigned.  If the new Descriptor is invalid, then a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        * RuntimeOperationsException wrapping an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        * IllegalArgumentException is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        * @param inDescriptor replaces the Descriptor associated with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        * ModelMBeanAttributeInfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        * @exception RuntimeOperationsException Wraps an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        * IllegalArgumentException for an invalid Descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        * @see #getDescriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        public void setDescriptor(Descriptor inDescriptor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            attrDescriptor =  validDescriptor(inDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        * Creates and returns a new ModelMBeanAttributeInfo which is a duplicate of this ModelMBeanAttributeInfo.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        * @exception RuntimeOperationsException for illegal value for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        * field Names or field Values.  If the descriptor construction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        * fails for any reason, this exception will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   411
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        public Object clone()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
            if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                MODELMBEAN_LOGGER.logp(Level.FINER,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                        ModelMBeanAttributeInfo.class.getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                        "clone()", "Entry");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                return(new ModelMBeanAttributeInfo(this));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        * Returns a human-readable version of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        * ModelMBeanAttributeInfo instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        */
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   426
        @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        public String toString()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
                "ModelMBeanAttributeInfo: " + this.getName() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
                " ; Description: " + this.getDescription() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
                " ; Types: " + this.getType() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                " ; isReadable: " + this.isReadable() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                " ; isWritable: " + this.isWritable() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                " ; Descriptor: " + this.getDescriptor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
         * Clones the passed in Descriptor, sets default values, and checks for validity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
         * If the Descriptor is invalid (for instance by having the wrong "name"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
         * this indicates programming error and a RuntimeOperationsException will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
         * The following fields will be defaulted if they are not already set:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
         * displayName=this.getName(),name=this.getName(),descriptorType = "attribute"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
         * @param in Descriptor to be checked, or null which is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
         * an empty Descriptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
         * @exception RuntimeOperationsException if Descriptor is invalid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
526
61ba2d5ea9da 6701459: Synchronization bug pattern found in javax.management.relation.RelationService
emcmanus
parents: 2
diff changeset
   453
            Descriptor clone;
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   454
            boolean defaulted = (in == null);
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   455
            if (defaulted) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
                clone = new DescriptorSupport();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
                MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                clone = (Descriptor) in.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
            //Setting defaults.
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   463
            if (defaulted && clone.getFieldValue("name")==null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                clone.setField("name", this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                MODELMBEAN_LOGGER.finer("Defaulting Descriptor name to " + this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            }
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   467
            if (defaulted && clone.getFieldValue("descriptorType")==null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                clone.setField("descriptorType", "attribute");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                MODELMBEAN_LOGGER.finer("Defaulting descriptorType to \"attribute\"");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
            if (clone.getFieldValue("displayName") == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                clone.setField("displayName",this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                MODELMBEAN_LOGGER.finer("Defaulting Descriptor displayName to " + this.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            //Checking validity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            if (!clone.isValid()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
                 throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
                    "The isValid() method of the Descriptor object itself returned false,"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                    "one or more required fields are invalid. Descriptor:" + clone.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            }
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   482
            if (!getName().equalsIgnoreCase((String)clone.getFieldValue("name"))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
                    throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
                    "The Descriptor \"name\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                     " Expected: "+ this.getName() + " , was: " + clone.getFieldValue("name"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
4156
acaa49a2768a 6851617: Remove JSR 255 (JMX API 2.0) from JDK 7
emcmanus
parents: 1513
diff changeset
   488
            if (!"attribute".equalsIgnoreCase((String)clone.getFieldValue("descriptorType"))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
                     throw new RuntimeOperationsException(new IllegalArgumentException("Invalid Descriptor argument"),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
                    "The Descriptor \"descriptorType\" field does not match the object described. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
                     " Expected: \"attribute\" ," + " was: " + clone.getFieldValue("descriptorType"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            return clone;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * Deserializes a {@link ModelMBeanAttributeInfo} from an {@link ObjectInputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    private void readObject(ObjectInputStream in)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            throws IOException, ClassNotFoundException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
      // New serial form ignores extra field "currClass"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
      in.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * Serializes a {@link ModelMBeanAttributeInfo} to an {@link ObjectOutputStream}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    private void writeObject(ObjectOutputStream out)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
      if (compat)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        // Serializes this instance in the old serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        ObjectOutputStream.PutField fields = out.putFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        fields.put("attrDescriptor", attrDescriptor);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        fields.put("currClass", currClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        out.writeFields();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
      else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
      {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        // Serializes this instance in the new serial form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        out.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
}