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