1 16 17 18 package org.apache.commons.modeler; 19 20 21 import java.io.Serializable ; 22 23 import javax.management.Descriptor ; 24 import javax.management.MBeanParameterInfo ; 25 import javax.management.modelmbean.ModelMBeanConstructorInfo ; 26 27 28 35 36 public class ConstructorInfo extends FeatureInfo implements Serializable { 37 static final long serialVersionUID = -5735336213417238238L; 38 39 41 42 46 transient ModelMBeanConstructorInfo info = null; 47 protected String displayName = null; 48 protected ParameterInfo parameters[] = new ParameterInfo[0]; 49 50 51 53 54 59 public void setDescription(String description) { 60 super.setDescription(description); 61 this.info = null; 62 } 63 64 65 70 public void setName(String name) { 71 super.setName(name); 72 this.info = null; 73 } 74 75 76 79 public String getDisplayName() { 80 return (this.displayName); 81 } 82 83 public void setDisplayName(String displayName) { 84 this.displayName = displayName; 85 } 86 87 88 91 public ParameterInfo[] getSignature() { 92 return (this.parameters); 93 } 94 95 96 98 99 104 public void addParameter(ParameterInfo parameter) { 105 106 synchronized (parameters) { 107 ParameterInfo results[] = new ParameterInfo[parameters.length + 1]; 108 System.arraycopy(parameters, 0, results, 0, parameters.length); 109 results[parameters.length] = parameter; 110 parameters = results; 111 this.info = null; 112 } 113 114 } 115 116 117 121 public ModelMBeanConstructorInfo createConstructorInfo() { 122 123 if (info != null) 125 return (info); 126 127 ParameterInfo params[] = getSignature(); 129 MBeanParameterInfo parameters[] = 130 new MBeanParameterInfo [params.length]; 131 for (int i = 0; i < params.length; i++) 132 parameters[i] = params[i].createParameterInfo(); 133 info = new ModelMBeanConstructorInfo 134 (getName(), getDescription(), parameters); 135 Descriptor descriptor = info.getDescriptor(); 136 descriptor.removeField("class"); 137 if (getDisplayName() != null) 138 descriptor.setField("displayName", getDisplayName()); 139 addFields(descriptor); 140 info.setDescriptor(descriptor); 141 return (info); 142 143 } 144 145 146 149 public String toString() { 150 151 StringBuffer sb = new StringBuffer ("ConstructorInfo["); 152 sb.append("name="); 153 sb.append(name); 154 sb.append(", description="); 155 sb.append(description); 156 sb.append(", parameters="); 157 sb.append(parameters.length); 158 sb.append("]"); 159 return (sb.toString()); 160 161 } 162 163 164 } 165 | Popular Tags |