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 AlertService 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 ALERT_SUBSCRIPTION = "AlertSubscription"; 50 static public final String ELEMENT_PROPERTY = "ElementProperty"; 51 52 public AlertService() { 53 this(Common.USE_DEFAULT_VALUES); 54 } 55 56 public AlertService(int options) 57 { 58 super(comparators, runtimeVersion); 59 initPropertyTables(2); 61 this.createProperty("alert-subscription", ALERT_SUBSCRIPTION, 62 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 63 AlertSubscription.class); 64 this.createAttribute(ALERT_SUBSCRIPTION, "name", "Name", 65 AttrProp.CDATA | AttrProp.REQUIRED, 66 null, null); 67 this.createProperty("property", ELEMENT_PROPERTY, 68 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 69 ElementProperty.class); 70 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 71 AttrProp.CDATA | AttrProp.REQUIRED, 72 null, null); 73 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 74 AttrProp.CDATA | AttrProp.REQUIRED, 75 null, null); 76 this.initialize(options); 77 } 78 79 void initialize(int options) { 81 82 } 83 84 public void setAlertSubscription(int index, AlertSubscription value) { 86 this.setValue(ALERT_SUBSCRIPTION, index, value); 87 } 88 89 public AlertSubscription getAlertSubscription(int index) { 91 return (AlertSubscription)this.getValue(ALERT_SUBSCRIPTION, index); 92 } 93 94 public void setAlertSubscription(AlertSubscription[] value) { 96 this.setValue(ALERT_SUBSCRIPTION, value); 97 } 98 99 public AlertSubscription[] getAlertSubscription() { 101 return (AlertSubscription[])this.getValues(ALERT_SUBSCRIPTION); 102 } 103 104 public int sizeAlertSubscription() { 106 return this.size(ALERT_SUBSCRIPTION); 107 } 108 109 public int addAlertSubscription(AlertSubscription value) 111 throws ConfigException{ 112 return addAlertSubscription(value, true); 113 } 114 115 public int addAlertSubscription(AlertSubscription value, boolean overwrite) 117 throws ConfigException{ 118 AlertSubscription old = getAlertSubscriptionByName(value.getName()); 119 if(old != null) { 120 throw new ConfigException(StringManager.getManager(AlertService.class).getString("cannotAddDuplicate", "AlertSubscription")); 121 } 122 return this.addValue(ALERT_SUBSCRIPTION, value, overwrite); 123 } 124 125 public int removeAlertSubscription(AlertSubscription value){ 130 return this.removeValue(ALERT_SUBSCRIPTION, value); 131 } 132 133 public int removeAlertSubscription(AlertSubscription value, boolean overwrite) 139 throws StaleWriteConfigException{ 140 return this.removeValue(ALERT_SUBSCRIPTION, value, overwrite); 141 } 142 143 public AlertSubscription getAlertSubscriptionByName(String id) { 144 if (null != id) { id = id.trim(); } 145 AlertSubscription[] o = getAlertSubscription(); 146 if (o == null) return null; 147 148 for (int i=0; i < o.length; i++) { 149 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 150 return o[i]; 151 } 152 } 153 154 return null; 155 156 } 157 public void setElementProperty(int index, ElementProperty value) { 159 this.setValue(ELEMENT_PROPERTY, index, value); 160 } 161 162 public ElementProperty getElementProperty(int index) { 164 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 165 } 166 167 public void setElementProperty(ElementProperty[] value) { 169 this.setValue(ELEMENT_PROPERTY, value); 170 } 171 172 public ElementProperty[] getElementProperty() { 174 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 175 } 176 177 public int sizeElementProperty() { 179 return this.size(ELEMENT_PROPERTY); 180 } 181 182 public int addElementProperty(ElementProperty value) 184 throws ConfigException{ 185 return addElementProperty(value, true); 186 } 187 188 public int addElementProperty(ElementProperty value, boolean overwrite) 190 throws ConfigException{ 191 ElementProperty old = getElementPropertyByName(value.getName()); 192 if(old != null) { 193 throw new ConfigException(StringManager.getManager(AlertService.class).getString("cannotAddDuplicate", "ElementProperty")); 194 } 195 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 196 } 197 198 public int removeElementProperty(ElementProperty value){ 203 return this.removeValue(ELEMENT_PROPERTY, value); 204 } 205 206 public int removeElementProperty(ElementProperty value, boolean overwrite) 212 throws StaleWriteConfigException{ 213 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 214 } 215 216 public ElementProperty getElementPropertyByName(String id) { 217 if (null != id) { id = id.trim(); } 218 ElementProperty[] o = getElementProperty(); 219 if (o == null) return null; 220 221 for (int i=0; i < o.length; i++) { 222 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 223 return o[i]; 224 } 225 } 226 227 return null; 228 229 } 230 234 public AlertSubscription newAlertSubscription() { 235 return new AlertSubscription(); 236 } 237 238 242 public ElementProperty newElementProperty() { 243 return new ElementProperty(); 244 } 245 246 251 protected String getRelativeXPath() { 252 String ret = null; 253 ret = "alert-service"; 254 return (null != ret ? ret.trim() : null); 255 } 256 257 260 public static String getDefaultAttributeValue(String attr) { 261 if(attr == null) return null; 262 attr = attr.trim(); 263 return null; 264 } 265 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 267 comparators.add(c); 268 } 269 270 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 272 comparators.remove(c); 273 } 274 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 275 } 276 277 public void dump(StringBuffer str, String indent){ 279 String s; 280 Object o; 281 org.netbeans.modules.schema2beans.BaseBean n; 282 str.append(indent); 283 str.append("AlertSubscription["+this.sizeAlertSubscription()+"]"); for(int i=0; i<this.sizeAlertSubscription(); i++) 285 { 286 str.append(indent+"\t"); 287 str.append("#"+i+":"); 288 n = (org.netbeans.modules.schema2beans.BaseBean) this.getAlertSubscription(i); 289 if (n != null) 290 n.dump(str, indent + "\t"); else 292 str.append(indent+"\tnull"); this.dumpAttributes(ALERT_SUBSCRIPTION, i, str, indent); 294 } 295 296 str.append(indent); 297 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 299 { 300 str.append(indent+"\t"); 301 str.append("#"+i+":"); 302 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 303 if (n != null) 304 n.dump(str, indent + "\t"); else 306 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 308 } 309 310 } 311 public String dumpBeanNode(){ 312 StringBuffer str = new StringBuffer (); 313 str.append("AlertService\n"); this.dump(str, "\n "); return str.toString(); 316 }} 317 318 320 | Popular Tags |