View Javadoc
1   /**
2    * Copyright 2010-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.util.log4j.model;
17  
18  import java.util.ArrayList;
19  import java.util.Arrays;
20  import java.util.List;
21  
22  import javax.xml.bind.annotation.XmlAccessType;
23  import javax.xml.bind.annotation.XmlAccessorType;
24  import javax.xml.bind.annotation.XmlAttribute;
25  import javax.xml.bind.annotation.XmlElement;
26  import javax.xml.bind.annotation.XmlRootElement;
27  
28  import org.kuali.common.util.CollectionUtils;
29  
30  /**
31   * @deprecated
32   */
33  @Deprecated
34  @XmlRootElement(name = "log4j:configuration")
35  @XmlAccessorType(XmlAccessType.PROPERTY)
36  public class Log4JContext {
37  
38  	public static final Boolean DEFAULT_RESET_VALUE = false;
39  	public static final Boolean DEFAULT_DEBUG_VALUE = false;
40  	public static final Value DEFAULT_THRESHOLD_VALUE = Value.NULL;
41  
42  	Boolean reset = DEFAULT_RESET_VALUE;
43  	Boolean debug = DEFAULT_DEBUG_VALUE;
44  	Value threshold = DEFAULT_THRESHOLD_VALUE;
45  	Logger root;
46  	List<Appender> appenders = new ArrayList<Appender>();
47  	List<Logger> loggers = new ArrayList<Logger>();
48  
49  	public Log4JContext() {
50  		this(null, null);
51  	}
52  
53  	public Log4JContext(List<Appender> appenders, Logger root) {
54  		this(appenders, root, null);
55  	}
56  
57  	public Log4JContext(List<Appender> appenders, Logger root, List<Logger> loggers) {
58  		this(appenders, root, loggers, DEFAULT_RESET_VALUE);
59  	}
60  
61  	public Log4JContext(List<Appender> appenders, Logger root, boolean reset) {
62  		this(appenders, root, null, reset);
63  	}
64  
65  	public Log4JContext(Appender appender, Logger root, boolean reset) {
66  		this(Arrays.asList(appender), root, null, reset);
67  	}
68  
69  	public Log4JContext(List<Appender> appenders, Logger root, List<Logger> loggers, boolean reset) {
70  		super();
71  		this.appenders = appenders;
72  		this.root = root;
73  		this.loggers = loggers;
74  		this.reset = reset;
75  	}
76  
77  	public Log4JContext(Log4JContext context) {
78  		super();
79  		this.reset = context.getReset();
80  		this.debug = context.getDebug();
81  		this.threshold = context.getThreshold();
82  		this.root = context.getRoot();
83  
84  		for (Appender appender : CollectionUtils.toEmptyList(context.getAppenders())) {
85  			this.appenders.add(new Appender(appender));
86  		}
87  
88  		for (Logger logger : CollectionUtils.toEmptyList(context.getLoggers())) {
89  			this.loggers.add(new Logger(logger));
90  		}
91  	}
92  
93  	@XmlAttribute
94  	public Boolean getReset() {
95  		return reset;
96  	}
97  
98  	@XmlAttribute
99  	public Boolean getDebug() {
100 		return debug;
101 	}
102 
103 	@XmlAttribute
104 	public Value getThreshold() {
105 		return threshold;
106 	}
107 
108 	@XmlElement(name = "appender")
109 	public List<Appender> getAppenders() {
110 		return appenders;
111 	}
112 
113 	@XmlElement(name = "logger")
114 	public List<Logger> getLoggers() {
115 		return loggers;
116 	}
117 
118 	@XmlElement
119 	public void setRoot(Logger root) {
120 		this.root = root;
121 	}
122 
123 	public void setReset(Boolean reset) {
124 		this.reset = reset;
125 	}
126 
127 	public void setDebug(Boolean debug) {
128 		this.debug = debug;
129 	}
130 
131 	public void setThreshold(Value threshold) {
132 		this.threshold = threshold;
133 	}
134 
135 	public void setAppenders(List<Appender> appenders) {
136 		this.appenders = appenders;
137 	}
138 
139 	public void setLoggers(List<Logger> loggers) {
140 		this.loggers = loggers;
141 	}
142 
143 	public Logger getRoot() {
144 		return root;
145 	}
146 
147 }