1 package org.sapia.soto.jmx; 2 3 import java.lang.reflect.Method ; 4 5 import java.util.ArrayList ; 6 import java.util.List ; 7 8 import javax.management.MBeanOperationInfo ; 9 import javax.management.MBeanParameterInfo ; 10 11 12 26 public class OperationDescriptor { 27 private String _name; 28 private String _description = MBeanDescriptor.DEFAULT_DESC; 29 private List _parameters = new ArrayList (); 30 private String _type = void.class.getName(); 31 private Method _method; 32 private int _impact = MBeanOperationInfo.UNKNOWN; 33 34 37 public OperationDescriptor() { 38 super(); 39 } 40 41 47 public void setImpact(int impact) { 48 _impact = impact; 49 } 50 51 56 public void setDescription(String desc) { 57 _description = desc; 58 } 59 60 67 public MBeanOperationInfo getInfo() { 68 return new MBeanOperationInfo (_name, _description, getParameterInfos(), 69 _type, _impact); 70 } 71 72 75 public Method getMethod() { 76 return _method; 77 } 78 79 public String getOperationName() { 80 return _name; 81 } 82 83 public List getParameters() { 84 return _parameters; 85 } 86 87 void setMethod(Method method) { 88 _method = method; 89 _type = method.getReturnType().getName(); 90 } 91 92 void setOperationName(String name) { 93 _name = name; 94 } 95 96 MBeanParameterInfo [] getParameterInfos() { 97 MBeanParameterInfo [] infos = new MBeanParameterInfo [_parameters.size()]; 98 ParameterDescriptor desc; 99 100 for (int i = 0; i < _parameters.size(); i++) { 101 desc = (ParameterDescriptor) _parameters.get(i); 102 infos[i] = desc.getInfo(); 103 } 104 105 return infos; 106 } 107 108 void addParameters(ParameterDescriptor desc) { 109 _parameters.add(desc); 110 } 111 112 public String toString() { 113 return "[ name=" + _name + ", description=" + _description + ", type=" + 114 _type + ", parameters=" + _parameters + " ]"; 115 } 116 } 117 | Popular Tags |