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 EjbModule 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 DESCRIPTION = "Description"; 50 static public final String WEB_SERVICE_ENDPOINT = "WebServiceEndpoint"; 51 static public final String ELEMENT_PROPERTY = "ElementProperty"; 52 53 public EjbModule() { 54 this(Common.USE_DEFAULT_VALUES); 55 } 56 57 public EjbModule(int options) 58 { 59 super(comparators, runtimeVersion); 60 initPropertyTables(3); 62 this.createProperty("description", DESCRIPTION, 63 Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 64 String .class); 65 this.createProperty("web-service-endpoint", WEB_SERVICE_ENDPOINT, 66 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 67 WebServiceEndpoint.class); 68 this.createAttribute(WEB_SERVICE_ENDPOINT, "name", "Name", 69 AttrProp.CDATA | AttrProp.REQUIRED, 70 null, null); 71 this.createAttribute(WEB_SERVICE_ENDPOINT, "monitoring", "Monitoring", 72 AttrProp.CDATA, 73 null, "OFF"); 74 this.createAttribute(WEB_SERVICE_ENDPOINT, "max-history-size", "MaxHistorySize", 75 AttrProp.CDATA, 76 null, "25"); 77 this.createAttribute(WEB_SERVICE_ENDPOINT, "jbi-enabled", "JbiEnabled", 78 AttrProp.CDATA, 79 null, "true"); 80 this.createProperty("property", ELEMENT_PROPERTY, 81 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 82 ElementProperty.class); 83 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 84 AttrProp.CDATA | AttrProp.REQUIRED, 85 null, null); 86 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 87 AttrProp.CDATA | AttrProp.REQUIRED, 88 null, null); 89 this.initialize(options); 90 } 91 92 void initialize(int options) { 94 95 } 96 97 100 public String getDescription() { 101 return (String ) getValue(ServerTags.DESCRIPTION); 102 } 103 107 public void setDescription(String v){ 108 setValue(ServerTags.DESCRIPTION, (null != v ? v.trim() : null)); 109 } 110 public void setWebServiceEndpoint(int index, WebServiceEndpoint value) { 112 this.setValue(WEB_SERVICE_ENDPOINT, index, value); 113 } 114 115 public WebServiceEndpoint getWebServiceEndpoint(int index) { 117 return (WebServiceEndpoint)this.getValue(WEB_SERVICE_ENDPOINT, index); 118 } 119 120 public void setWebServiceEndpoint(WebServiceEndpoint[] value) { 122 this.setValue(WEB_SERVICE_ENDPOINT, value); 123 } 124 125 public WebServiceEndpoint[] getWebServiceEndpoint() { 127 return (WebServiceEndpoint[])this.getValues(WEB_SERVICE_ENDPOINT); 128 } 129 130 public int sizeWebServiceEndpoint() { 132 return this.size(WEB_SERVICE_ENDPOINT); 133 } 134 135 public int addWebServiceEndpoint(WebServiceEndpoint value) 137 throws ConfigException{ 138 return addWebServiceEndpoint(value, true); 139 } 140 141 public int addWebServiceEndpoint(WebServiceEndpoint value, boolean overwrite) 143 throws ConfigException{ 144 WebServiceEndpoint old = getWebServiceEndpointByName(value.getName()); 145 if(old != null) { 146 throw new ConfigException(StringManager.getManager(EjbModule.class).getString("cannotAddDuplicate", "WebServiceEndpoint")); 147 } 148 return this.addValue(WEB_SERVICE_ENDPOINT, value, overwrite); 149 } 150 151 public int removeWebServiceEndpoint(WebServiceEndpoint value){ 156 return this.removeValue(WEB_SERVICE_ENDPOINT, value); 157 } 158 159 public int removeWebServiceEndpoint(WebServiceEndpoint value, boolean overwrite) 165 throws StaleWriteConfigException{ 166 return this.removeValue(WEB_SERVICE_ENDPOINT, value, overwrite); 167 } 168 169 public WebServiceEndpoint getWebServiceEndpointByName(String id) { 170 if (null != id) { id = id.trim(); } 171 WebServiceEndpoint[] o = getWebServiceEndpoint(); 172 if (o == null) return null; 173 174 for (int i=0; i < o.length; i++) { 175 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 176 return o[i]; 177 } 178 } 179 180 return null; 181 182 } 183 public void setElementProperty(int index, ElementProperty value) { 185 this.setValue(ELEMENT_PROPERTY, index, value); 186 } 187 188 public ElementProperty getElementProperty(int index) { 190 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 191 } 192 193 public void setElementProperty(ElementProperty[] value) { 195 this.setValue(ELEMENT_PROPERTY, value); 196 } 197 198 public ElementProperty[] getElementProperty() { 200 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 201 } 202 203 public int sizeElementProperty() { 205 return this.size(ELEMENT_PROPERTY); 206 } 207 208 public int addElementProperty(ElementProperty value) 210 throws ConfigException{ 211 return addElementProperty(value, true); 212 } 213 214 public int addElementProperty(ElementProperty value, boolean overwrite) 216 throws ConfigException{ 217 ElementProperty old = getElementPropertyByName(value.getName()); 218 if(old != null) { 219 throw new ConfigException(StringManager.getManager(EjbModule.class).getString("cannotAddDuplicate", "ElementProperty")); 220 } 221 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 222 } 223 224 public int removeElementProperty(ElementProperty value){ 229 return this.removeValue(ELEMENT_PROPERTY, value); 230 } 231 232 public int removeElementProperty(ElementProperty value, boolean overwrite) 238 throws StaleWriteConfigException{ 239 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 240 } 241 242 public ElementProperty getElementPropertyByName(String id) { 243 if (null != id) { id = id.trim(); } 244 ElementProperty[] o = getElementProperty(); 245 if (o == null) return null; 246 247 for (int i=0; i < o.length; i++) { 248 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 249 return o[i]; 250 } 251 } 252 253 return null; 254 255 } 256 260 public String getName() { 261 return getAttributeValue(ServerTags.NAME); 262 } 263 268 public void setName(String v, boolean overwrite) throws StaleWriteConfigException { 269 setAttributeValue(ServerTags.NAME, v, overwrite); 270 } 271 275 public void setName(String v) { 276 setAttributeValue(ServerTags.NAME, v); 277 } 278 282 public String getLocation() { 283 return getAttributeValue(ServerTags.LOCATION); 284 } 285 290 public void setLocation(String v, boolean overwrite) throws StaleWriteConfigException { 291 setAttributeValue(ServerTags.LOCATION, v, overwrite); 292 } 293 297 public void setLocation(String v) { 298 setAttributeValue(ServerTags.LOCATION, v); 299 } 300 304 public String getObjectType() { 305 return getAttributeValue(ServerTags.OBJECT_TYPE); 306 } 307 312 public void setObjectType(String v, boolean overwrite) throws StaleWriteConfigException { 313 setAttributeValue(ServerTags.OBJECT_TYPE, v, overwrite); 314 } 315 319 public void setObjectType(String v) { 320 setAttributeValue(ServerTags.OBJECT_TYPE, v); 321 } 322 325 public static String getDefaultObjectType() { 326 return "user".trim(); 327 } 328 332 public boolean isEnabled() { 333 return toBoolean(getAttributeValue(ServerTags.ENABLED)); 334 } 335 340 public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 341 setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite); 342 } 343 347 public void setEnabled(boolean v) { 348 setAttributeValue(ServerTags.ENABLED, ""+(v==true)); 349 } 350 353 public static String getDefaultEnabled() { 354 return "true".trim(); 355 } 356 360 public String getLibraries() { 361 return getAttributeValue(ServerTags.LIBRARIES); 362 } 363 368 public void setLibraries(String v, boolean overwrite) throws StaleWriteConfigException { 369 setAttributeValue(ServerTags.LIBRARIES, v, overwrite); 370 } 371 375 public void setLibraries(String v) { 376 setAttributeValue(ServerTags.LIBRARIES, v); 377 } 378 382 public boolean isAvailabilityEnabled() { 383 return toBoolean(getAttributeValue(ServerTags.AVAILABILITY_ENABLED)); 384 } 385 390 public void setAvailabilityEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 391 setAttributeValue(ServerTags.AVAILABILITY_ENABLED, ""+(v==true), overwrite); 392 } 393 397 public void setAvailabilityEnabled(boolean v) { 398 setAttributeValue(ServerTags.AVAILABILITY_ENABLED, ""+(v==true)); 399 } 400 403 public static String getDefaultAvailabilityEnabled() { 404 return "false".trim(); 405 } 406 410 public boolean isDirectoryDeployed() { 411 return toBoolean(getAttributeValue(ServerTags.DIRECTORY_DEPLOYED)); 412 } 413 418 public void setDirectoryDeployed(boolean v, boolean overwrite) throws StaleWriteConfigException { 419 setAttributeValue(ServerTags.DIRECTORY_DEPLOYED, ""+(v==true), overwrite); 420 } 421 425 public void setDirectoryDeployed(boolean v) { 426 setAttributeValue(ServerTags.DIRECTORY_DEPLOYED, ""+(v==true)); 427 } 428 431 public static String getDefaultDirectoryDeployed() { 432 return "false".trim(); 433 } 434 438 public WebServiceEndpoint newWebServiceEndpoint() { 439 return new WebServiceEndpoint(); 440 } 441 442 446 public ElementProperty newElementProperty() { 447 return new ElementProperty(); 448 } 449 450 455 protected String getRelativeXPath() { 456 String ret = null; 457 ret = "ejb-module" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ; 458 return (null != ret ? ret.trim() : null); 459 } 460 461 464 public static String getDefaultAttributeValue(String attr) { 465 if(attr == null) return null; 466 attr = attr.trim(); 467 if(attr.equals(ServerTags.OBJECT_TYPE)) return "user".trim(); 468 if(attr.equals(ServerTags.ENABLED)) return "true".trim(); 469 if(attr.equals(ServerTags.AVAILABILITY_ENABLED)) return "false".trim(); 470 if(attr.equals(ServerTags.DIRECTORY_DEPLOYED)) return "false".trim(); 471 return null; 472 } 473 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 475 comparators.add(c); 476 } 477 478 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 480 comparators.remove(c); 481 } 482 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 483 } 484 485 public void dump(StringBuffer str, String indent){ 487 String s; 488 Object o; 489 org.netbeans.modules.schema2beans.BaseBean n; 490 str.append(indent); 491 str.append("Description"); str.append(indent+"\t"); str.append("<"); o = this.getDescription(); 495 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(DESCRIPTION, 0, str, indent); 498 499 str.append(indent); 500 str.append("WebServiceEndpoint["+this.sizeWebServiceEndpoint()+"]"); for(int i=0; i<this.sizeWebServiceEndpoint(); i++) 502 { 503 str.append(indent+"\t"); 504 str.append("#"+i+":"); 505 n = (org.netbeans.modules.schema2beans.BaseBean) this.getWebServiceEndpoint(i); 506 if (n != null) 507 n.dump(str, indent + "\t"); else 509 str.append(indent+"\tnull"); this.dumpAttributes(WEB_SERVICE_ENDPOINT, i, str, indent); 511 } 512 513 str.append(indent); 514 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 516 { 517 str.append(indent+"\t"); 518 str.append("#"+i+":"); 519 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 520 if (n != null) 521 n.dump(str, indent + "\t"); else 523 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 525 } 526 527 } 528 public String dumpBeanNode(){ 529 StringBuffer str = new StringBuffer (); 530 str.append("EjbModule\n"); this.dump(str, "\n "); return str.toString(); 533 }} 534 535 537 | Popular Tags |