ModelMBeanOperationInfopublic class ModelMBeanOperationInfo extends MBeanOperationInfo implements DescriptorAccessThe ModelMBeanOperationInfo object describes a management operation of the ModelMBean.
It is a subclass of MBeanOperationInfo with the addition of an associated Descriptor
and an implementation of the DescriptorAccess interface.
The fields in the descriptor are defined, but not limited to, the following:
name : operation name
descriptorType : must be "operation"
class : class where method is defined (fully qualified)
role : must be "operation", "getter", or "setter
targetObject : object on which to execute this method
targetType : type of object reference for targetObject. Can be: ObjectReference | Handle | EJBHandle | IOR | RMIReference.
value : cached value for operation
currencyTimeLimit : how long cached value is valid
lastUpdatedTimeStamp : when cached value was set
visibility : 1-4 where 1: always visible 4: rarely visible
presentationString : xml formatted string to describe how to present operation
The default descriptor will have name, descriptorType, displayName and role fields set.
Note: because of inconsistencies in previous versions of
this specification, it is recommended not to use negative or zero
values for currencyTimeLimit . To indicate that a
cached value is never valid, omit the
currencyTimeLimit field. To indicate that it is
always valid, use a very large number for this field.
The serialVersionUID of this class is 6532732096650090465L . |
Fields Summary |
---|
private static final long | oldSerialVersionUID | private static final long | newSerialVersionUID | private static final ObjectStreamField[] | oldSerialPersistentFields | private static final ObjectStreamField[] | newSerialPersistentFields | private static final long | serialVersionUID | private static final ObjectStreamField[] | serialPersistentFields | private static boolean | compat | private Descriptor | operationDescriptor | private static final String | currClass |
Constructors Summary |
---|
public ModelMBeanOperationInfo(String description, Method operationMethod)Constructs a ModelMBeanOperationInfo object with a default
descriptor. 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.
super(description, operationMethod);
// create default descriptor
if (tracing())
{
trace("ModelMBeanOperationInfo(String,Method)","Executed");
}
operationDescriptor = createDefaultDescriptor();
| public ModelMBeanOperationInfo(String description, Method operationMethod, Descriptor descriptor)Constructs a ModelMBeanOperationInfo 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.
super(description, operationMethod);
if (tracing())
{
trace("ModelMBeanOperationInfo(String,Method,Descriptor)","Executed");
}
if (descriptor == null)
{
if (tracing())
{
trace("ModelMBeanOperationInfo()","Received null for new descriptor value, setting descriptor to default values");
}
operationDescriptor = createDefaultDescriptor();
} else
{
if (isValid(descriptor))
{
operationDescriptor = (Descriptor) descriptor.clone();
} else
{
operationDescriptor = createDefaultDescriptor();
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid descriptor passed in parameter"), ("Exception occurred in ModelMBeanOperationInfo constructor"));
}
}
| public ModelMBeanOperationInfo(String name, String description, MBeanParameterInfo[] signature, String type, int impact)Constructs a ModelMBeanOperationInfo object with a default descriptor.
super(name, description, signature, type, impact);
// create default descriptor
if (tracing())
{
trace("ModelMBeanOperationInfo(String,String,MBeanParameterInfo[],String,int)","Executed");
}
operationDescriptor = createDefaultDescriptor();
| public ModelMBeanOperationInfo(String name, String description, MBeanParameterInfo[] signature, String type, int impact, Descriptor descriptor)Constructs a ModelMBeanOperationInfo object.
super(name, description, signature, type, impact);
if (tracing())
{
trace("ModelMBeanOperationInfo(String,String,MBeanParameterInfo[],String,int,Descriptor)","Executed");
}
if (descriptor == null)
{
if (tracing())
{
trace("ModelMBeanOperationInfo()","Received null for new descriptor value, setting descriptor to default values");
}
operationDescriptor = createDefaultDescriptor();
} else
{
if (isValid(descriptor))
{
operationDescriptor = (Descriptor) descriptor.clone();
} else
{
operationDescriptor = createDefaultDescriptor();
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid descriptor passed in parameter"), ("Exception occurred in ModelMBeanOperationInfo constructor"));
}
}
| public ModelMBeanOperationInfo(ModelMBeanOperationInfo inInfo)Constructs a new ModelMBeanOperationInfo object from this ModelMBeanOperation Object.
super(inInfo.getName(),
inInfo.getDescription(),
inInfo.getSignature(),
inInfo.getReturnType(),
inInfo.getImpact());
if (tracing())
{
trace("ModelMBeanOperationInfo(ModelMBeanOperationInfo)","Executed");
}
Descriptor newDesc = inInfo.getDescriptor();
if (newDesc == null)
{
operationDescriptor = createDefaultDescriptor();
} else
{
if (isValid(newDesc))
{
operationDescriptor = (Descriptor) newDesc.clone();
} else
{
operationDescriptor = createDefaultDescriptor();
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid descriptor passed in parameter"), ("Exception occurred in ModelMBeanOperationInfo constructor"));
}
}
|
Methods Summary |
---|
public java.lang.Object | clone()Creates and returns a new ModelMBeanOperationInfo which is a duplicate of this ModelMBeanOperationInfo.
if (tracing())
{
trace("ModelMBeanOperationInfo.clone()","Executed");
}
return(new ModelMBeanOperationInfo(this)) ;
| private javax.management.Descriptor | createDefaultDescriptor()Creates default descriptor for operation as follows:
descriptorType=operation,role=operation, name=this.getName(),displayname=this.getName().
if (tracing())
{
trace("ModelMBeanOperationInfo.createDefaultDescriptor()","Executed");
}
return new DescriptorSupport(new String[] {"descriptorType=operation",
("name=" + this.getName()),
"role=operation",
("displayname=" + this.getName())});
| public javax.management.Descriptor | getDescriptor()Returns a copy of the associated Descriptor of the
ModelMBeanOperationInfo.
if (tracing())
{
trace("ModelMBeanOperationInfo.getDescriptor()","Executed");
}
if (operationDescriptor == null)
{
operationDescriptor = createDefaultDescriptor();
}
return((Descriptor) operationDescriptor.clone());
| private boolean | isValid(javax.management.Descriptor inDesc)Tests that the descriptor is valid and adds appropriate
default fields not already specified. Field values must be
correct for field names. descriptorType field must be
"operation". We do not check the targetType because a
custom implementation of ModelMBean could recognize
additional types beyond the "standard" ones. The following
fields will be defaulted if they are not already set:
role=operation,displayName=this.getName()
boolean results = true;
String badField = "none";
// if name != this.getName
// if (descriptorType != operation)
// look for displayName, persistPolicy, visibility and add in
if (inDesc == null)
{
results = false;
}
else if (!inDesc.isValid())
{ // checks for empty descriptors, null,
// checks for empty name and descriptorType
// and valid values for fields.
results = false;
} else
{
if (! ((String)inDesc.getFieldValue("name")).equalsIgnoreCase(this.getName()))
{
results = false;
}
if (! ((String)inDesc.getFieldValue("descriptorType")).equalsIgnoreCase("operation"))
{
results = false;
}
Object roleValue = inDesc.getFieldValue("role");
if (roleValue == null)
{
inDesc.setField("role","operation");
} else {
final String role = (String)roleValue;
if (!(role.equalsIgnoreCase("operation")
|| role.equalsIgnoreCase("setter")
|| role.equalsIgnoreCase("getter"))) {
results = false;
badField="role";
}
}
Object targetValue = inDesc.getFieldValue("targetType");
if (targetValue != null) {
if (!(targetValue instanceof java.lang.String)) {
results = false;
badField="targetType";
}
}
if ((inDesc.getFieldValue("displayName")) == null)
{
inDesc.setField("displayName",this.getName());
}
}
if (tracing()) trace("isValid()",("Returning " + results + ": Invalid field is " + badField));
return results;
| private void | readObject(java.io.ObjectInputStream in)Deserializes a {@link ModelMBeanOperationInfo} from an {@link ObjectInputStream}.
// New serial form ignores extra field "currClass"
in.defaultReadObject();
| public void | setDescriptor(javax.management.Descriptor inDescriptor)Sets associated Descriptor (full replace) for the
ModelMBeanOperationInfo If the new Descriptor is null, then
the associated Descriptor reverts to a default descriptor.
The Descriptor is validated before it is assigned. If the
new Descriptor is invalid, then a
RuntimeOperationsException wrapping an
IllegalArgumentException is thrown.
if (tracing())
{
trace("ModelMBeanOperationInfo.setDescriptor(Descriptor)","Executed");
}
if (inDescriptor == null)
{
if (tracing())
{
trace("ModelMBeanOperationInfo.setDescriptor()","Received null for new descriptor value, setting descriptor to default values");
}
operationDescriptor = createDefaultDescriptor();
} else
{
if (isValid(inDescriptor))
{
operationDescriptor = (Descriptor) inDescriptor.clone();
} else
{
throw new RuntimeOperationsException(new IllegalArgumentException("Invalid descriptor passed in parameter"), ("Exception occurred in ModelMBeanOperationInfo setDescriptor"));
}
}
| public java.lang.String | toString()Returns a string containing the entire contents of the ModelMBeanOperationInfo in human readable form.
if (tracing())
{
trace("ModelMBeanConstructorInfo.toString()","Executed");
}
String retStr =
"ModelMBeanOperationInfo: " + this.getName() +
" ; Description: " + this.getDescription() +
" ; Descriptor: " + this.getDescriptor() +
" ; ReturnType: " + this.getReturnType() +
" ; Signature: ";
MBeanParameterInfo[] pTypes = this.getSignature();
for (int i=0; i < pTypes.length; i++)
{
retStr = retStr.concat((pTypes[i]).getType() + ", ");
}
return retStr;
| private void | trace(java.lang.String inClass, java.lang.String inMethod, java.lang.String inText)
// System.out.println("TRACE: " + inClass + ":" + inMethod + ": " + inText);
Trace.send(Trace.LEVEL_TRACE, Trace.INFO_MODELMBEAN, inClass,
inMethod, Integer.toHexString(this.hashCode()) + " " + inText);
| private void | trace(java.lang.String inMethod, java.lang.String inText)
trace(currClass, inMethod, inText);
| private boolean | tracing()
// return false;
return Trace.isSelected(Trace.LEVEL_TRACE, Trace.INFO_MODELMBEAN);
| private void | writeObject(java.io.ObjectOutputStream out)Serializes a {@link ModelMBeanOperationInfo} to an {@link ObjectOutputStream}.
if (compat)
{
// Serializes this instance in the old serial form
//
ObjectOutputStream.PutField fields = out.putFields();
fields.put("operationDescriptor", operationDescriptor);
fields.put("currClass", currClass);
out.writeFields();
}
else
{
// Serializes this instance in the new serial form
//
out.defaultWriteObject();
}
|
|