FileDocCategorySizeDatePackage
MBeanOperationInfo.javaAPI DocJava SE 5 API7240Fri Aug 26 14:57:32 BST 2005javax.management

MBeanOperationInfo

public class MBeanOperationInfo extends MBeanFeatureInfo implements Cloneable, Serializable
Describes a management operation exposed by an MBean. Instances of this class are immutable. Subclasses may be mutable but this is not recommended.
since
1.5

Fields Summary
static final long
serialVersionUID
static final MBeanOperationInfo[]
NO_OPERATIONS
public static final int
INFO
Indicates that the operation is read-like, it basically returns information.
public static final int
ACTION
Indicates 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_INFO
Indicates that the operation is both read-like and write-like.
public static final int
UNKNOWN
Indicates that the operation has an "unknown" nature.
private final String
type
private final MBeanParameterInfo[]
signature
private final int
impact
private final transient boolean
immutable
Constructors Summary
public MBeanOperationInfo(String description, Method method)
Constructs an MBeanOperationInfo object.

param
method The java.lang.reflect.Method object describing the MBean operation.
param
description A human readable description of the operation.



                               
      
			       
	      

	this(method.getName(),
	     description,
	     methodSignature(method),
	     method.getReturnType().getName(),
	     UNKNOWN);
    
public MBeanOperationInfo(String name, String description, MBeanParameterInfo[] signature, String type, int impact)
Constructs an MBeanOperationInfo object.

param
name The name of the method.
param
description A human readable description of the operation.
param
signature MBeanParameterInfo objects describing the parameters(arguments) of the method. This may be null with the same effect as a zero-length array.
param
type The type of the method's return value.
param
impact The impact of the method, one of INFO, ACTION, ACTION_INFO, UNKNOWN.


	super(name, description);

	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.immutable =
	    MBeanInfo.isImmutableClass(this.getClass(),
				       MBeanOperationInfo.class);
    
Methods Summary
public java.lang.Objectclone()

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 booleanequals(java.lang.Object o)
Compare this MBeanOperationInfo to another.

param
o the object to compare to.
return
true iff o is an MBeanOperationInfo such that its {@link #getName()}, {@link #getReturnType()}, {@link #getDescription()}, {@link #getImpact()}, and {@link #getSignature()} values are equal (not necessarily identical) to those of this MBeanConstructorInfo. Two signature arrays are equal if their elements are pairwise equal.

	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()));
    
private javax.management.MBeanParameterInfo[]fastGetSignature()

	if (immutable)
	    return signature;
	else
	    return getSignature();
    
public intgetImpact()
Returns the impact of the method, one of INFO, ACTION, ACTION_INFO, UNKNOWN.

return
the impact code.

	return impact;
    
public java.lang.StringgetReturnType()
Returns the type of the method's return value.

return
the return type.

	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.

return
An array of MBeanParameterInfo objects.

	if (signature.length == 0)
	    return signature;
	else
	    return (MBeanParameterInfo[]) signature.clone();
    
public inthashCode()

	return getName().hashCode() ^ getReturnType().hashCode();
    
private static javax.management.MBeanParameterInfo[]methodSignature(java.lang.reflect.Method method)

	final Class[] classes = method.getParameterTypes();
	final MBeanParameterInfo[] params =
	    new MBeanParameterInfo[classes.length];

	for (int i = 0; i < classes.length; i++) {
	    final String pn = "p" + (i + 1);
	    params[i] = new MBeanParameterInfo(pn, classes[i].getName(), "");
	}

	return params;