1 23 24 28 29 package com.sun.enterprise.config.clientbeans; 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 ProviderConfig 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 REQUEST_POLICY = "RequestPolicy"; 50 static public final String RESPONSE_POLICY = "ResponsePolicy"; 51 static public final String ELEMENT_PROPERTY = "ElementProperty"; 52 53 public ProviderConfig() { 54 this(Common.USE_DEFAULT_VALUES); 55 } 56 57 public ProviderConfig(int options) 58 { 59 super(comparators, runtimeVersion); 60 initPropertyTables(3); 62 this.createProperty("request-policy", REQUEST_POLICY, 63 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 64 RequestPolicy.class); 65 this.createAttribute(REQUEST_POLICY, "auth-source", "AuthSource", 66 AttrProp.ENUM | AttrProp.IMPLIED, 67 new String [] { 68 "sender", 69 "content" 70 }, null); 71 this.createAttribute(REQUEST_POLICY, "auth-recipient", "AuthRecipient", 72 AttrProp.ENUM | AttrProp.IMPLIED, 73 new String [] { 74 "before-content", 75 "after-content" 76 }, null); 77 this.createProperty("response-policy", RESPONSE_POLICY, 78 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 79 ResponsePolicy.class); 80 this.createAttribute(RESPONSE_POLICY, "auth-source", "AuthSource", 81 AttrProp.ENUM | AttrProp.IMPLIED, 82 new String [] { 83 "sender", 84 "content" 85 }, null); 86 this.createAttribute(RESPONSE_POLICY, "auth-recipient", "AuthRecipient", 87 AttrProp.ENUM | AttrProp.IMPLIED, 88 new String [] { 89 "before-content", 90 "after-content" 91 }, null); 92 this.createProperty("property", ELEMENT_PROPERTY, 93 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 94 ElementProperty.class); 95 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 96 AttrProp.CDATA | AttrProp.REQUIRED, 97 null, null); 98 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 99 AttrProp.CDATA | AttrProp.REQUIRED, 100 null, null); 101 this.initialize(options); 102 } 103 104 void initialize(int options) { 106 107 } 108 109 public void setRequestPolicy(RequestPolicy value) { 111 this.setValue(REQUEST_POLICY, value); 112 } 113 114 public RequestPolicy getRequestPolicy() { 116 return (RequestPolicy)this.getValue(REQUEST_POLICY); 117 } 118 119 public void setResponsePolicy(ResponsePolicy value) { 121 this.setValue(RESPONSE_POLICY, value); 122 } 123 124 public ResponsePolicy getResponsePolicy() { 126 return (ResponsePolicy)this.getValue(RESPONSE_POLICY); 127 } 128 129 public void setElementProperty(int index, ElementProperty value) { 131 this.setValue(ELEMENT_PROPERTY, index, value); 132 } 133 134 public ElementProperty getElementProperty(int index) { 136 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 137 } 138 139 public void setElementProperty(ElementProperty[] value) { 141 this.setValue(ELEMENT_PROPERTY, value); 142 } 143 144 public ElementProperty[] getElementProperty() { 146 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 147 } 148 149 public int sizeElementProperty() { 151 return this.size(ELEMENT_PROPERTY); 152 } 153 154 public int addElementProperty(ElementProperty value) 156 throws ConfigException{ 157 return addElementProperty(value, true); 158 } 159 160 public int addElementProperty(ElementProperty value, boolean overwrite) 162 throws ConfigException{ 163 ElementProperty old = getElementPropertyByName(value.getName()); 164 if(old != null) { 165 throw new ConfigException(StringManager.getManager(ProviderConfig.class).getString("cannotAddDuplicate", "ElementProperty")); 166 } 167 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 168 } 169 170 public int removeElementProperty(ElementProperty value){ 175 return this.removeValue(ELEMENT_PROPERTY, value); 176 } 177 178 public int removeElementProperty(ElementProperty value, boolean overwrite) 184 throws StaleWriteConfigException{ 185 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 186 } 187 188 public ElementProperty getElementPropertyByName(String id) { 189 if (null != id) { id = id.trim(); } 190 ElementProperty[] o = getElementProperty(); 191 if (o == null) return null; 192 193 for (int i=0; i < o.length; i++) { 194 if(o[i].getAttributeValue(Common.convertName(ClientTags.NAME)).equals(id)) { 195 return o[i]; 196 } 197 } 198 199 return null; 200 201 } 202 206 public String getProviderId() { 207 return getAttributeValue(ClientTags.PROVIDER_ID); 208 } 209 214 public void setProviderId(String v, boolean overwrite) throws StaleWriteConfigException { 215 setAttributeValue(ClientTags.PROVIDER_ID, v, overwrite); 216 } 217 221 public void setProviderId(String v) { 222 setAttributeValue(ClientTags.PROVIDER_ID, v); 223 } 224 228 public String getProviderType() { 229 return getAttributeValue(ClientTags.PROVIDER_TYPE); 230 } 231 236 public void setProviderType(String v, boolean overwrite) throws StaleWriteConfigException { 237 setAttributeValue(ClientTags.PROVIDER_TYPE, v, overwrite); 238 } 239 243 public void setProviderType(String v) { 244 setAttributeValue(ClientTags.PROVIDER_TYPE, v); 245 } 246 250 public String getClassName() { 251 return getAttributeValue(ClientTags.CLASS_NAME); 252 } 253 258 public void setClassName(String v, boolean overwrite) throws StaleWriteConfigException { 259 setAttributeValue(ClientTags.CLASS_NAME, v, overwrite); 260 } 261 265 public void setClassName(String v) { 266 setAttributeValue(ClientTags.CLASS_NAME, v); 267 } 268 272 public RequestPolicy newRequestPolicy() { 273 return new RequestPolicy(); 274 } 275 276 280 public ResponsePolicy newResponsePolicy() { 281 return new ResponsePolicy(); 282 } 283 284 288 public ElementProperty newElementProperty() { 289 return new ElementProperty(); 290 } 291 292 297 protected String getRelativeXPath() { 298 String ret = null; 299 ret = "provider-config" + (canHaveSiblings() ? "[@provider-id='" + getAttributeValue("provider-id") +"']" : "") ; 300 return (null != ret ? ret.trim() : null); 301 } 302 303 306 public static String getDefaultAttributeValue(String attr) { 307 if(attr == null) return null; 308 attr = attr.trim(); 309 return null; 310 } 311 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 313 comparators.add(c); 314 } 315 316 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 318 comparators.remove(c); 319 } 320 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 321 } 322 323 public void dump(StringBuffer str, String indent){ 325 String s; 326 Object o; 327 org.netbeans.modules.schema2beans.BaseBean n; 328 str.append(indent); 329 str.append("RequestPolicy"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getRequestPolicy(); 331 if (n != null) 332 n.dump(str, indent + "\t"); else 334 str.append(indent+"\tnull"); this.dumpAttributes(REQUEST_POLICY, 0, str, indent); 336 337 str.append(indent); 338 str.append("ResponsePolicy"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getResponsePolicy(); 340 if (n != null) 341 n.dump(str, indent + "\t"); else 343 str.append(indent+"\tnull"); this.dumpAttributes(RESPONSE_POLICY, 0, str, indent); 345 346 str.append(indent); 347 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 349 { 350 str.append(indent+"\t"); 351 str.append("#"+i+":"); 352 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 353 if (n != null) 354 n.dump(str, indent + "\t"); else 356 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 358 } 359 360 } 361 public String dumpBeanNode(){ 362 StringBuffer str = new StringBuffer (); 363 str.append("ProviderConfig\n"); this.dump(str, "\n "); return str.toString(); 366 }} 367 368 370 | Popular Tags |