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 LogService 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_LOG_LEVELS = "ModuleLogLevels"; 50 static public final String ELEMENT_PROPERTY = "ElementProperty"; 51 52 public LogService() { 53 this(Common.USE_DEFAULT_VALUES); 54 } 55 56 public LogService(int options) 57 { 58 super(comparators, runtimeVersion); 59 initPropertyTables(2); 61 this.createProperty("module-log-levels", MODULE_LOG_LEVELS, 62 Common.TYPE_0_1 | Common.TYPE_BEAN | Common.TYPE_KEY, 63 ModuleLogLevels.class); 64 this.createAttribute(MODULE_LOG_LEVELS, "root", "Root", 65 AttrProp.CDATA, 66 null, "INFO"); 67 this.createAttribute(MODULE_LOG_LEVELS, "server", "Server", 68 AttrProp.CDATA, 69 null, "INFO"); 70 this.createAttribute(MODULE_LOG_LEVELS, "ejb-container", "EjbContainer", 71 AttrProp.CDATA, 72 null, "INFO"); 73 this.createAttribute(MODULE_LOG_LEVELS, "cmp-container", "CmpContainer", 74 AttrProp.CDATA, 75 null, "INFO"); 76 this.createAttribute(MODULE_LOG_LEVELS, "mdb-container", "MdbContainer", 77 AttrProp.CDATA, 78 null, "INFO"); 79 this.createAttribute(MODULE_LOG_LEVELS, "web-container", "WebContainer", 80 AttrProp.CDATA, 81 null, "INFO"); 82 this.createAttribute(MODULE_LOG_LEVELS, "classloader", "Classloader", 83 AttrProp.CDATA, 84 null, "INFO"); 85 this.createAttribute(MODULE_LOG_LEVELS, "configuration", "Configuration", 86 AttrProp.CDATA, 87 null, "INFO"); 88 this.createAttribute(MODULE_LOG_LEVELS, "naming", "Naming", 89 AttrProp.CDATA, 90 null, "INFO"); 91 this.createAttribute(MODULE_LOG_LEVELS, "security", "Security", 92 AttrProp.CDATA, 93 null, "INFO"); 94 this.createAttribute(MODULE_LOG_LEVELS, "jts", "Jts", 95 AttrProp.CDATA, 96 null, "INFO"); 97 this.createAttribute(MODULE_LOG_LEVELS, "jta", "Jta", 98 AttrProp.CDATA, 99 null, "INFO"); 100 this.createAttribute(MODULE_LOG_LEVELS, "admin", "Admin", 101 AttrProp.CDATA, 102 null, "INFO"); 103 this.createAttribute(MODULE_LOG_LEVELS, "deployment", "Deployment", 104 AttrProp.CDATA, 105 null, "INFO"); 106 this.createAttribute(MODULE_LOG_LEVELS, "verifier", "Verifier", 107 AttrProp.CDATA, 108 null, "INFO"); 109 this.createAttribute(MODULE_LOG_LEVELS, "jaxr", "Jaxr", 110 AttrProp.CDATA, 111 null, "INFO"); 112 this.createAttribute(MODULE_LOG_LEVELS, "jaxrpc", "Jaxrpc", 113 AttrProp.CDATA, 114 null, "INFO"); 115 this.createAttribute(MODULE_LOG_LEVELS, "saaj", "Saaj", 116 AttrProp.CDATA, 117 null, "INFO"); 118 this.createAttribute(MODULE_LOG_LEVELS, "corba", "Corba", 119 AttrProp.CDATA, 120 null, "INFO"); 121 this.createAttribute(MODULE_LOG_LEVELS, "javamail", "Javamail", 122 AttrProp.CDATA, 123 null, "INFO"); 124 this.createAttribute(MODULE_LOG_LEVELS, "jms", "Jms", 125 AttrProp.CDATA, 126 null, "INFO"); 127 this.createAttribute(MODULE_LOG_LEVELS, "connector", "Connector", 128 AttrProp.CDATA, 129 null, "INFO"); 130 this.createAttribute(MODULE_LOG_LEVELS, "jdo", "Jdo", 131 AttrProp.CDATA, 132 null, "INFO"); 133 this.createAttribute(MODULE_LOG_LEVELS, "cmp", "Cmp", 134 AttrProp.CDATA, 135 null, "INFO"); 136 this.createAttribute(MODULE_LOG_LEVELS, "util", "Util", 137 AttrProp.CDATA, 138 null, "INFO"); 139 this.createAttribute(MODULE_LOG_LEVELS, "resource-adapter", "ResourceAdapter", 140 AttrProp.CDATA, 141 null, "INFO"); 142 this.createAttribute(MODULE_LOG_LEVELS, "synchronization", "Synchronization", 143 AttrProp.CDATA, 144 null, "INFO"); 145 this.createAttribute(MODULE_LOG_LEVELS, "node-agent", "NodeAgent", 146 AttrProp.CDATA, 147 null, "INFO"); 148 this.createAttribute(MODULE_LOG_LEVELS, "self-management", "SelfManagement", 149 AttrProp.CDATA, 150 null, "INFO"); 151 this.createAttribute(MODULE_LOG_LEVELS, "group-management-service", "GroupManagementService", 152 AttrProp.CDATA, 153 null, "INFO"); 154 this.createAttribute(MODULE_LOG_LEVELS, "management-event", "ManagementEvent", 155 AttrProp.CDATA, 156 null, "INFO"); 157 this.createProperty("property", ELEMENT_PROPERTY, 158 Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY, 159 ElementProperty.class); 160 this.createAttribute(ELEMENT_PROPERTY, "name", "Name", 161 AttrProp.CDATA | AttrProp.REQUIRED, 162 null, null); 163 this.createAttribute(ELEMENT_PROPERTY, "value", "Value", 164 AttrProp.CDATA | AttrProp.REQUIRED, 165 null, null); 166 this.initialize(options); 167 } 168 169 void initialize(int options) { 171 172 } 173 174 public void setModuleLogLevels(ModuleLogLevels value) { 176 this.setValue(MODULE_LOG_LEVELS, value); 177 } 178 179 public ModuleLogLevels getModuleLogLevels() { 181 return (ModuleLogLevels)this.getValue(MODULE_LOG_LEVELS); 182 } 183 184 public void setElementProperty(int index, ElementProperty value) { 186 this.setValue(ELEMENT_PROPERTY, index, value); 187 } 188 189 public ElementProperty getElementProperty(int index) { 191 return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index); 192 } 193 194 public void setElementProperty(ElementProperty[] value) { 196 this.setValue(ELEMENT_PROPERTY, value); 197 } 198 199 public ElementProperty[] getElementProperty() { 201 return (ElementProperty[])this.getValues(ELEMENT_PROPERTY); 202 } 203 204 public int sizeElementProperty() { 206 return this.size(ELEMENT_PROPERTY); 207 } 208 209 public int addElementProperty(ElementProperty value) 211 throws ConfigException{ 212 return addElementProperty(value, true); 213 } 214 215 public int addElementProperty(ElementProperty value, boolean overwrite) 217 throws ConfigException{ 218 ElementProperty old = getElementPropertyByName(value.getName()); 219 if(old != null) { 220 throw new ConfigException(StringManager.getManager(LogService.class).getString("cannotAddDuplicate", "ElementProperty")); 221 } 222 return this.addValue(ELEMENT_PROPERTY, value, overwrite); 223 } 224 225 public int removeElementProperty(ElementProperty value){ 230 return this.removeValue(ELEMENT_PROPERTY, value); 231 } 232 233 public int removeElementProperty(ElementProperty value, boolean overwrite) 239 throws StaleWriteConfigException{ 240 return this.removeValue(ELEMENT_PROPERTY, value, overwrite); 241 } 242 243 public ElementProperty getElementPropertyByName(String id) { 244 if (null != id) { id = id.trim(); } 245 ElementProperty[] o = getElementProperty(); 246 if (o == null) return null; 247 248 for (int i=0; i < o.length; i++) { 249 if(o[i].getAttributeValue(Common.convertName(ServerTags.NAME)).equals(id)) { 250 return o[i]; 251 } 252 } 253 254 return null; 255 256 } 257 261 public String getFile() { 262 return getAttributeValue(ServerTags.FILE); 263 } 264 269 public void setFile(String v, boolean overwrite) throws StaleWriteConfigException { 270 setAttributeValue(ServerTags.FILE, v, overwrite); 271 } 272 276 public void setFile(String v) { 277 setAttributeValue(ServerTags.FILE, v); 278 } 279 283 public boolean isUseSystemLogging() { 284 return toBoolean(getAttributeValue(ServerTags.USE_SYSTEM_LOGGING)); 285 } 286 291 public void setUseSystemLogging(boolean v, boolean overwrite) throws StaleWriteConfigException { 292 setAttributeValue(ServerTags.USE_SYSTEM_LOGGING, ""+(v==true), overwrite); 293 } 294 298 public void setUseSystemLogging(boolean v) { 299 setAttributeValue(ServerTags.USE_SYSTEM_LOGGING, ""+(v==true)); 300 } 301 304 public static String getDefaultUseSystemLogging() { 305 return "false".trim(); 306 } 307 311 public String getLogHandler() { 312 return getAttributeValue(ServerTags.LOG_HANDLER); 313 } 314 319 public void setLogHandler(String v, boolean overwrite) throws StaleWriteConfigException { 320 setAttributeValue(ServerTags.LOG_HANDLER, v, overwrite); 321 } 322 326 public void setLogHandler(String v) { 327 setAttributeValue(ServerTags.LOG_HANDLER, v); 328 } 329 333 public String getLogFilter() { 334 return getAttributeValue(ServerTags.LOG_FILTER); 335 } 336 341 public void setLogFilter(String v, boolean overwrite) throws StaleWriteConfigException { 342 setAttributeValue(ServerTags.LOG_FILTER, v, overwrite); 343 } 344 348 public void setLogFilter(String v) { 349 setAttributeValue(ServerTags.LOG_FILTER, v); 350 } 351 355 public boolean isLogToConsole() { 356 return toBoolean(getAttributeValue(ServerTags.LOG_TO_CONSOLE)); 357 } 358 363 public void setLogToConsole(boolean v, boolean overwrite) throws StaleWriteConfigException { 364 setAttributeValue(ServerTags.LOG_TO_CONSOLE, ""+(v==true), overwrite); 365 } 366 370 public void setLogToConsole(boolean v) { 371 setAttributeValue(ServerTags.LOG_TO_CONSOLE, ""+(v==true)); 372 } 373 376 public static String getDefaultLogToConsole() { 377 return "false".trim(); 378 } 379 383 public String getLogRotationLimitInBytes() { 384 return getAttributeValue(ServerTags.LOG_ROTATION_LIMIT_IN_BYTES); 385 } 386 391 public void setLogRotationLimitInBytes(String v, boolean overwrite) throws StaleWriteConfigException { 392 setAttributeValue(ServerTags.LOG_ROTATION_LIMIT_IN_BYTES, v, overwrite); 393 } 394 398 public void setLogRotationLimitInBytes(String v) { 399 setAttributeValue(ServerTags.LOG_ROTATION_LIMIT_IN_BYTES, v); 400 } 401 404 public static String getDefaultLogRotationLimitInBytes() { 405 return "500000".trim(); 406 } 407 411 public String getLogRotationTimelimitInMinutes() { 412 return getAttributeValue(ServerTags.LOG_ROTATION_TIMELIMIT_IN_MINUTES); 413 } 414 419 public void setLogRotationTimelimitInMinutes(String v, boolean overwrite) throws StaleWriteConfigException { 420 setAttributeValue(ServerTags.LOG_ROTATION_TIMELIMIT_IN_MINUTES, v, overwrite); 421 } 422 426 public void setLogRotationTimelimitInMinutes(String v) { 427 setAttributeValue(ServerTags.LOG_ROTATION_TIMELIMIT_IN_MINUTES, v); 428 } 429 432 public static String getDefaultLogRotationTimelimitInMinutes() { 433 return "0".trim(); 434 } 435 439 public boolean isAlarms() { 440 return toBoolean(getAttributeValue(ServerTags.ALARMS)); 441 } 442 447 public void setAlarms(boolean v, boolean overwrite) throws StaleWriteConfigException { 448 setAttributeValue(ServerTags.ALARMS, ""+(v==true), overwrite); 449 } 450 454 public void setAlarms(boolean v) { 455 setAttributeValue(ServerTags.ALARMS, ""+(v==true)); 456 } 457 460 public static String getDefaultAlarms() { 461 return "false".trim(); 462 } 463 467 public String getRetainErrorStatisticsForHours() { 468 return getAttributeValue(ServerTags.RETAIN_ERROR_STATISTICS_FOR_HOURS); 469 } 470 475 public void setRetainErrorStatisticsForHours(String v, boolean overwrite) throws StaleWriteConfigException { 476 setAttributeValue(ServerTags.RETAIN_ERROR_STATISTICS_FOR_HOURS, v, overwrite); 477 } 478 482 public void setRetainErrorStatisticsForHours(String v) { 483 setAttributeValue(ServerTags.RETAIN_ERROR_STATISTICS_FOR_HOURS, v); 484 } 485 488 public static String getDefaultRetainErrorStatisticsForHours() { 489 return "5".trim(); 490 } 491 495 public ModuleLogLevels newModuleLogLevels() { 496 return new ModuleLogLevels(); 497 } 498 499 503 public ElementProperty newElementProperty() { 504 return new ElementProperty(); 505 } 506 507 512 protected String getRelativeXPath() { 513 String ret = null; 514 ret = "log-service"; 515 return (null != ret ? ret.trim() : null); 516 } 517 518 521 public static String getDefaultAttributeValue(String attr) { 522 if(attr == null) return null; 523 attr = attr.trim(); 524 if(attr.equals(ServerTags.USE_SYSTEM_LOGGING)) return "false".trim(); 525 if(attr.equals(ServerTags.LOG_TO_CONSOLE)) return "false".trim(); 526 if(attr.equals(ServerTags.LOG_ROTATION_LIMIT_IN_BYTES)) return "500000".trim(); 527 if(attr.equals(ServerTags.LOG_ROTATION_TIMELIMIT_IN_MINUTES)) return "0".trim(); 528 if(attr.equals(ServerTags.ALARMS)) return "false".trim(); 529 if(attr.equals(ServerTags.RETAIN_ERROR_STATISTICS_FOR_HOURS)) return "5".trim(); 530 return null; 531 } 532 public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 534 comparators.add(c); 535 } 536 537 public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) { 539 comparators.remove(c); 540 } 541 public void validate() throws org.netbeans.modules.schema2beans.ValidateException { 542 } 543 544 public void dump(StringBuffer str, String indent){ 546 String s; 547 Object o; 548 org.netbeans.modules.schema2beans.BaseBean n; 549 str.append(indent); 550 str.append("ModuleLogLevels"); n = (org.netbeans.modules.schema2beans.BaseBean) this.getModuleLogLevels(); 552 if (n != null) 553 n.dump(str, indent + "\t"); else 555 str.append(indent+"\tnull"); this.dumpAttributes(MODULE_LOG_LEVELS, 0, str, indent); 557 558 str.append(indent); 559 str.append("ElementProperty["+this.sizeElementProperty()+"]"); for(int i=0; i<this.sizeElementProperty(); i++) 561 { 562 str.append(indent+"\t"); 563 str.append("#"+i+":"); 564 n = (org.netbeans.modules.schema2beans.BaseBean) this.getElementProperty(i); 565 if (n != null) 566 n.dump(str, indent + "\t"); else 568 str.append(indent+"\tnull"); this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent); 570 } 571 572 } 573 public String dumpBeanNode(){ 574 StringBuffer str = new StringBuffer (); 575 str.append("LogService\n"); this.dump(str, "\n "); return str.toString(); 578 }} 579 580 582 | Popular Tags |