String name = in.getVariable("objectname");
String attributeVariable = in.getVariable("attribute");
String formatVariable = in.getVariable("format");
ObjectName objectName = null;
MBeanAttributeInfo targetAttribute = null;
// special case
boolean validMBean = false;
if (name != null)
{
objectName = new ObjectName(name);
if (server.isRegistered(objectName))
{
validMBean = true;
}
}
if (validMBean && attributeVariable != null)
{
validMBean = false;
MBeanInfo info = server.getMBeanInfo(objectName);
MBeanAttributeInfo[] attributes = info.getAttributes();
if (attributes != null)
{
for (int i=0;i<attributes.length;i++)
{
if (attributes[i].getName().equals(attributeVariable))
{
targetAttribute = attributes[i];
validMBean = true;
break;
}
}
}
}
if (validMBean)
{
Element root = document.createElement("MBean");
document.appendChild(root);
root.setAttribute("objectname", objectName.toString());
MBeanInfo info = server.getMBeanInfo(objectName);
root.setAttribute("classname", info.getClassName());
root.setAttribute("description", info.getDescription());
Element attribute = document.createElement("Attribute");
attribute.setAttribute("name", attributeVariable);
attribute.setAttribute("classname", targetAttribute.getType());
Object attributeValue = server.getAttribute(objectName, attributeVariable);
attribute.setAttribute("isnull", (attributeValue==null)?"true":"false");
root.appendChild(attribute);
if ("array".equals(formatVariable) && attributeValue.getClass().isArray())