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 MonitoringService 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 MODULE_MONITORING_LEVELS = "ModuleMonitoringLevels"; 50 static public final String ELEMENT_PROPERTY = "ElementProperty"; 51 52 public MonitoringService() { 53 this(Common.USE_DEFAULT_VALUES); 54 } 55 56 public MonitoringService(int options) 57 { 58 super(comparators, runtimeVersion); 59 initPropertyTables(2); 61 this.createProperty("module-monitoring-levels", MODULE_MONITORING_LEVELS, 62 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 63 ModuleMonitoringLevels.class); 64 this.createAttribute(MODULE_MONITORING_LEVELS, "thread-pool", "ThreadPool", 65 AttrProp.CDATA, 66 null, "OFF"); 67 this.createAttribute(MODULE_MONITORING_LEVELS, "orb", "Orb", 68 AttrProp.CDATA, 69 null, "OFF"); 70 this.createAttribute(MODULE_MONITORING_LEVELS, "ejb-container", "EjbContainer", 71 AttrProp.CDATA, 72 null, "OFF"); 73 this.createAttribute(MODULE_MONITORING_LEVELS, "web-container", "WebContainer", 74 AttrProp.CDATA, 75 null, "OFF"); 76 this.createAttribute(MODULE_MONITORING_LEVELS, "transaction-service", "TransactionService", 77 AttrProp.CDATA, 78 null, "OFF"); 79 this.createAttribute(MODULE_MONITORING_LEVELS, "http-service", "HttpService", 80 AttrProp.CDATA, 81 null, "OFF"); 82 this.createAttribute(MODULE_MONITORING_LEVELS, "jdbc-connection-pool", "JdbcConnectionPool", 83 AttrProp.CDATA, 84 null, "OFF"); 85 this.createAttribute(MODULE_MONITORING_LEVELS, "connector-connection-pool", "ConnectorConnectionPool", 86 AttrProp.CDATA, 87 null, "OFF"); 88 this.createAttribute(MODULE_MONITORING_LEVELS, "connector-service", "ConnectorService", 89 AttrProp.CDATA, 90 null, "OFF"); 91 this.createAttribute(MODULE_MONITORING_LEVELS, "jms-service", "JmsService", 92 AttrProp.CDATA, 93 null, "OFF"); 94 this.createAttribute(MODULE_MONITORING_LEVELS, "jvm", "Jvm", 95 AttrProp.CDATA, 96 null, "OFF"); 97 this.createProperty("property", ELEMENT_PROPERTY, 98 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 99 ElementProperty.class); 100 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 101 AttrProp.CDATA | AttrProp.REQUIRED, 102 null, null); 103 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 104 AttrProp.CDATA | AttrProp.REQUIRED, 105 null, null); 106 this.initialize(options); 107 } 108 109 void initialize(int options) { 111 112 } 113 114 public void setModuleMonitoringLevels(ModuleMonitoringLevels value) { 116 this.setValue(MODULE_MONITORING_LEVELS, value); 117 } 118 119 public ModuleMonitoringLevels getModuleMonitoringLevels() { 121 return (ModuleMonitoringLevels)this.getValue(MODULE_MONITORING_LEVELS); 122 } 123 124 public void setElementProperty(int index, ElementProperty value) { 126 this.setValue(ELEMENT_PROPERTY, index, value); 127 } 128 129 public ElementProperty getElementProperty(int index) { 131 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 132 } 133 134 public void setElementProperty(ElementProperty[] value) { 136 this.setValue(ELEMENT_PROPERTY, value); 137 } 138 139 public ElementProperty[] getElementProperty() { 141 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 142 } 143 144 public int sizeElementProperty() { 146 return this.size(ELEMENT_PROPERTY); 147 } 148 149 public int addElementProperty(ElementProperty value) 151 throws ConfigException{ 152 return addElementProperty(value, true); 153 } 154 155 public int addElementProperty(ElementProperty value, boolean overwrite) 157 throws ConfigException{ 158 ElementProperty old = getElementPropertyByName(value.getName()); 159 if(old != null) { 160 throw new ConfigException(StringManager.getManager(MonitoringService.class).getString("cannotAddDuplicate", "ElementProperty")); 161 } 162 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 163 } 164 165 public int removeElementProperty(ElementProperty value){ 170 return this.removeValue(ELEMENT_PROPERTY, value); 171 } 172 173 public int removeElementProperty(ElementProperty value, boolean overwrite) 179 throws StaleWriteConfigException{ 180 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 181 } 182 183 public ElementProperty getElementPropertyByName(String id) { 184 if (null != id) { id = id.trim(); } 185 ElementProperty[] o = getElementProperty(); 186 if (o == null) return null; 187 188 for (int i=0; i < o.length; i++) { 189 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 190 return o[i]; 191 } 192 } 193 194 return null; 195 196 } 197 201 public ModuleMonitoringLevels newModuleMonitoringLevels() { 202 return new ModuleMonitoringLevels(); 203 } 204 205 209 public ElementProperty newElementProperty() { 210 return new ElementProperty(); 211 } 212 213 218 protected String getRelativeXPath() { 219 String ret = null; 220 ret = "monitoring-service"; 221 return (null != ret ? ret.trim() : null); 222 } 223 224 227 public static String getDefaultAttributeValue(String attr) { 228 if(attr == null) return null; 229 attr = attr.trim(); 230 return null; 231 } 232 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 234 comparators.add(c); 235 } 236 237 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 239 comparators.remove(c); 240 } 241 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 242 } 243 244 public void dump(StringBuffer str, String indent){ 246 String s; 247 Object o; 248 org.netbeans.modules.schema2beans.BaseBean n; 249 str.append(indent); 250 str.append("ModuleMonitoringLevels"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getModuleMonitoringLevels(); 252 if (n != null) 253 n.dump(str, indent + "\t"); else 255 str.append(indent+"\tnull"); this.dumpAttributes(MODULE_MONITORING_LEVELS, 0, str, indent); 257 258 str.append(indent); 259 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 261 { 262 str.append(indent+"\t"); 263 str.append("#"+i+":"); 264 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 265 if (n != null) 266 n.dump(str, indent + "\t"); else 268 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 270 } 271 272 } 273 public String dumpBeanNode(){ 274 StringBuffer str = new StringBuffer (); 275 str.append("MonitoringService\n"); this.dump(str, "\n "); return str.toString(); 278 }} 279 280 282 | Popular Tags |