KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > config > serverbeans > LogService


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /**
25  * This generated bean class LogService matches the DTD element log-service
26  *
27  */

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 JavaDoc;
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 // BEGIN_NOI18N
42

43 public class LogService extends ConfigBean implements Serializable JavaDoc
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 JavaDoc MODULE_LOG_LEVELS = "ModuleLogLevels";
50     static public final String JavaDoc 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         // Properties (see root bean comments for the bean graph)
60
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     // Setting the default values of the properties
170
void initialize(int options) {
171
172     }
173
174     // This attribute is optional
175
public void setModuleLogLevels(ModuleLogLevels value) {
176         this.setValue(MODULE_LOG_LEVELS, value);
177     }
178
179     // Get Method
180
public ModuleLogLevels getModuleLogLevels() {
181         return (ModuleLogLevels)this.getValue(MODULE_LOG_LEVELS);
182     }
183
184     // This attribute is an array, possibly empty
185
public void setElementProperty(int index, ElementProperty value) {
186         this.setValue(ELEMENT_PROPERTY, index, value);
187     }
188
189     // Get Method
190
public ElementProperty getElementProperty(int index) {
191         return (ElementProperty)this.getValue(ELEMENT_PROPERTY, index);
192     }
193
194     // This attribute is an array, possibly empty
195
public void setElementProperty(ElementProperty[] value) {
196         this.setValue(ELEMENT_PROPERTY, value);
197     }
198
199     // Getter Method
200
public ElementProperty[] getElementProperty() {
201         return (ElementProperty[])this.getValues(ELEMENT_PROPERTY);
202     }
203
204     // Return the number of properties
205
public int sizeElementProperty() {
206         return this.size(ELEMENT_PROPERTY);
207     }
208
209     // Add a new element returning its index in the list
210
public int addElementProperty(ElementProperty value)
211             throws ConfigException{
212         return addElementProperty(value, true);
213     }
214
215     // Add a new element returning its index in the list with a boolean flag
216
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     //
226
// Remove an element using its reference
227
// Returns the index the element had in the list
228
//
229
public int removeElementProperty(ElementProperty value){
230         return this.removeValue(ELEMENT_PROPERTY, value);
231     }
232
233     //
234
// Remove an element using its reference
235
// Returns the index the element had in the list
236
// with boolean overwrite
237
//
238
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 JavaDoc 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     /**
258     * Getter for File of the Element log-service
259     * @return the File of the Element log-service
260     */

261     public String JavaDoc getFile() {
262             return getAttributeValue(ServerTags.FILE);
263     }
264     /**
265     * Modify the File of the Element log-service
266     * @param v the new value
267     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
268     */

269     public void setFile(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
270         setAttributeValue(ServerTags.FILE, v, overwrite);
271     }
272     /**
273     * Modify the File of the Element log-service
274     * @param v the new value
275     */

276     public void setFile(String JavaDoc v) {
277         setAttributeValue(ServerTags.FILE, v);
278     }
279     /**
280     * Getter for UseSystemLogging of the Element log-service
281     * @return the UseSystemLogging of the Element log-service
282     */

283     public boolean isUseSystemLogging() {
284         return toBoolean(getAttributeValue(ServerTags.USE_SYSTEM_LOGGING));
285     }
286     /**
287     * Modify the UseSystemLogging of the Element log-service
288     * @param v the new value
289     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
290     */

291     public void setUseSystemLogging(boolean v, boolean overwrite) throws StaleWriteConfigException {
292         setAttributeValue(ServerTags.USE_SYSTEM_LOGGING, ""+(v==true), overwrite);
293     }
294     /**
295     * Modify the UseSystemLogging of the Element log-service
296     * @param v the new value
297     */

298     public void setUseSystemLogging(boolean v) {
299         setAttributeValue(ServerTags.USE_SYSTEM_LOGGING, ""+(v==true));
300     }
301     /**
302     * Get the default value of UseSystemLogging from dtd
303     */

304     public static String JavaDoc getDefaultUseSystemLogging() {
305         return "false".trim();
306     }
307     /**
308     * Getter for LogHandler of the Element log-service
309     * @return the LogHandler of the Element log-service
310     */

311     public String JavaDoc getLogHandler() {
312             return getAttributeValue(ServerTags.LOG_HANDLER);
313     }
314     /**
315     * Modify the LogHandler of the Element log-service
316     * @param v the new value
317     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
318     */

