View Javadoc
1   package org.kuali.common.util.log4j.model;
2   
3   import java.util.ArrayList;
4   import java.util.Arrays;
5   import java.util.List;
6   
7   import javax.xml.bind.annotation.XmlAccessType;
8   import javax.xml.bind.annotation.XmlAccessorType;
9   import javax.xml.bind.annotation.XmlAttribute;
10  import javax.xml.bind.annotation.XmlElement;
11  import javax.xml.bind.annotation.XmlRootElement;
12  
13  import org.kuali.common.util.CollectionUtils;
14  
15  /**
16   * @deprecated
17   */
18  @Deprecated
19  @XmlRootElement(name = "log4j:configuration")
20  @XmlAccessorType(XmlAccessType.PROPERTY)
21  public class Log4JContext {
22  
23  	public static final Boolean DEFAULT_RESET_VALUE = false;
24  	public static final Boolean DEFAULT_DEBUG_VALUE = false;
25  	public static final Value DEFAULT_THRESHOLD_VALUE = Value.NULL;
26  
27  	Boolean reset = DEFAULT_RESET_VALUE;
28  	Boolean debug = DEFAULT_DEBUG_VALUE;
29  	Value threshold = DEFAULT_THRESHOLD_VALUE;
30  	Logger root;
31  	List<Appender> appenders = new ArrayList<Appender>();
32  	List<Logger> loggers = new ArrayList<Logger>();
33  
34  	public Log4JContext() {
35  		this(null, null);
36  	}
37  
38  	public Log4JContext(List<Appender> appenders, Logger root) {
39  		this(appenders, root, null);
40  	}
41  
42  	public Log4JContext(List<Appender> appenders, Logger root, List<Logger> loggers) {
43  		this(appenders, root, loggers, DEFAULT_RESET_VALUE);
44  	}
45  
46  	public Log4JContext(List<Appender> appenders, Logger root, boolean reset) {
47  		this(appenders, root, null, reset);
48  	}
49  
50  	public Log4JContext(Appender appender, Logger root, boolean reset) {
51  		this(Arrays.asList(appender), root, null, reset);
52  	}
53  
54  	public Log4JContext(List<Appender> appenders, Logger root, List<Logger> loggers, boolean reset) {
55  		super();
56  		this.appenders = appenders;
57  		this.root = root;
58  		this.loggers = loggers;
59  		this.reset = reset;
60  	}
61  
62  	public Log4JContext(Log4JContext context) {
63  		super();
64  		this.reset = context.getReset();
65  		this.debug = context.getDebug();
66  		this.threshold = context.getThreshold();
67  		this.root = context.getRoot();
68  
69  		for (Appender appender : CollectionUtils.toEmptyList(context.getAppenders())) {
70  			this.appenders.add(new Appender(appender));
71  		}
72  
73  		for (Logger logger : CollectionUtils.toEmptyList(context.getLoggers())) {
74  			this.loggers.add(new Logger(logger));
75  		}
76  	}
77  
78  	@XmlAttribute
79  	public Boolean getReset() {
80  		return reset;
81  	}
82  
83  	@XmlAttribute
84  	public Boolean getDebug() {
85  		return debug;
86  	}
87  
88  	@XmlAttribute
89  	public Value getThreshold() {
90  		return threshold;
91  	}
92  
93  	@XmlElement(name = "appender")
94  	public List<Appender> getAppenders() {
95  		return appenders;
96  	}
97  
98  	@XmlElement(name = "logger")
99  	public List<Logger> getLoggers() {
100 		return loggers;
101 	}
102 
103 	@XmlElement
104 	public void setRoot(Logger root) {
105 		this.root = root;
106 	}
107 
108 	public void setReset(Boolean reset) {
109 		this.reset = reset;
110 	}
111 
112 	public void setDebug(Boolean debug) {
113 		this.debug = debug;
114 	}
115 
116 	public void setThreshold(Value threshold) {
117 		this.threshold = threshold;
118 	}
119 
120 	public void setAppenders(List<Appender> appenders) {
121 		this.appenders = appenders;
122 	}
123 
124 	public void setLoggers(List<Logger> loggers) {
125 		this.loggers = loggers;
126 	}
127 
128 	public Logger getRoot() {
129 		return root;
130 	}
131 
132 }