1 23 24 28 29 package com.sun.enterprise.config.serverbeans; 30 31 import org.w3c.dom.*; 32 import org.netbeans.modules.schema2beans.*; 33 import java.beans.*; 34 import java.util.*; 35 import java.io.Serializable ; 36 import com.sun.enterprise.config.ConfigBean; 37 import com.sun.enterprise.config.ConfigException; 38 import com.sun.enterprise.config.StaleWriteConfigException; 39 import com.sun.enterprise.util.i18n.StringManager; 40 41 43 public class Profiler extends ConfigBean implements Serializable 44 { 45 46 static Vector comparators = new Vector(); 47 private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 2, 0); 48 49 static public final String JVM_OPTIONS = "JvmOptions"; 50 static public final String ELEMENT_PROPERTY = "ElementProperty"; 51 52 public Profiler() { 53 this(Common.USE_DEFAULT_VALUES); 54 } 55 56 public Profiler(int options) 57 { 58 super(comparators, runtimeVersion); 59 initPropertyTables(2); 61 this.createProperty("jvm-options", JVM_OPTIONS, Common.SEQUENCE_OR | 62 Common.TYPE_0_N | Common.TYPE_STRING | Common.TYPE_KEY, 63 String .class); 64 this.createProperty("property", ELEMENT_PROPERTY, Common.SEQUENCE_OR | 65 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 66 ElementProperty.class); 67 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 68 AttrProp.CDATA | AttrProp.REQUIRED, 69 null, null); 70 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 71 AttrProp.CDATA | AttrProp.REQUIRED, 72 null, null); 73 this.initialize(options); 74 } 75 76 void initialize(int options) { 78 79 } 80 81 public void setJvmOptions(String [] value) { 83 this.setValue(JVM_OPTIONS, value); 84 } 85 86 public String [] getJvmOptions() { 88 return (String [])this.getValues(JVM_OPTIONS); 89 } 90 91 public int sizeJvmOptions() { 93 return this.size(JVM_OPTIONS); 94 } 95 96 public int addJvmOptions(String value) 98 throws ConfigException{ 99 return addJvmOptions(value, true); 100 } 101 102 public int addJvmOptions(String value, boolean overwrite) 104 throws ConfigException{ 105 return this.addValue(JVM_OPTIONS, value, overwrite); 106 } 107 108 public int removeJvmOptions(String value){ 113 return this.removeValue(JVM_OPTIONS, value); 114 } 115 116 public int removeJvmOptions(String value, boolean overwrite) 122 throws StaleWriteConfigException{ 123 return this.removeValue(JVM_OPTIONS, value, overwrite); 124 } 125 126 public void setElementProperty(int index, ElementProperty value) { 128 this.setValue(ELEMENT_PROPERTY, index, value); 129 } 130 131 public ElementProperty getElementProperty(int index) { 133 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 134 } 135 136 public void setElementProperty(ElementProperty[] value) { 138 this.setValue(ELEMENT_PROPERTY, value); 139 } 140 141 public ElementProperty[] getElementProperty() { 143 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 144 } 145 146 public int sizeElementProperty() { 148 return this.size(ELEMENT_PROPERTY); 149 } 150 151 public int addElementProperty(ElementProperty value) 153 throws ConfigException{ 154 return addElementProperty(value, true); 155 } 156 157 public int addElementProperty(ElementProperty value, boolean overwrite) 159 throws ConfigException{ 160 ElementProperty old = getElementPropertyByName(value.getName()); 161 if(old != null) { 162 throw new ConfigException(StringManager.getManager(Profiler.class).getString("cannotAddDuplicate", "ElementProperty")); 163 } 164 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 165 } 166 167 public int removeElementProperty(ElementProperty value){ 172 return this.removeValue(ELEMENT_PROPERTY, value); 173 } 174 175 public int removeElementProperty(ElementProperty value, boolean overwrite) 181 throws StaleWriteConfigException{ 182 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 183 } 184 185 public ElementProperty getElementPropertyByName(String id) { 186 if (null != id) { id = id.trim(); } 187 ElementProperty[] o = getElementProperty(); 188 if (o == null) return null; 189 190 for (int i=0; i < o.length; i++) { 191 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 192 return o[i]; 193 } 194 } 195 196 return null; 197 198 } 199 203 public String getName() { 204 return getAttributeValue(ServerTags.NAME); 205 } 206 211 public void setName(String v, boolean overwrite) throws StaleWriteConfigException { 212 setAttributeValue(ServerTags.NAME, v, overwrite); 213 } 214 218 public void setName(String v) { 219 setAttributeValue(ServerTags.NAME, v); 220 } 221 225 public String getClasspath() { 226 return getAttributeValue(ServerTags.CLASSPATH); 227 } 228 233 public void setClasspath(String v, boolean overwrite) throws StaleWriteConfigException { 234 setAttributeValue(ServerTags.CLASSPATH, v, overwrite); 235 } 236 240 public void setClasspath(String v) { 241 setAttributeValue(ServerTags.CLASSPATH, v); 242 } 243 247 public String getNativeLibraryPath() { 248 return getAttributeValue(ServerTags.NATIVE_LIBRARY_PATH); 249 } 250 255 public void setNativeLibraryPath(String v, boolean overwrite) throws StaleWriteConfigException { 256 setAttributeValue(ServerTags.NATIVE_LIBRARY_PATH, v, overwrite); 257 } 258 262 public void setNativeLibraryPath(String v) { 263 setAttributeValue(ServerTags.NATIVE_LIBRARY_PATH, v); 264 } 265 269 public boolean isEnabled() { 270 return toBoolean(getAttributeValue(ServerTags.ENABLED)); 271 } 272 277 public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 278 setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite); 279 } 280 284 public void setEnabled(boolean v) { 285 setAttributeValue(ServerTags.ENABLED, ""+(v==true)); 286 } 287 290 public static String getDefaultEnabled() { 291 return "true".trim(); 292 } 293 297 public ElementProperty newElementProperty() { 298 return new ElementProperty(); 299 } 300 301 306 protected String getRelativeXPath() { 307 String ret = null; 308 ret = "profiler" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ; 309 return (null != ret ? ret.trim() : null); 310 } 311 312 315 public static String getDefaultAttributeValue(String attr) { 316 if(attr == null) return null; 317 attr = attr.trim(); 318 if(attr.equals(ServerTags.ENABLED)) return "true".trim(); 319 return null; 320 } 321 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 323 comparators.add(c); 324 } 325 326 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 328 comparators.remove(c); 329 } 330 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 331 } 332 333 public void dump(StringBuffer str, String indent){ 335 String s; 336 Object o; 337 org.netbeans.modules.schema2beans.BaseBean n; 338 str.append(indent); 339 str.append("JvmOptions["+this.sizeJvmOptions()+"]"); for(int i=0; i<this.sizeJvmOptions(); i++) 341 { 342 str.append(indent+"\t"); 343 str.append("#"+i+":"); 344 str.append(indent+"\t"); str.append("<"); o = this.getValue(JVM_OPTIONS, i); 347 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(JVM_OPTIONS, i, str, indent); 350 } 351 352 str.append(indent); 353 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 355 { 356 str.append(indent+"\t"); 357 str.append("#"+i+":"); 358 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 359 if (n != null) 360 n.dump(str, indent + "\t"); else 362 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 364 } 365 366 } 367 public String dumpBeanNode(){ 368 StringBuffer str = new StringBuffer (); 369 str.append("Profiler\n"); this.dump(str, "\n "); return str.toString(); 372 }} 373 374 376 | Popular Tags |