jdk/src/share/classes/javax/management/MBeanOperationInfo.java
changeset 4156 acaa49a2768a
parent 1699 3611e5fd6da5
child 5506 202f599c92aa
equal deleted inserted replaced
4155:460e37d40f12 4156:acaa49a2768a
    46         new MBeanOperationInfo[0];
    46         new MBeanOperationInfo[0];
    47 
    47 
    48     /**
    48     /**
    49      * Indicates that the operation is read-like:
    49      * Indicates that the operation is read-like:
    50      * it returns information but does not change any state.
    50      * it returns information but does not change any state.
    51      * @see Impact#INFO
       
    52      */
    51      */
    53     public static final int INFO = 0;
    52     public static final int INFO = 0;
    54 
    53 
    55     /**
    54     /**
    56      * Indicates that the operation is write-like: it has an effect but does
    55      * Indicates that the operation is write-like: it has an effect but does
    57      * not return any information from the MBean.
    56      * not return any information from the MBean.
    58      * @see Impact#ACTION
       
    59      */
    57      */
    60     public static final int ACTION = 1;
    58     public static final int ACTION = 1;
    61 
    59 
    62     /**
    60     /**
    63      * Indicates that the operation is both read-like and write-like:
    61      * Indicates that the operation is both read-like and write-like:
    64      * it has an effect, and it also returns information from the MBean.
    62      * it has an effect, and it also returns information from the MBean.
    65      * @see Impact#ACTION_INFO
       
    66      */
    63      */
    67     public static final int ACTION_INFO = 2;
    64     public static final int ACTION_INFO = 2;
    68 
    65 
    69     /**
    66     /**
    70      * Indicates that the impact of the operation is unknown or cannot be
    67      * Indicates that the impact of the operation is unknown or cannot be
    71      * expressed using one of the other values.
    68      * expressed using one of the other values.
    72      * @see Impact#UNKNOWN
       
    73      */
    69      */
    74     public static final int UNKNOWN = 3;
    70     public static final int UNKNOWN = 3;
    75 
    71 
    76     /**
    72     /**
    77      * @serial The method's return value.
    73      * @serial The method's return value.
   111         this(method.getName(),
   107         this(method.getName(),
   112              description,
   108              description,
   113              methodSignature(method),
   109              methodSignature(method),
   114              method.getReturnType().getName(),
   110              method.getReturnType().getName(),
   115              UNKNOWN,
   111              UNKNOWN,
   116              Introspector.descriptorForElement(method, false));
   112              Introspector.descriptorForElement(method));
   117     }
   113     }
   118 
   114 
   119     /**
   115     /**
   120      * Constructs an <CODE>MBeanOperationInfo</CODE> object.
   116      * Constructs an <CODE>MBeanOperationInfo</CODE> object.
   121      *
   117      *
   183      * No deeper cloning of any internal field is made.</p>
   179      * No deeper cloning of any internal field is made.</p>
   184      *
   180      *
   185      * <p>Since this class is immutable, cloning is chiefly of interest
   181      * <p>Since this class is immutable, cloning is chiefly of interest
   186      * to subclasses.</p>
   182      * to subclasses.</p>
   187      */
   183      */
       
   184      @Override
   188      public Object clone () {
   185      public Object clone () {
   189          try {
   186          try {
   190              return super.clone() ;
   187              return super.clone() ;
   191          } catch (CloneNotSupportedException e) {
   188          } catch (CloneNotSupportedException e) {
   192              // should not happen as this class is cloneable
   189              // should not happen as this class is cloneable
   255      */
   252      */
   256     public int getImpact() {
   253     public int getImpact() {
   257         return impact;
   254         return impact;
   258     }
   255     }
   259 
   256 
       
   257     @Override
   260     public String toString() {
   258     public String toString() {
   261         String impactString;
   259         String impactString;
   262         switch (getImpact()) {
   260         switch (getImpact()) {
   263         case ACTION: impactString = "action"; break;
   261         case ACTION: impactString = "action"; break;
   264         case ACTION_INFO: impactString = "action/info"; break;
   262         case ACTION_INFO: impactString = "action/info"; break;
   286      * #getDescription()}, {@link #getImpact()}, {@link #getDescriptor()}
   284      * #getDescription()}, {@link #getImpact()}, {@link #getDescriptor()}
   287      * and {@link #getSignature()} values are equal (not necessarily identical)
   285      * and {@link #getSignature()} values are equal (not necessarily identical)
   288      * to those of this MBeanConstructorInfo.  Two signature arrays
   286      * to those of this MBeanConstructorInfo.  Two signature arrays
   289      * are equal if their elements are pairwise equal.
   287      * are equal if their elements are pairwise equal.
   290      */
   288      */
       
   289     @Override
   291     public boolean equals(Object o) {
   290     public boolean equals(Object o) {
   292         if (o == this)
   291         if (o == this)
   293             return true;
   292             return true;
   294         if (!(o instanceof MBeanOperationInfo))
   293         if (!(o instanceof MBeanOperationInfo))
   295             return false;
   294             return false;
   325             new MBeanParameterInfo[classes.length];
   324             new MBeanParameterInfo[classes.length];
   326         assert(classes.length == annots.length);
   325         assert(classes.length == annots.length);
   327 
   326 
   328         for (int i = 0; i < classes.length; i++) {
   327         for (int i = 0; i < classes.length; i++) {
   329             Descriptor d = Introspector.descriptorForAnnotations(annots[i]);
   328             Descriptor d = Introspector.descriptorForAnnotations(annots[i]);
   330             String description = Introspector.descriptionForParameter(annots[i]);
   329             final String pn = "p" + (i + 1);
   331             if (description == null)
   330             params[i] =
   332                 description = "";
   331                 new MBeanParameterInfo(pn, classes[i].getName(), "", d);
   333             String name = Introspector.nameForParameter(annots[i]);
       
   334             if (name == null)
       
   335                 name = "p" + (i + 1);
       
   336             params[i] = new MBeanParameterInfo(
       
   337                     name, classes[i].getName(), description, d);
       
   338         }
   332         }
   339 
   333 
   340         return params;
   334         return params;
   341     }
   335     }
   342 }
   336 }