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 ResourceAdapterConfig 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 ELEMENT_PROPERTY = "ElementProperty"; 50 51 public ResourceAdapterConfig() { 52 this(Common.USE_DEFAULT_VALUES); 53 } 54 55 public ResourceAdapterConfig(int options) 56 { 57 super(comparators, runtimeVersion); 58 initPropertyTables(1); 60 this.createProperty("property", ELEMENT_PROPERTY, 61 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 62 ElementProperty.class); 63 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 64 AttrProp.CDATA | AttrProp.REQUIRED, 65 null, null); 66 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 67 AttrProp.CDATA | AttrProp.REQUIRED, 68 null, null); 69 this.initialize(options); 70 } 71 72 void initialize(int options) { 74 75 } 76 77 public void setElementProperty(int index, ElementProperty value) { 79 this.setValue(ELEMENT_PROPERTY, index, value); 80 } 81 82 public ElementProperty getElementProperty(int index) { 84 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 85 } 86 87 public void setElementProperty(ElementProperty[] value) { 89 this.setValue(ELEMENT_PROPERTY, value); 90 } 91 92 public ElementProperty[] getElementProperty() { 94 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 95 } 96 97 public int sizeElementProperty() { 99 return this.size(ELEMENT_PROPERTY); 100 } 101 102 public int addElementProperty(ElementProperty value) 104 throws ConfigException{ 105 return addElementProperty(value, true); 106 } 107 108 public int addElementProperty(ElementProperty value, boolean overwrite) 110 throws ConfigException{ 111 ElementProperty old = getElementPropertyByName(value.getName()); 112 if(old != null) { 113 throw new ConfigException(StringManager.getManager(ResourceAdapterConfig.class).getString("cannotAddDuplicate", "ElementProperty")); 114 } 115 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 116 } 117 118 public int removeElementProperty(ElementProperty value){ 123 return this.removeValue(ELEMENT_PROPERTY, value); 124 } 125 126 public int removeElementProperty(ElementProperty value, boolean overwrite) 132 throws StaleWriteConfigException{ 133 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 134 } 135 136 public ElementProperty getElementPropertyByName(String id) { 137 if (null != id) { id = id.trim(); } 138 ElementProperty[] o = getElementProperty(); 139 if (o == null) return null; 140 141 for (int i=0; i < o.length; i++) { 142 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 143 return o[i]; 144 } 145 } 146 147 return null; 148 149 } 150 154 public String getName() { 155 return getAttributeValue(ServerTags.NAME); 156 } 157 162 public void setName(String v, boolean overwrite) throws StaleWriteConfigException { 163 setAttributeValue(ServerTags.NAME, v, overwrite); 164 } 165 169 public void setName(String v) { 170 setAttributeValue(ServerTags.NAME, v); 171 } 172 176 public String getThreadPoolIds() { 177 return getAttributeValue(ServerTags.THREAD_POOL_IDS); 178 } 179 184 public void setThreadPoolIds(String v, boolean overwrite) throws StaleWriteConfigException { 185 setAttributeValue(ServerTags.THREAD_POOL_IDS, v, overwrite); 186 } 187 191 public void setThreadPoolIds(String v) { 192 setAttributeValue(ServerTags.THREAD_POOL_IDS, v); 193 } 194 198 public String getObjectType() { 199 return getAttributeValue(ServerTags.OBJECT_TYPE); 200 } 201 206 public void setObjectType(String v, boolean overwrite) throws StaleWriteConfigException { 207 setAttributeValue(ServerTags.OBJECT_TYPE, v, overwrite); 208 } 209 213 public void setObjectType(String v) { 214 setAttributeValue(ServerTags.OBJECT_TYPE, v); 215 } 216 219 public static String getDefaultObjectType() { 220 return "user".trim(); 221 } 222 226 public String getResourceAdapterName() { 227 return getAttributeValue(ServerTags.RESOURCE_ADAPTER_NAME); 228 } 229 234 public void setResourceAdapterName(String v, boolean overwrite) throws StaleWriteConfigException { 235 setAttributeValue(ServerTags.RESOURCE_ADAPTER_NAME, v, overwrite); 236 } 237 241 public void setResourceAdapterName(String v) { 242 setAttributeValue(ServerTags.RESOURCE_ADAPTER_NAME, v); 243 } 244 248 public ElementProperty newElementProperty() { 249 return new ElementProperty(); 250 } 251 252 257 protected String getRelativeXPath() { 258 String ret = null; 259 ret = "resource-adapter-config" + (canHaveSiblings() ? "[@resource-adapter-name='" + getAttributeValue("resource-adapter-name") +"']" : "") ; 260 return (null != ret ? ret.trim() : null); 261 } 262 263 266 public static String getDefaultAttributeValue(String attr) { 267 if(attr == null) return null; 268 attr = attr.trim(); 269 if(attr.equals(ServerTags.OBJECT_TYPE)) return "user".trim(); 270 return null; 271 } 272 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 274 comparators.add(c); 275 } 276 277 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 279 comparators.remove(c); 280 } 281 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 282 } 283 284 public void dump(StringBuffer str, String indent){ 286 String s; 287 Object o; 288 org.netbeans.modules.schema2beans.BaseBean n; 289 str.append(indent); 290 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 292 { 293 str.append(indent+"\t"); 294 str.append("#"+i+":"); 295 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 296 if (n != null) 297 n.dump(str, indent + "\t"); else 299 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 301 } 302 303 } 304 public String dumpBeanNode(){ 305 StringBuffer str = new StringBuffer (); 306 str.append("ResourceAdapterConfig\n"); this.dump(str, "\n "); return str.toString(); 309 }} 310 311 313 | Popular Tags |