final boolean READABLE = true;
final boolean WRITABLE = true;
final boolean BOOLEAN = true;
// build 'pojoAttribute' read-write attribute
Descriptor descr2 = new DescriptorSupport();
descr2.setField("name", "pojoAttribute");
descr2.setField("descriptorType", "attribute");
descr2.setField("getMethod", "getpojoAttribute");
descr2.setField("setMethod", "setpojoAttribute");
ModelMBeanAttributeInfo pojoAttributeInfo =
new ModelMBeanAttributeInfo(
"pojoAttribute",
int.class.getName(),
"A simple integer attribute.",
READABLE, WRITABLE, !BOOLEAN,
descr2
);
// JBAS-3614 - the jdk implementation of RequiredModelMBean
// requires the attribute to be declared as operation(s), too.
// This is not a requirement of the JMX 1.2 spec, though.
// build 'getpojoAttribute' operation
Descriptor descr21 = new DescriptorSupport();
descr21.setField("name", "getpojoAttribute");
descr21.setField("descriptorType", "operation");
ModelMBeanOperationInfo getpojoAttributeOperation =
new ModelMBeanOperationInfo(
"getpojoAttribute", // name
"A simple operation.", // description
null, // signature
int.class.getName(), // return type
MBeanOperationInfo.INFO, // impact
descr21 // descriptor
);
// build 'setpojoAttribute' operation
Descriptor descr22 = new DescriptorSupport();
descr22.setField("name", "setpojoAttribute");
descr22.setField("descriptorType", "operation");
ModelMBeanOperationInfo setpojoAttributeOperation =
new ModelMBeanOperationInfo(
"setpojoAttribute", // name
"A simple operation.", // description
new MBeanParameterInfo[] // signature
{ new MBeanParameterInfo("int", int.class.getName(), "int setter") },
void.class.getName(), // return type
MBeanOperationInfo.ACTION, // impact
descr22 // descriptor
);
// build 'pojoOperation' operation
Descriptor descr3 = new DescriptorSupport();
descr3.setField("name", "pojoOperation");
descr3.setField("descriptorType", "operation");
ModelMBeanOperationInfo pojoOperationInfo =
new ModelMBeanOperationInfo(
"pojoOperation", // name & description
"A simple operation.",
null, // signature
boolean.class.getName(), // return type
MBeanOperationInfo.ACTION, // impact
descr3 // descriptor
);
// MBean descriptor
Descriptor descr4 = new DescriptorSupport();
descr4.setField("name", RequiredModelMBean.class.getName());
descr4.setField("descriptorType", "MBean");
// create ModelMBeanInfo
ModelMBeanInfo info = new ModelMBeanInfoSupport(
RequiredModelMBean.class.getName(), // class name
"POJO", // description