MBeanInfo info = server.getMBeanInfo(objectName);
MBeanAttributeInfo[] attribute_info = info.getAttributes();
String type;
AttributeList attrs = new AttributeList(attributeNames.size());
Attribute attr;
String attr_name;
Object attr_value, real_value;
MBeanAttributeInfo attr_info;
for (Iterator it = attributeNames.iterator(); it.hasNext();)
{
attr_name = (String) it.next();
attr_value = it.next();
attr_info = findAttribute(attr_name, attribute_info);
if (attr_info == null)
throw new CommandException("attribute " + attr_name + " not found");
type = attr_info.getType();
PropertyEditor editor = PropertyEditors.getEditor(type);
editor.setAsText((String) attr_value);
real_value = editor.getValue();
attr = new Attribute(attr_name, real_value);
attrs.add(attr);
}
AttributeList ret = server.setAttributes(objectName, attrs);
System.out.println("The following attributes were set successfuly:");
if (ret.size() > 0)
{
for (Iterator it = ret.iterator(); it.hasNext();)
{
Attribute a = (Attribute) it.next();
System.out.println(a.getName() + "=" + a.getValue());
}
}
closeServer();
}