AttributeList list = null;
JMXServerRegistry serverRegistry = (JMXServerRegistry)ApplicationRegistry.getServerRegistry(mbean);
MBeanServerConnection mbsc = serverRegistry.getServerConnection();
MBeanAttributeInfo[] attributesInfo = null;
ManagedAttributeModel attributeModel = serverRegistry.getAttributeModel(mbean);
if (attributeModel == null)
{
// If the process is here, then it means the attribute values are not retrieved from mbean server
// even once for this mbean. Create attribute model, retrieve values from mbean server and
// set the attribute model in server registry for this mbean
attributeModel = new ManagedAttributeModel();
attributesInfo = serverRegistry.getMBeanInfo(mbean).getAttributes();
attributes = new String[attributesInfo.length];
for (int i = 0; i< attributesInfo.length ; i++)
{
attributes[i] = attributesInfo[i].getName();
attributeModel.setAttributeDescription(attributes[i], attributesInfo[i].getDescription());
attributeModel.setAttributeWritable(attributes[i], attributesInfo[i].isWritable());
attributeModel.setAttributeReadable(attributes[i], attributesInfo[i].isReadable());
}
}
else
{
attributes = attributeModel.getAttributeNames().toArray(new String[0]);
}
if (attributes.length != 0)
{
list = mbsc.getAttributes(objName, attributes);
for (Iterator itr = list.iterator(); itr.hasNext();)
{
Attribute attrib = (Attribute)itr.next();
attributeModel.setAttributeValue(attrib.getName(), attrib.getValue());
}
}
serverRegistry.setAttributeModel(mbean, attributeModel);
return attributeModel;