MBeanOperationInfopublic class MBeanOperationInfo extends MBeanFeatureInfo implements CloneableDescribes a management operation exposed by an MBean. Instances of
this class are immutable. Subclasses may be mutable but this is
not recommended. |
Fields Summary |
---|
static final long | serialVersionUID | static final MBeanOperationInfo[] | NO_OPERATIONS | public static final int | INFOIndicates that the operation is read-like,
it basically returns information. | public static final int | ACTIONIndicates that the operation is a write-like,
and would modify the MBean in some way, typically by writing some value
or changing a configuration. | public static final int | ACTION_INFOIndicates that the operation is both read-like and write-like. | public static final int | UNKNOWNIndicates that the operation has an "unknown" nature. | private final String | type | private final MBeanParameterInfo[] | signature | private final int | impact | private final transient boolean | arrayGettersSafe |
Constructors Summary |
---|
public MBeanOperationInfo(String description, Method method)Constructs an MBeanOperationInfo object. The
{@link Descriptor} of the constructed object will include
fields contributed by any annotations on the {@code Method}
object that contain the {@link DescriptorKey} meta-annotation.
this(method.getName(),
description,
methodSignature(method),
method.getReturnType().getName(),
UNKNOWN,
Introspector.descriptorForElement(method));
| public MBeanOperationInfo(String name, String description, MBeanParameterInfo[] signature, String type, int impact)Constructs an MBeanOperationInfo object.
this(name, description, signature, type, impact, (Descriptor) null);
| public MBeanOperationInfo(String name, String description, MBeanParameterInfo[] signature, String type, int impact, Descriptor descriptor)Constructs an MBeanOperationInfo object.
super(name, description, descriptor);
if (signature == null || signature.length == 0)
signature = MBeanParameterInfo.NO_PARAMS;
else
signature = (MBeanParameterInfo[]) signature.clone();
this.signature = signature;
this.type = type;
this.impact = impact;
this.arrayGettersSafe =
MBeanInfo.arrayGettersSafe(this.getClass(),
MBeanOperationInfo.class);
|
Methods Summary |
---|
public java.lang.Object | clone()Returns a shallow clone of this instance.
The clone is obtained by simply calling super.clone(),
thus calling the default native shallow cloning mechanism
implemented by Object.clone().
No deeper cloning of any internal field is made.
Since this class is immutable, cloning is chiefly of interest
to subclasses.
try {
return super.clone() ;
} catch (CloneNotSupportedException e) {
// should not happen as this class is cloneable
return null;
}
| public boolean | equals(java.lang.Object o)Compare this MBeanOperationInfo to another.
if (o == this)
return true;
if (!(o instanceof MBeanOperationInfo))
return false;
MBeanOperationInfo p = (MBeanOperationInfo) o;
return (p.getName().equals(getName()) &&
p.getReturnType().equals(getReturnType()) &&
p.getDescription().equals(getDescription()) &&
p.getImpact() == getImpact() &&
Arrays.equals(p.fastGetSignature(), fastGetSignature()) &&
p.getDescriptor().equals(getDescriptor()));
| private javax.management.MBeanParameterInfo[] | fastGetSignature()
if (arrayGettersSafe) {
// if signature is null simply return an empty array .
// see getSignature() above.
//
if (signature == null)
return MBeanParameterInfo.NO_PARAMS;
else return signature;
} else return getSignature();
| public int | getImpact()Returns the impact of the method, one of
INFO , ACTION , ACTION_INFO , UNKNOWN .
return impact;
| public java.lang.String | getReturnType()Returns the type of the method's return value.
return type;
| public javax.management.MBeanParameterInfo[] | getSignature()Returns the list of parameters for this operation. Each
parameter is described by an MBeanParameterInfo
object.
The returned array is a shallow copy of the internal array,
which means that it is a copy of the internal array of
references to the MBeanParameterInfo objects but
that each referenced MBeanParameterInfo object is
not copied.
// If MBeanOperationInfo was created in our implementation,
// signature cannot be null - because our constructors replace
// null with MBeanParameterInfo.NO_PARAMS;
//
// However, signature could be null if an MBeanOperationInfo is
// deserialized from a byte array produced by another implementation.
// This is not very likely but possible, since the serial form says
// nothing against it. (see 6373150)
//
if (signature == null)
// if signature is null simply return an empty array .
//
return MBeanParameterInfo.NO_PARAMS;
else if (signature.length == 0)
return signature;
else
return (MBeanParameterInfo[]) signature.clone();
| public int | hashCode()
return getName().hashCode() ^ getReturnType().hashCode();
| private static javax.management.MBeanParameterInfo[] | methodSignature(java.lang.reflect.Method method)
final Class[] classes = method.getParameterTypes();
final Annotation[][] annots = method.getParameterAnnotations();
return parameters(classes, annots);
| static javax.management.MBeanParameterInfo[] | parameters(java.lang.Class[] classes, java.lang.annotation.Annotation[][] annots)
final MBeanParameterInfo[] params =
new MBeanParameterInfo[classes.length];
assert(classes.length == annots.length);
for (int i = 0; i < classes.length; i++) {
Descriptor d = Introspector.descriptorForAnnotations(annots[i]);
final String pn = "p" + (i + 1);
params[i] =
new MBeanParameterInfo(pn, classes[i].getName(), "", d);
}
return params;
| public java.lang.String | toString()
String impactString;
switch (getImpact()) {
case ACTION: impactString = "action"; break;
case ACTION_INFO: impactString = "action/info"; break;
case INFO: impactString = "info"; break;
case UNKNOWN: impactString = "unknown"; break;
default: impactString = "(" + getImpact() + ")";
}
return getClass().getName() + "[" +
"description=" + getDescription() + ", " +
"name=" + getName() + ", " +
"returnType=" + getReturnType() + ", " +
"signature=" + Arrays.asList(fastGetSignature()) + ", " +
"impact=" + impactString + ", " +
"descriptor=" + getDescriptor() +
"]";
|
|