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 WebContainer 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 SESSION_CONFIG = "SessionConfig"; 50 static public final String ELEMENT_PROPERTY = "ElementProperty"; 51 52 public WebContainer() { 53 this(Common.USE_DEFAULT_VALUES); 54 } 55 56 public WebContainer(int options) 57 { 58 super(comparators, runtimeVersion); 59 initPropertyTables(2); 61 this.createProperty("session-config", SESSION_CONFIG, 62 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 63 SessionConfig.class); 64 this.createProperty("property", ELEMENT_PROPERTY, 65 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 66 ElementProperty.class); 67 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 68 AttrProp.CDATA | AttrProp.REQUIRED, 69 null, null); 70 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 71 AttrProp.CDATA | AttrProp.REQUIRED, 72 null, null); 73 this.initialize(options); 74 } 75 76 void initialize(int options) { 78 79 } 80 81 public void setSessionConfig(SessionConfig value) { 83 this.setValue(SESSION_CONFIG, value); 84 } 85 86 public SessionConfig getSessionConfig() { 88 return (SessionConfig)this.getValue(SESSION_CONFIG); 89 } 90 91 public void setElementProperty(int index, ElementProperty value) { 93 this.setValue(ELEMENT_PROPERTY, index, value); 94 } 95 96 public ElementProperty getElementProperty(int index) { 98 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 99 } 100 101 public void setElementProperty(ElementProperty[] value) { 103 this.setValue(ELEMENT_PROPERTY, value); 104 } 105 106 public ElementProperty[] getElementProperty() { 108 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 109 } 110 111 public int sizeElementProperty() { 113 return this.size(ELEMENT_PROPERTY); 114 } 115 116 public int addElementProperty(ElementProperty value) 118 throws ConfigException{ 119 return addElementProperty(value, true); 120 } 121 122 public int addElementProperty(ElementProperty value, boolean overwrite) 124 throws ConfigException{ 125 ElementProperty old = getElementPropertyByName(value.getName()); 126 if(old != null) { 127 throw new ConfigException(StringManager.getManager(WebContainer.class).getString("cannotAddDuplicate", "ElementProperty")); 128 } 129 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 130 } 131 132 public int removeElementProperty(ElementProperty value){ 137 return this.removeValue(ELEMENT_PROPERTY, value); 138 } 139 140 public int removeElementProperty(ElementProperty value, boolean overwrite) 146 throws StaleWriteConfigException{ 147 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 148 } 149 150 public ElementProperty getElementPropertyByName(String id) { 151 if (null != id) { id = id.trim(); } 152 ElementProperty[] o = getElementProperty(); 153 if (o == null) return null; 154 155 for (int i=0; i < o.length; i++) { 156 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 157 return o[i]; 158 } 159 } 160 161 return null; 162 163 } 164 168 public SessionConfig newSessionConfig() { 169 return new SessionConfig(); 170 } 171 172 176 public ElementProperty newElementProperty() { 177 return new ElementProperty(); 178 } 179 180 185 protected String getRelativeXPath() { 186 String ret = null; 187 ret = "web-container"; 188 return (null != ret ? ret.trim() : null); 189 } 190 191 194 public static String getDefaultAttributeValue(String attr) { 195 if(attr == null) return null; 196 attr = attr.trim(); 197 return null; 198 } 199 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 201 comparators.add(c); 202 } 203 204 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 206 comparators.remove(c); 207 } 208 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 209 } 210 211 public void dump(StringBuffer str, String indent){ 213 String s; 214 Object o; 215 org.netbeans.modules.schema2beans.BaseBean n; 216 str.append(indent); 217 str.append("SessionConfig"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getSessionConfig(); 219 if (n != null) 220 n.dump(str, indent + "\t"); else 222 str.append(indent+"\tnull"); this.dumpAttributes(SESSION_CONFIG, 0, str, indent); 224 225 str.append(indent); 226 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 228 { 229 str.append(indent+"\t"); 230 str.append("#"+i+":"); 231 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 232 if (n != null) 233 n.dump(str, indent + "\t"); else 235 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 237 } 238 239 } 240 public String dumpBeanNode(){ 241 StringBuffer str = new StringBuffer (); 242 str.append("WebContainer\n"); this.dump(str, "\n "); return str.toString(); 245 }} 246 247 249 | Popular Tags |