001/**
002 * Copyright 2010-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.common.util.log4j.model;
017
018import java.util.ArrayList;
019import java.util.Arrays;
020import java.util.List;
021
022import javax.xml.bind.annotation.XmlAccessType;
023import javax.xml.bind.annotation.XmlAccessorType;
024import javax.xml.bind.annotation.XmlAttribute;
025import javax.xml.bind.annotation.XmlElement;
026import javax.xml.bind.annotation.XmlRootElement;
027
028import org.kuali.common.util.CollectionUtils;
029
030/**
031 * @deprecated
032 */
033@Deprecated
034@XmlRootElement(name = "log4j:configuration")
035@XmlAccessorType(XmlAccessType.PROPERTY)
036public class Log4JContext {
037
038        public static final Boolean DEFAULT_RESET_VALUE = false;
039        public static final Boolean DEFAULT_DEBUG_VALUE = false;
040        public static final Value DEFAULT_THRESHOLD_VALUE = Value.NULL;
041
042        Boolean reset = DEFAULT_RESET_VALUE;
043        Boolean debug = DEFAULT_DEBUG_VALUE;
044        Value threshold = DEFAULT_THRESHOLD_VALUE;
045        Logger root;
046        List<Appender> appenders = new ArrayList<Appender>();
047        List<Logger> loggers = new ArrayList<Logger>();
048
049        public Log4JContext() {
050                this(null, null);
051        }
052
053        public Log4JContext(List<Appender> appenders, Logger root) {
054                this(appenders, root, null);
055        }
056
057        public Log4JContext(List<Appender> appenders, Logger root, List<Logger> loggers) {
058                this(appenders, root, loggers, DEFAULT_RESET_VALUE);
059        }
060
061        public Log4JContext(List<Appender> appenders, Logger root, boolean reset) {
062                this(appenders, root, null, reset);
063        }
064
065        public Log4JContext(Appender appender, Logger root, boolean reset) {
066                this(Arrays.asList(appender), root, null, reset);
067        }
068
069        public Log4JContext(List<Appender> appenders, Logger root, List<Logger> loggers, boolean reset) {
070                super();
071                this.appenders = appenders;
072                this.root = root;
073                this.loggers = loggers;
074                this.reset = reset;
075        }
076
077        public Log4JContext(Log4JContext context) {
078                super();
079                this.reset = context.getReset();
080                this.debug = context.getDebug();
081                this.threshold = context.getThreshold();
082                this.root = context.getRoot();
083
084                for (Appender appender : CollectionUtils.toEmptyList(context.getAppenders())) {
085                        this.appenders.add(new Appender(appender));
086                }
087
088                for (Logger logger : CollectionUtils.toEmptyList(context.getLoggers())) {
089                        this.loggers.add(new Logger(logger));
090                }
091        }
092
093        @XmlAttribute
094        public Boolean getReset() {
095                return reset;
096        }
097
098        @XmlAttribute
099        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}