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 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.CDATA | AttrProp.IMPLIED, 67 null, null); 68 this.createAttribute(REQUEST_POLICY, "auth-recipient", "AuthRecipient", 69 AttrProp.CDATA | AttrProp.IMPLIED, 70 null, null); 71 this.createProperty("response-policy", RESPONSE_POLICY, 72 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 73 ResponsePolicy.class); 74 this.createAttribute(RESPONSE_POLICY, "auth-source", "AuthSource", 75 AttrProp.CDATA | AttrProp.IMPLIED, 76 null, null); 77 this.createAttribute(RESPONSE_POLICY, "auth-recipient", "AuthRecipient", 78 AttrProp.CDATA | AttrProp.IMPLIED, 79 null, null); 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 public void setRequestPolicy(RequestPolicy value) { 99 this.setValue(REQUEST_POLICY, value); 100 } 101 102 public RequestPolicy getRequestPolicy() { 104 return (RequestPolicy)this.getValue(REQUEST_POLICY); 105 } 106 107 public void setResponsePolicy(ResponsePolicy value) { 109 this.setValue(RESPONSE_POLICY, value); 110 } 111 112 public ResponsePolicy getResponsePolicy() { 114 return (ResponsePolicy)this.getValue(RESPONSE_POLICY); 115 } 116 117 public void setElementProperty(int index, ElementProperty value) { 119 this.setValue(ELEMENT_PROPERTY, index, value); 120 } 121 122 public ElementProperty getElementProperty(int index) { 124 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 125 } 126 127 public void setElementProperty(ElementProperty[] value) { 129 this.setValue(ELEMENT_PROPERTY, value); 130 } 131 132 public ElementProperty[] getElementProperty() { 134 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 135 } 136 137 public int sizeElementProperty() { 139 return this.size(ELEMENT_PROPERTY); 140 } 141 142 public int addElementProperty(ElementProperty value) 144 throws ConfigException{ 145 return addElementProperty(value, true); 146 } 147 148 public int addElementProperty(ElementProperty value, boolean overwrite) 150 throws ConfigException{ 151 ElementProperty old = getElementPropertyByName(value.getName()); 152 if(old != null) { 153 throw new ConfigException(StringManager.getManager(ProviderConfig.class).getString("cannotAddDuplicate", "ElementProperty")); 154 } 155 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 156 } 157 158 public int removeElementProperty(ElementProperty value){ 163 return this.removeValue(ELEMENT_PROPERTY, value); 164 } 165 166 public int removeElementProperty(ElementProperty value, boolean overwrite) 172 throws StaleWriteConfigException{ 173 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 174 } 175 176 public ElementProperty getElementPropertyByName(String id) { 177 if (null != id) { id = id.trim(); } 178 ElementProperty[] o = getElementProperty(); 179 if (o == null) return null; 180 181 for (int i=0; i < o.length; i++) { 182 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 183 return o[i]; 184 } 185 } 186 187 return null; 188 189 } 190 194 public String getProviderId() { 195 return getAttributeValue(ServerTags.PROVIDER_ID); 196 } 197 202 public void setProviderId(String v, boolean overwrite) throws StaleWriteConfigException { 203 setAttributeValue(ServerTags.PROVIDER_ID, v, overwrite); 204 } 205 209 public void setProviderId(String v) { 210 setAttributeValue(ServerTags.PROVIDER_ID, v); 211 } 212 216 public String getProviderType() { 217 return getAttributeValue(ServerTags.PROVIDER_TYPE); 218 } 219 224 public void setProviderType(String v, boolean overwrite) throws StaleWriteConfigException { 225 setAttributeValue(ServerTags.PROVIDER_TYPE, v, overwrite); 226 } 227 231 public void setProviderType(String v) { 232 setAttributeValue(ServerTags.PROVIDER_TYPE, v); 233 } 234 238 public String getClassName() { 239 return getAttributeValue(ServerTags.CLASS_NAME); 240 } 241 246 public void setClassName(String v, boolean overwrite) throws StaleWriteConfigException { 247 setAttributeValue(ServerTags.CLASS_NAME, v, overwrite); 248 } 249 253 public void setClassName(String v) { 254 setAttributeValue(ServerTags.CLASS_NAME, v); 255 } 256 260 public RequestPolicy newRequestPolicy() { 261 return new RequestPolicy(); 262 } 263 264 268 public ResponsePolicy newResponsePolicy() { 269 return new ResponsePolicy(); 270 } 271 272 276 public ElementProperty newElementProperty() { 277 return new ElementProperty(); 278 } 279 280 285 protected String getRelativeXPath() { 286 String ret = null; 287 ret = "provider-config" + (canHaveSiblings() ? "[@provider-id='" + getAttributeValue("provider-id") +"']" : "") ; 288 return (null != ret ? ret.trim() : null); 289 } 290 291 294 public static String getDefaultAttributeValue(String attr) { 295 if(attr == null) return null; 296 attr = attr.trim(); 297 return null; 298 } 299 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 301 comparators.add(c); 302 } 303 304 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 306 comparators.remove(c); 307 } 308 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 309 } 310 311 public void dump(StringBuffer str, String indent){ 313 String s; 314 Object o; 315 org.netbeans.modules.schema2beans.BaseBean n; 316 str.append(indent); 317 str.append("RequestPolicy"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getRequestPolicy(); 319 if (n != null) 320 n.dump(str, indent + "\t"); else 322 str.append(indent+"\tnull"); this.dumpAttributes(REQUEST_POLICY, 0, str, indent); 324 325 str.append(indent); 326 str.append("ResponsePolicy"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getResponsePolicy(); 328 if (n != null) 329 n.dump(str, indent + "\t"); else 331 str.append(indent+"\tnull"); this.dumpAttributes(RESPONSE_POLICY, 0, str, indent); 333 334 str.append(indent); 335 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 337 { 338 str.append(indent+"\t"); 339 str.append("#"+i+":"); 340 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 341 if (n != null) 342 n.dump(str, indent + "\t"); else 344 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 346 } 347 348 } 349 public String dumpBeanNode(){ 350 StringBuffer str = new StringBuffer (); 351 str.append("ProviderConfig\n"); this.dump(str, "\n "); return str.toString(); 354 }} 355 356 358 | Popular Tags |