@HandlerOutput(name="StatusString", type=String.class),
@HandlerOutput(name="Result", type=List.class),
@HandlerOutput(name="Properties", type=Map.class) })
public static void getCustomMBeanValues(HandlerContext handlerCtx){
try{
CustomMBeanConfig mbeanConfig = null;
boolean edit = ((Boolean)handlerCtx.getInputValue("Edit")).booleanValue();
String implClassName = "";
Map<String, String> props = new HashMap();
boolean status = true;
if(edit){
mbeanConfig = AMXUtil.getDomainConfig().getCustomMBeanConfigMap().get(handlerCtx.getInputValue("CustomMBeanName"));
implClassName = mbeanConfig.getImplClassname();
handlerCtx.setOutputValue("ObjectName", mbeanConfig.getObjectNameInConfig());
handlerCtx.setOutputValue("Description", mbeanConfig.getDescription());
props = mbeanConfig.getProperties();
if(AMXUtil.isEE()){
handlerCtx.setOutputValue("StatusString", TargetUtil.getEnabledStatus(mbeanConfig, true));
}else{
status = TargetUtil.isApplicationEnabled(mbeanConfig, "server");
}
}else{
implClassName = (String)handlerCtx.getInputValue("ClassName");
}
List result = new ArrayList();
Object[] params = {implClassName};
String[] signature = {"java.lang.String"};
MBeanInfo mbinfo = (MBeanInfo) JMXUtil.invoke(APPS_OBJNAME, "getMBeanInfo", params, signature);
MBeanAttributeInfo[] attrArray = mbinfo.getAttributes();
if (attrArray != null && attrArray.length > 0){
AttributeList attrList = null;
if(edit){
String objName = "com.sun.appserv:type=mbean,category=config,name=" + mbeanConfig.getName();
attrList = (AttributeList) JMXUtil.invoke(objName, "getProperties", null, null);
}
for(int i=0; i<attrArray.length; i++){
HashMap oneRow = new HashMap();
String name = attrArray[i].getName();
oneRow.put("name", name);
oneRow.put("type", attrArray[i].getType());
oneRow.put("value", "");
if(edit){
if(Arrays.asList(mbeanConfig.getPropertyNames()).contains(name)){
oneRow.put("value", mbeanConfig.getPropertyValue(name));
}
}
result.add(oneRow);
}
}