List params = oper.getChildren("parameter");
MBeanParameterInfo[] paramInfo =
buildParameterInfo(params);
Descriptor descr = getDescriptor(oper, name, OPERATION_DESCRIPTOR);
// defaults to ACTION_INFO
int operImpact = MBeanOperationInfo.ACTION_INFO;
if (impact != null)
{
if (impact.equals(INFO))
operImpact = MBeanOperationInfo.INFO;
else if (impact.equals(ACTION))
operImpact = MBeanOperationInfo.ACTION;
else if (impact.equals(ACTION_INFO))
operImpact = MBeanOperationInfo.ACTION_INFO;
}
// default return-type is void
if (type == null)
type = "void";
// Possible getter?
if (paramInfo.length == 0 && type.equals("void") == false)
getters.put(name, type);
// Possible setter?
if (paramInfo.length == 1)
{
HashSet types = (HashSet) setters.get(name);
if (types == null)
{
types = new HashSet();
setters.put(name, types);
}
types.add(paramInfo[0].getType());
}
ModelMBeanOperationInfo info = new ModelMBeanOperationInfo(
name, description, paramInfo, type, operImpact, descr);
infos.add(info);
}
// Add operations for get/setMethod that aren't already present
for (Iterator it = attributes.iterator(); it.hasNext();)
{
Element attr = (Element) it.next();
String name = attr.getChildTextTrim("name");
String type = attr.getChildTextTrim("type");
String getMethod = attr.getAttributeValue(GET_METHOD);
String setMethod = attr.getAttributeValue(SET_METHOD);
// Fabricate a getter operation
if (getMethod != null)
{
Object getterOpType = getters.get(getMethod);
if (getterOpType == null || getterOpType.equals(type) == false)
{
Descriptor getterDescriptor = new DescriptorSupport();
getterDescriptor.setField(NAME, getMethod);
getterDescriptor.setField(DESCRIPTOR_TYPE, OPERATION_DESCRIPTOR);
getterDescriptor.setField(ROLE, GETTER);
ModelMBeanOperationInfo info = new ModelMBeanOperationInfo
(
getMethod,
"getMethod operation for '" + name + "' attribute.",
new MBeanParameterInfo[0],
type,
MBeanOperationInfo.INFO,
getterDescriptor
);
infos.add(info);
}
}
// Fabricate a setter operation
if (setMethod != null)
{
HashSet setterOpTypes = (HashSet) setters.get(setMethod);
if (setterOpTypes == null || setterOpTypes.contains(type) == false)
{
Descriptor setterDescriptor = new DescriptorSupport();
setterDescriptor.setField(NAME, setMethod);
setterDescriptor.setField(DESCRIPTOR_TYPE, OPERATION_DESCRIPTOR);
setterDescriptor.setField(ROLE, SETTER);
ModelMBeanOperationInfo info = new ModelMBeanOperationInfo
(
setMethod,
"setMethod operation for '" + name + "' attribute.",
new MBeanParameterInfo[]