319     public void setLogHandler(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
320         setAttributeValue(ServerTags.LOG_HANDLER, v, overwrite);
321     }
322     /**
323     * Modify the LogHandler of the Element log-service
324     * @param v the new value
325     */

326     public void setLogHandler(String JavaDoc v) {
327         setAttributeValue(ServerTags.LOG_HANDLER, v);
328     }
329     /**
330     * Getter for LogFilter of the Element log-service
331     * @return the LogFilter of the Element log-service
332     */

333     public String JavaDoc getLogFilter() {
334             return getAttributeValue(ServerTags.LOG_FILTER);
335     }
336     /**
337     * Modify the LogFilter of the Element log-service
338     * @param v the new value
339     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
340     */

341     public void setLogFilter(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
342         setAttributeValue(ServerTags.LOG_FILTER, v, overwrite);
343     }
344     /**
345     * Modify the LogFilter of the Element log-service
346     * @param v the new value
347     */

348     public void setLogFilter(String JavaDoc v) {
349         setAttributeValue(ServerTags.LOG_FILTER, v);
350     }
351     /**
352     * Getter for LogToConsole of the Element log-service
353     * @return the LogToConsole of the Element log-service
354     */

355     public boolean isLogToConsole() {
356         return toBoolean(getAttributeValue(ServerTags.LOG_TO_CONSOLE));
357     }
358     /**
359     * Modify the LogToConsole of the Element log-service
360     * @param v the new value
361     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
362     */

363     public void setLogToConsole(boolean v, boolean overwrite) throws StaleWriteConfigException {
364         setAttributeValue(ServerTags.LOG_TO_CONSOLE, ""+(v==true), overwrite);
365     }
366     /**
367     * Modify the LogToConsole of the Element log-service
368     * @param v the new value
369     */

370     public void setLogToConsole(boolean v) {
371         setAttributeValue(ServerTags.LOG_TO_CONSOLE, ""+(v==true));
372     }
373     /**
374     * Get the default value of LogToConsole from dtd
375     */

376     public static String JavaDoc getDefaultLogToConsole() {
377         return "false".trim();
378     }
379     /**
380     * Getter for LogRotationLimitInBytes of the Element log-service
381     * @return the LogRotationLimitInBytes of the Element log-service
382     */

383     public String JavaDoc getLogRotationLimitInBytes() {
384         return getAttributeValue(ServerTags.LOG_ROTATION_LIMIT_IN_BYTES);
385     }
386     /**
387     * Modify the LogRotationLimitInBytes of the Element log-service
388     * @param v the new value
389     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
390     */

391     public void setLogRotationLimitInBytes(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
392         setAttributeValue(ServerTags.LOG_ROTATION_LIMIT_IN_BYTES, v, overwrite);
393     }
394     /**
395     * Modify the LogRotationLimitInBytes of the Element log-service
396     * @param v the new value
397     */

398     public void setLogRotationLimitInBytes(String JavaDoc v) {
399         setAttributeValue(ServerTags.LOG_ROTATION_LIMIT_IN_BYTES, v);
400     }
401     /**
402     * Get the default value of LogRotationLimitInBytes from dtd
403     */

404     public static String JavaDoc getDefaultLogRotationLimitInBytes() {
405         return "500000".trim();
406     }
407     /**
408     * Getter for LogRotationTimelimitInMinutes of the Element log-service
409     * @return the LogRotationTimelimitInMinutes of the Element log-service
410     */

411     public String JavaDoc getLogRotationTimelimitInMinutes() {
412         return getAttributeValue(ServerTags.LOG_ROTATION_TIMELIMIT_IN_MINUTES);
413     }
414     /**
415     * Modify the LogRotationTimelimitInMinutes of the Element log-service
416     * @param v the new value
417     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
418     */

419     public void setLogRotationTimelimitInMinutes(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
420         setAttributeValue(ServerTags.LOG_ROTATION_TIMELIMIT_IN_MINUTES, v, overwrite);
421     }
422     /**
423     * Modify the LogRotationTimelimitInMinutes of the Element log-service
424     * @param v the new value
425     */

426     public void setLogRotationTimelimitInMinutes(String JavaDoc v) {
427         setAttributeValue(ServerTags.LOG_ROTATION_TIMELIMIT_IN_MINUTES, v);
428     }
429     /**
430     * Get the default value of LogRotationTimelimitInMinutes from dtd
431     */

