1 23 24 31 package com.sun.enterprise.admin.monitor; 32 33 import java.util.ArrayList ; 34 import java.util.Iterator ; 35 36 import javax.management.Attribute ; 37 import javax.management.AttributeList ; 38 import javax.management.InstanceNotFoundException ; 39 import javax.management.MBeanException ; 40 import javax.management.ReflectionException ; 41 import javax.management.MBeanAttributeInfo ; 42 import javax.management.MBeanInfo ; 43 import javax.management.ObjectName ; 44 45 48 public class MonitorSetCommand extends MonitorCommand { 49 50 53 private String [] params; 54 private static final String WILDCARD = "*"; 55 private String operationName; 56 57 60 MonitorSetCommand(ObjectName mbeanName, MonitoredObjectType type, String operationName, String [] commandOperands) { 61 this.objectName = mbeanName; 62 if (type != null) { 63 this.monitoredObjectType = type.getTypeName(); 64 } 65 this.operationName = operationName; 66 if (commandOperands.length > 0) { 67 params = commandOperands; 68 } 69 70 if (WILDCARD.equals(operationName)) { 71 throw new UnsupportedOperationException (BaseMonitorMBean.UNSUPPORTED_ERRMSG); 72 } 73 } 74 75 78 Object runCommand() throws InstanceNotFoundException , 79 ReflectionException , MBeanException { 80 BaseMonitorMBean mbean = MonitoringHelper.getMonitorMBean(objectName); 81 if (mbean == null) { 82 throw new InstanceNotFoundException (); 83 } 84 ArrayList mbeanList = null; 85 86 if (monitoredObjectType != null) { 87 mbeanList = mbean.getChildList(monitoredObjectType); 88 } else { 89 mbeanList = new ArrayList (); 90 mbeanList.add(mbean); 91 } 92 AttributeList result = new AttributeList (); 93 94 Object val = mbean.invoke(operationName, params, null); 95 Attribute attr = new Attribute (operationName, val); 96 result.add(attr); 97 98 return result; 99 } 100 } 101 | Popular Tags |