attributes[i].isWritable(),
attributes[i].isIs()
);
// by default, conversion metadata should not try to cache attributes
Descriptor d = attrInfo.getDescriptor();
d.setField(CURRENCY_TIME_LIMIT, CACHE_NEVER);
attrInfo.setDescriptor(d);
mmbAttributes[i] = attrInfo;
// if we're doing attribute operation mapping, find the accessor methods
// from the Standard MBean interface, and create the 'setter' and 'getter'
// management operations for them. Map the Model MBean attributes to
// these operations.
if (createAttributeOperationMapping)
{
String getterOperationName = null;
String setterOperationName = null;
Descriptor getterDescriptor = null;
Descriptor setterDescriptor = null;
// figure out the getter type
if (attributes[i].isReadable())
{
if (attributes[i].isIs())
getterOperationName = "is" + attributes[i].getName();
else
getterOperationName = "get" + attributes[i].getName();
// create a descriptor for 'getter' mgmt operation
getterDescriptor = new DescriptorSupport();
getterDescriptor.setField(NAME, getterOperationName);
getterDescriptor.setField(DESCRIPTOR_TYPE, OPERATION_DESCRIPTOR);
getterDescriptor.setField(ROLE, GETTER);
// create the new management operation
ModelMBeanOperationInfo opInfo = new ModelMBeanOperationInfo(
getterOperationName,
"Read accessor operation for '" + attributes[i].getName() + "' attribute.",
new MBeanParameterInfo[0], // void signature
attributes[i].getType(), // return type
MBeanOperationInfo.INFO, // impact
getterDescriptor
);
// modify the attributes descriptor to map the read operation
// to the above created management operation
Descriptor attrDescriptor = mmbAttributes[i].getDescriptor();
attrDescriptor.setField(GET_METHOD, getterOperationName);
mmbAttributes[i].setDescriptor(attrDescriptor);
accessorOperations.add(opInfo);
}
// figure out the setter
if (attributes[i].isWritable())
{
setterOperationName = "set" + attributes[i].getName();
// create a descriptor for 'setter' mgmt operation
setterDescriptor = new DescriptorSupport();
setterDescriptor.setField(NAME, setterOperationName);
setterDescriptor.setField(DESCRIPTOR_TYPE, OPERATION_DESCRIPTOR);
setterDescriptor.setField(ROLE, SETTER);
// create the new management operation
ModelMBeanOperationInfo opInfo = new ModelMBeanOperationInfo(
setterOperationName,
"Write accessor operation for '" + attributes[i].getName() + "' attribute.",
new MBeanParameterInfo[] {
new MBeanParameterInfo("value", attributes[i].getType(), "Attribute's value.")
},
Void.TYPE.getName(),
MBeanOperationInfo.ACTION,
setterDescriptor
);
// modify the attributes descriptor to map the read operation
// to the above created management operation
Descriptor attrDescriptor = mmbAttributes[i].getDescriptor();
attrDescriptor.setField(SET_METHOD, setterOperationName);
mmbAttributes[i].setDescriptor(attrDescriptor);
accessorOperations.add(opInfo);
}
}