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 Configs 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 CONFIG = "Config"; 50 51 public Configs() { 52 this(Common.USE_DEFAULT_VALUES); 53 } 54 55 public Configs(int options) 56 { 57 super(comparators, runtimeVersion); 58 initPropertyTables(1); 60 this.createProperty("config", CONFIG, 61 Common.TYPE_1_N | Common.TYPE_BEAN | Common.TYPE_KEY, 62 Config.class); 63 this.createAttribute(CONFIG, "name", "Name", 64 AttrProp.CDATA | AttrProp.REQUIRED, 65 null, null); 66 this.createAttribute(CONFIG, "dynamic-reconfiguration-enabled", "DynamicReconfigurationEnabled", 67 AttrProp.CDATA, 68 null, "true"); 69 this.initialize(options); 70 } 71 72 void initialize(int options) { 74 75 } 76 77 public void setConfig(int index, Config value) { 79 this.setValue(CONFIG, index, value); 80 } 81 82 public Config getConfig(int index) { 84 return (Config)this.getValue(CONFIG, index); 85 } 86 87 public void setConfig(Config[] value) { 89 this.setValue(CONFIG, value); 90 } 91 92 public Config[] getConfig() { 94 return (Config[])this.getValues(CONFIG); 95 } 96 97 public int sizeConfig() { 99 return this.size(CONFIG); 100 } 101 102 public int addConfig(Config value) 104 throws ConfigException{ 105 return addConfig(value, true); 106 } 107 108 public int addConfig(Config value, boolean overwrite) 110 throws ConfigException{ 111 Config old = getConfigByName(value.getName()); 112 if(old != null) { 113 throw new ConfigException(StringManager.getManager(Configs.class).getString("cannotAddDuplicate", "Config")); 114 } 115 return this.addValue(CONFIG, value, overwrite); 116 } 117 118 public int removeConfig(Config value){ 123 return this.removeValue(CONFIG, value); 124 } 125 126 public int removeConfig(Config value, boolean overwrite) 132 throws StaleWriteConfigException{ 133 return this.removeValue(CONFIG, value, overwrite); 134 } 135 136 public Config getConfigByName(String id) { 137 if (null != id) { id = id.trim(); } 138 Config[] o = getConfig(); 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 Config newConfig() { 155 return new Config(); 156 } 157 158 163 protected String getRelativeXPath() { 164 String ret = null; 165 ret = "configs"; 166 return (null != ret ? ret.trim() : null); 167 } 168 169 172 public static String getDefaultAttributeValue(String attr) { 173 if(attr == null) return null; 174 attr = attr.trim(); 175 return null; 176 } 177 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 179 comparators.add(c); 180 } 181 182 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 184 comparators.remove(c); 185 } 186 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 187 } 188 189 public void dump(StringBuffer str, String indent){ 191 String s; 192 Object o; 193 org.netbeans.modules.schema2beans.BaseBean n; 194 str.append(indent); 195 str.append("Config["+this.sizeConfig()+"]"); for(int i=0; i<this.sizeConfig(); i++) 197 { 198 str.append(indent+"\t"); 199 str.append("#"+i+":"); 200 n = (org.netbeans.modules.schema2beans.BaseBean) this.getConfig(i); 201 if (n != null) 202 n.dump(str, indent + "\t"); else 204 str.append(indent+"\tnull"); this.dumpAttributes(CONFIG, i, str, indent); 206 } 207 208 } 209 public String dumpBeanNode(){ 210 StringBuffer str = new StringBuffer (); 211 str.append("Configs\n"); this.dump(str, "\n "); return str.toString(); 214 }} 215 216 218 | Popular Tags |