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 WebServiceEndpoint 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 REGISTRY_LOCATION = "RegistryLocation"; 50 static public final String TRANSFORMATION_RULE = "TransformationRule"; 51 52 public WebServiceEndpoint() { 53 this(Common.USE_DEFAULT_VALUES); 54 } 55 56 public WebServiceEndpoint(int options) 57 { 58 super(comparators, runtimeVersion); 59 initPropertyTables(2); 61 this.createProperty("registry-location", REGISTRY_LOCATION, 62 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 63 RegistryLocation.class); 64 this.createAttribute(REGISTRY_LOCATION, "connector-resource-jndi-name", "ConnectorResourceJndiName", 65 AttrProp.CDATA | AttrProp.REQUIRED, 66 null, null); 67 this.createProperty("transformation-rule", TRANSFORMATION_RULE, 68 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 69 TransformationRule.class); 70 this.createAttribute(TRANSFORMATION_RULE, "name", "Name", 71 AttrProp.CDATA | AttrProp.REQUIRED, 72 null, null); 73 this.createAttribute(TRANSFORMATION_RULE, "enabled", "Enabled", 74 AttrProp.CDATA, 75 null, "true"); 76 this.createAttribute(TRANSFORMATION_RULE, "apply-to", "ApplyTo", 77 AttrProp.CDATA, 78 null, "request"); 79 this.createAttribute(TRANSFORMATION_RULE, "rule-file-location", "RuleFileLocation", 80 AttrProp.CDATA | AttrProp.REQUIRED, 81 null, null); 82 this.initialize(options); 83 } 84 85 void initialize(int options) { 87 88 } 89 90 public void setRegistryLocation(int index, RegistryLocation value) { 92 this.setValue(REGISTRY_LOCATION, index, value); 93 } 94 95 public RegistryLocation getRegistryLocation(int index) { 97 return (RegistryLocation)this.getValue(REGISTRY_LOCATION, index); 98 } 99 100 public void setRegistryLocation(RegistryLocation[] value) { 102 this.setValue(REGISTRY_LOCATION, value); 103 } 104 105 public RegistryLocation[] getRegistryLocation() { 107 return (RegistryLocation[])this.getValues(REGISTRY_LOCATION); 108 } 109 110 public int sizeRegistryLocation() { 112 return this.size(REGISTRY_LOCATION); 113 } 114 115 public int addRegistryLocation(RegistryLocation value) 117 throws ConfigException{ 118 return addRegistryLocation(value, true); 119 } 120 121 public int addRegistryLocation(RegistryLocation value, boolean overwrite) 123 throws ConfigException{ 124 RegistryLocation old = getRegistryLocationByConnectorResourceJndiName(value.getConnectorResourceJndiName()); 125 if(old != null) { 126 throw new ConfigException(StringManager.getManager(WebServiceEndpoint.class).getString("cannotAddDuplicate", "RegistryLocation")); 127 } 128 return this.addValue(REGISTRY_LOCATION, value, overwrite); 129 } 130 131 public int removeRegistryLocation(RegistryLocation value){ 136 return this.removeValue(REGISTRY_LOCATION, value); 137 } 138 139 public int removeRegistryLocation(RegistryLocation value, boolean overwrite) 145 throws StaleWriteConfigException{ 146 return this.removeValue(REGISTRY_LOCATION, value, overwrite); 147 } 148 149 public RegistryLocation getRegistryLocationByConnectorResourceJndiName(String id) { 150 if (null != id) { id = id.trim(); } 151 RegistryLocation[] o = getRegistryLocation(); 152 if (o == null) return null; 153 154 for (int i=0; i < o.length; i++) { 155 if(o[i].getAttributeValue(Common.convertName(ServerTags.CONNECTOR_RESOURCE_JNDI_NAME)).equals(id)) { 156 return o[i]; 157 } 158 } 159 160 return null; 161 162 } 163 public void setTransformationRule(int index, TransformationRule value) { 165 this.setValue(TRANSFORMATION_RULE, index, value); 166 } 167 168 public TransformationRule getTransformationRule(int index) { 170 return (TransformationRule)this.getValue(TRANSFORMATION_RULE, index); 171 } 172 173 public void setTransformationRule(TransformationRule[] value) { 175 this.setValue(TRANSFORMATION_RULE, value); 176 } 177 178 public TransformationRule[] getTransformationRule() { 180 return (TransformationRule[])this.getValues(TRANSFORMATION_RULE); 181 } 182 183 public int sizeTransformationRule() { 185 return this.size(TRANSFORMATION_RULE); 186 } 187 188 public int addTransformationRule(TransformationRule value) 190 throws ConfigException{ 191 return addTransformationRule(value, true); 192 } 193 194 public int addTransformationRule(TransformationRule value, boolean overwrite) 196 throws ConfigException{ 197 TransformationRule old = getTransformationRuleByName(value.getName()); 198 if(old != null) { 199 throw new ConfigException(StringManager.getManager(WebServiceEndpoint.class).getString("cannotAddDuplicate", "TransformationRule")); 200 } 201 return this.addValue(TRANSFORMATION_RULE, value, overwrite); 202 } 203 204 public int removeTransformationRule(TransformationRule value){ 209 return this.removeValue(TRANSFORMATION_RULE, value); 210 } 211 212 public int removeTransformationRule(TransformationRule value, boolean overwrite) 218 throws StaleWriteConfigException{ 219 return this.removeValue(TRANSFORMATION_RULE, value, overwrite); 220 } 221 222 public TransformationRule getTransformationRuleByName(String id) { 223 if (null != id) { id = id.trim(); } 224 TransformationRule[] o = getTransformationRule(); 225 if (o == null) return null; 226 227 for (int i=0; i < o.length; i++) { 228 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 229 return o[i]; 230 } 231 } 232 233 return null; 234 235 } 236 240 public String getName() { 241 return getAttributeValue(ServerTags.NAME); 242 } 243 248 public void setName(String v, boolean overwrite) throws StaleWriteConfigException { 249 setAttributeValue(ServerTags.NAME, v, overwrite); 250 } 251 255 public void setName(String v) { 256 setAttributeValue(ServerTags.NAME, v); 257 } 258 262 public String getMonitoring() { 263 return getAttributeValue(ServerTags.MONITORING); 264 } 265 270 public void setMonitoring(String v, boolean overwrite) throws StaleWriteConfigException { 271 setAttributeValue(ServerTags.MONITORING, v, overwrite); 272 } 273 277 public void setMonitoring(String v) { 278 setAttributeValue(ServerTags.MONITORING, v); 279 } 280 283 public static String getDefaultMonitoring() { 284 return "OFF".trim(); 285 } 286 290 public String getMaxHistorySize() { 291 return getAttributeValue(ServerTags.MAX_HISTORY_SIZE); 292 } 293 298 public void setMaxHistorySize(String v, boolean overwrite) throws StaleWriteConfigException { 299 setAttributeValue(ServerTags.MAX_HISTORY_SIZE, v, overwrite); 300 } 301 305 public void setMaxHistorySize(String v) { 306 setAttributeValue(ServerTags.MAX_HISTORY_SIZE, v); 307 } 308 311 public static String getDefaultMaxHistorySize() { 312 return "25".trim(); 313 } 314 318 public boolean isJbiEnabled() { 319 return toBoolean(getAttributeValue(ServerTags.JBI_ENABLED)); 320 } 321 326 public void setJbiEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 327 setAttributeValue(ServerTags.JBI_ENABLED, ""+(v==true), overwrite); 328 } 329 333 public void setJbiEnabled(boolean v) { 334 setAttributeValue(ServerTags.JBI_ENABLED, ""+(v==true)); 335 } 336 339 public static String getDefaultJbiEnabled() { 340 return "true".trim(); 341 } 342 346 public RegistryLocation newRegistryLocation() { 347 return new RegistryLocation(); 348 } 349 350 354 public TransformationRule newTransformationRule() { 355 return new TransformationRule(); 356 } 357 358 363 protected String getRelativeXPath() { 364 String ret = null; 365 ret = "web-service-endpoint" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ; 366 return (null != ret ? ret.trim() : null); 367 } 368 369 372 public static String getDefaultAttributeValue(String attr) { 373 if(attr == null) return null; 374 attr = attr.trim(); 375 if(attr.equals(ServerTags.MONITORING)) return "OFF".trim(); 376 if(attr.equals(ServerTags.MAX_HISTORY_SIZE)) return "25".trim(); 377 if(attr.equals(ServerTags.JBI_ENABLED)) return "true".trim(); 378 return null; 379 } 380 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 382 comparators.add(c); 383 } 384 385 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 387 comparators.remove(c); 388 } 389 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 390 } 391 392 public void dump(StringBuffer str, String indent){ 394 String s; 395 Object o; 396 org.netbeans.modules.schema2beans.BaseBean n; 397 str.append(indent); 398 str.append("RegistryLocation["+this.sizeRegistryLocation()+"]"); for(int i=0; i<this.sizeRegistryLocation(); i++) 400 { 401 str.append(indent+"\t"); 402 str.append("#"+i+":"); 403 n = (org.netbeans.modules.schema2beans.BaseBean) this.getRegistryLocation(i); 404 if (n != null) 405 n.dump(str, indent + "\t"); else 407 str.append(indent+"\tnull"); this.dumpAttributes(REGISTRY_LOCATION, i, str, indent); 409 } 410 411 str.append(indent); 412 str.append("TransformationRule["+this.sizeTransformationRule()+"]"); for(int i=0; i<this.sizeTransformationRule(); i++) 414 { 415 str.append(indent+"\t"); 416 str.append("#"+i+":"); 417 n = (org.netbeans.modules.schema2beans.BaseBean) this.getTransformationRule(i); 418 if (n != null) 419 n.dump(str, indent + "\t"); else 421 str.append(indent+"\tnull"); this.dumpAttributes(TRANSFORMATION_RULE, i, str, indent); 423 } 424 425 } 426 public String dumpBeanNode(){ 427 StringBuffer str = new StringBuffer (); 428 str.append("WebServiceEndpoint\n"); this.dump(str, "\n "); return str.toString(); 431 }} 432 433 435 | Popular Tags |