1 17 18 19 package org.apache.tomcat.util.modeler; 20 21 22 import java.io.Serializable ; 23 24 import javax.management.MBeanOperationInfo ; 25 import javax.management.MBeanParameterInfo ; 26 27 28 34 public class OperationInfo extends FeatureInfo implements Serializable { 35 static final long serialVersionUID = 4418342922072614875L; 36 38 39 42 public OperationInfo() { 43 44 super(); 45 46 } 47 48 50 protected String impact = "UNKNOWN"; 51 protected String role = "operation"; 52 protected ParameterInfo parameters[] = new ParameterInfo[0]; 53 54 55 57 61 public String getImpact() { 62 return (this.impact); 63 } 64 65 public void setImpact(String impact) { 66 if (impact == null) 67 this.impact = null; 68 else 69 this.impact = impact.toUpperCase(); 70 } 71 72 73 77 public String getRole() { 78 return (this.role); 79 } 80 81 public void setRole(String role) { 82 this.role = role; 83 } 84 85 86 90 public String getReturnType() { 91 if(type == null) { 92 type = "void"; 93 } 94 return type; 95 } 96 97 public void setReturnType(String returnType) { 98 this.type = returnType; 99 } 100 101 104 public ParameterInfo[] getSignature() { 105 return (this.parameters); 106 } 107 108 110 111 116 public void addParameter(ParameterInfo parameter) { 117 118 synchronized (parameters) { 119 ParameterInfo results[] = new ParameterInfo[parameters.length + 1]; 120 System.arraycopy(parameters, 0, results, 0, parameters.length); 121 results[parameters.length] = parameter; 122 parameters = results; 123 this.info = null; 124 } 125 126 } 127 128 129 133 MBeanOperationInfo createOperationInfo() { 134 135 if (info == null) { 137 int impact = MBeanOperationInfo.UNKNOWN; 139 if ("ACTION".equals(getImpact())) 140 impact = MBeanOperationInfo.ACTION; 141 else if ("ACTION_INFO".equals(getImpact())) 142 impact = MBeanOperationInfo.ACTION_INFO; 143 else if ("INFO".equals(getImpact())) 144 impact = MBeanOperationInfo.INFO; 145 146 info = new MBeanOperationInfo (getName(), getDescription(), 147 getMBeanParameterInfo(), 148 getReturnType(), impact); 149 } 150 return (MBeanOperationInfo )info; 151 } 152 153 protected MBeanParameterInfo [] getMBeanParameterInfo() { 154 ParameterInfo params[] = getSignature(); 155 MBeanParameterInfo parameters[] = 156 new MBeanParameterInfo [params.length]; 157 for (int i = 0; i < params.length; i++) 158 parameters[i] = params[i].createParameterInfo(); 159 return parameters; 160 } 161 } 162 | Popular Tags |