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 ManagementRule 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 EVENT = "Event"; 50 static public final String ACTION = "Action"; 51 static public final String DESCRIPTION = "Description"; 52 53 public ManagementRule() { 54 this(Common.USE_DEFAULT_VALUES); 55 } 56 57 public ManagementRule(int options) 58 { 59 super(comparators, runtimeVersion); 60 initPropertyTables(3); 62 this.createProperty("event", EVENT, 63 Common.TYPE_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 64 Event.class); 65 this.createAttribute(EVENT, "type", "Type", 66 AttrProp.CDATA | AttrProp.REQUIRED, 67 null, null); 68 this.createAttribute(EVENT, "record-event", "RecordEvent", 69 AttrProp.CDATA, 70 null, "true"); 71 this.createAttribute(EVENT, "level", "Level", 72 AttrProp.CDATA, 73 null, "INFO"); 74 this.createProperty("action", ACTION, 75 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 76 Action.class); 77 this.createAttribute(ACTION, "action-mbean-name", "ActionMbeanName", 78 AttrProp.CDATA | AttrProp.REQUIRED, 79 null, null); 80 this.createProperty("description", DESCRIPTION, 81 Common.TYPE_0_1 | Common.TYPE_STRING | Common.TYPE_KEY, 82 String .class); 83 this.initialize(options); 84 } 85 86 void initialize(int options) { 88 89 } 90 91 public void setEvent(Event value) { 93 this.setValue(EVENT, value); 94 } 95 96 public Event getEvent() { 98 return (Event)this.getValue(EVENT); 99 } 100 101 public void setAction(Action value) { 103 this.setValue(ACTION, value); 104 } 105 106 public Action getAction() { 108 return (Action)this.getValue(ACTION); 109 } 110 111 114 public String getDescription() { 115 return (String ) getValue(ServerTags.DESCRIPTION); 116 } 117 121 public void setDescription(String v){ 122 setValue(ServerTags.DESCRIPTION, (null != v ? v.trim() : null)); 123 } 124 128 public String getName() { 129 return getAttributeValue(ServerTags.NAME); 130 } 131 136 public void setName(String v, boolean overwrite) throws StaleWriteConfigException { 137 setAttributeValue(ServerTags.NAME, v, overwrite); 138 } 139 143 public void setName(String v) { 144 setAttributeValue(ServerTags.NAME, v); 145 } 146 150 public boolean isEnabled() { 151 return toBoolean(getAttributeValue(ServerTags.ENABLED)); 152 } 153 158 public void setEnabled(boolean v, boolean overwrite) throws StaleWriteConfigException { 159 setAttributeValue(ServerTags.ENABLED, ""+(v==true), overwrite); 160 } 161 165 public void setEnabled(boolean v) { 166 setAttributeValue(ServerTags.ENABLED, ""+(v==true)); 167 } 168 171 public static String getDefaultEnabled() { 172 return "true".trim(); 173 } 174 178 public Event newEvent() { 179 return new Event(); 180 } 181 182 186 public Action newAction() { 187 return new Action(); 188 } 189 190 195 protected String getRelativeXPath() { 196 String ret = null; 197 ret = "management-rule" + (canHaveSiblings() ? "[@name='" + getAttributeValue("name") +"']" : "") ; 198 return (null != ret ? ret.trim() : null); 199 } 200 201 204 public static String getDefaultAttributeValue(String attr) { 205 if(attr == null) return null; 206 attr = attr.trim(); 207 if(attr.equals(ServerTags.ENABLED)) return "true".trim(); 208 return null; 209 } 210 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 212 comparators.add(c); 213 } 214 215 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 217 comparators.remove(c); 218 } 219 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 220 } 221 222 public void dump(StringBuffer str, String indent){ 224 String s; 225 Object o; 226 org.netbeans.modules.schema2beans.BaseBean n; 227 str.append(indent); 228 str.append("Event"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getEvent(); 230 if (n != null) 231 n.dump(str, indent + "\t"); else 233 str.append(indent+"\tnull"); this.dumpAttributes(EVENT, 0, str, indent); 235 236 str.append(indent); 237 str.append("Action"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getAction(); 239 if (n != null) 240 n.dump(str, indent + "\t"); else 242 str.append(indent+"\tnull"); this.dumpAttributes(ACTION, 0, str, indent); 244 245 str.append(indent); 246 str.append("Description"); str.append(indent+"\t"); str.append("<"); o = this.getDescription(); 250 str.append((o==null?"null":o.toString().trim())); str.append(">\n"); this.dumpAttributes(DESCRIPTION, 0, str, indent); 253 254 } 255 public String dumpBeanNode(){ 256 StringBuffer str = new StringBuffer (); 257 str.append("ManagementRule\n"); this.dump(str, "\n "); return str.toString(); 260 }} 261 262 264 | Popular Tags |