432     public static String JavaDoc getDefaultLogRotationTimelimitInMinutes() {
433         return "0".trim();
434     }
435     /**
436     * Getter for Alarms of the Element log-service
437     * @return the Alarms of the Element log-service
438     */

439     public boolean isAlarms() {
440         return toBoolean(getAttributeValue(ServerTags.ALARMS));
441     }
442     /**
443     * Modify the Alarms of the Element log-service
444     * @param v the new value
445     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
446     */

447     public void setAlarms(boolean v, boolean overwrite) throws StaleWriteConfigException {
448         setAttributeValue(ServerTags.ALARMS, ""+(v==true), overwrite);
449     }
450     /**
451     * Modify the Alarms of the Element log-service
452     * @param v the new value
453     */

454     public void setAlarms(boolean v) {
455         setAttributeValue(ServerTags.ALARMS, ""+(v==true));
456     }
457     /**
458     * Get the default value of Alarms from dtd
459     */

460     public static String JavaDoc getDefaultAlarms() {
461         return "false".trim();
462     }
463     /**
464     * Getter for RetainErrorStatisticsForHours of the Element log-service
465     * @return the RetainErrorStatisticsForHours of the Element log-service
466     */

467     public String JavaDoc getRetainErrorStatisticsForHours() {
468         return getAttributeValue(ServerTags.RETAIN_ERROR_STATISTICS_FOR_HOURS);
469     }
470     /**
471     * Modify the RetainErrorStatisticsForHours of the Element log-service
472     * @param v the new value
473     * @throws StaleWriteConfigException if overwrite is false and file changed on disk
474     */

475     public void setRetainErrorStatisticsForHours(String JavaDoc v, boolean overwrite) throws StaleWriteConfigException {
476         setAttributeValue(ServerTags.RETAIN_ERROR_STATISTICS_FOR_HOURS, v, overwrite);
477     }
478     /**
479     * Modify the RetainErrorStatisticsForHours of the Element log-service
480     * @param v the new value
481     */

482     public void setRetainErrorStatisticsForHours(String JavaDoc v) {
483         setAttributeValue(ServerTags.RETAIN_ERROR_STATISTICS_FOR_HOURS, v);
484     }
485     /**
486     * Get the default value of RetainErrorStatisticsForHours from dtd
487     */

488     public static String JavaDoc getDefaultRetainErrorStatisticsForHours() {
489         return "5".trim();
490     }
491     /**
492      * Create a new bean using it's default constructor.
493      * This does not add it to any bean graph.
494      */

495     public ModuleLogLevels newModuleLogLevels() {
496         return new ModuleLogLevels();
497     }
498
499     /**
500      * Create a new bean using it's default constructor.
501      * This does not add it to any bean graph.
502      */

503     public ElementProperty newElementProperty() {
504         return new ElementProperty();
505     }
506
507     /**
508     * get the xpath representation for this element
509     * returns something like abc[@name='value'] or abc
510     * depending on the type of the bean
511     */

512     protected String JavaDoc getRelativeXPath() {
513         String JavaDoc ret = null;
514         ret = "log-service";
515         return (null != ret ? ret.trim() : null);
516     }
517
518     /*
519     * generic method to get default value from dtd
520     */

521     public static String JavaDoc getDefaultAttributeValue(String JavaDoc 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     //
533
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
534         comparators.add(c);
535     }
536
537     //
538
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     // Dump the content of this bean returning it as a String
545
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
546         String JavaDoc s;
547         Object JavaDoc o;
548         org.netbeans.modules.schema2beans.BaseBean n;
549         str.append(indent);
550         str.append("ModuleLogLevels"); // NOI18N
551
n = (org.netbeans.modules.schema2beans.BaseBean) this.getModuleLogLevels();
552         if (n != null)
553             n.dump(str, indent + "\t"); // NOI18N
554
else
555             str.append(indent+"\tnull"); // NOI18N
556
this.dumpAttributes(MODULE_LOG_LEVELS, 0, str, indent);
557
558         str.append(indent);
559         str.append("ElementProperty["+this.sizeElementProperty()+"]"); // NOI18N
560
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"); // NOI18N
567
else
568                 str.append(indent+"\tnull"); // NOI18N
569
this.dumpAttributes(ELEMENT_PROPERTY, i, str, indent);
570         }
571
572     }
573     public String JavaDoc dumpBeanNode(){
574         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
575         str.append("LogService\n"); // NOI18N
576
this.dump(str, "\n "); // NOI18N
577
return str.toString();
578     }}
579
580 // END_NOI18N
581

582
Popular Tags