001package org.kuali.common.util.log4j.model; 002 003import java.util.ArrayList; 004import java.util.Arrays; 005import java.util.List; 006 007import javax.xml.bind.annotation.XmlAccessType; 008import javax.xml.bind.annotation.XmlAccessorType; 009import javax.xml.bind.annotation.XmlAttribute; 010import javax.xml.bind.annotation.XmlElement; 011import javax.xml.bind.annotation.XmlRootElement; 012 013import org.kuali.common.util.CollectionUtils; 014 015/** 016 * @deprecated 017 */ 018@Deprecated 019@XmlRootElement(name = "log4j:configuration") 020@XmlAccessorType(XmlAccessType.PROPERTY) 021public class Log4JContext { 022 023 public static final Boolean DEFAULT_RESET_VALUE = false; 024 public static final Boolean DEFAULT_DEBUG_VALUE = false; 025 public static final Value DEFAULT_THRESHOLD_VALUE = Value.NULL; 026 027 Boolean reset = DEFAULT_RESET_VALUE; 028 Boolean debug = DEFAULT_DEBUG_VALUE; 029 Value threshold = DEFAULT_THRESHOLD_VALUE; 030 Logger root; 031 List<Appender> appenders = new ArrayList<Appender>(); 032 List<Logger> loggers = new ArrayList<Logger>(); 033 034 public Log4JContext() { 035 this(null, null); 036 } 037 038 public Log4JContext(List<Appender> appenders, Logger root) { 039 this(appenders, root, null); 040 } 041 042 public Log4JContext(List<Appender> appenders, Logger root, List<Logger> loggers) { 043 this(appenders, root, loggers, DEFAULT_RESET_VALUE); 044 } 045 046 public Log4JContext(List<Appender> appenders, Logger root, boolean reset) { 047 this(appenders, root, null, reset); 048 } 049 050 public Log4JContext(Appender appender, Logger root, boolean reset) { 051 this(Arrays.asList(appender), root, null, reset); 052 } 053 054 public Log4JContext(List<Appender> appenders, Logger root, List<Logger> loggers, boolean reset) { 055 super(); 056 this.appenders = appenders; 057 this.root = root; 058 this.loggers = loggers; 059 this.reset = reset; 060 } 061 062 public Log4JContext(Log4JContext context) { 063 super(); 064 this.reset = context.getReset(); 065 this.debug = context.getDebug(); 066 this.threshold = context.getThreshold(); 067 this.root = context.getRoot(); 068 069 for (Appender appender : CollectionUtils.toEmptyList(context.getAppenders())) { 070 this.appenders.add(new Appender(appender)); 071 } 072 073 for (Logger logger : CollectionUtils.toEmptyList(context.getLoggers())) { 074 this.loggers.add(new Logger(logger)); 075 } 076 } 077 078 @XmlAttribute 079 public Boolean getReset() { 080 return reset; 081 } 082 083 @XmlAttribute 084 public Boolean getDebug() { 085 return debug; 086 } 087 088 @XmlAttribute 089 public Value getThreshold() { 090 return threshold; 091 } 092 093 @XmlElement(name = "appender") 094 public List<Appender> getAppenders() { 095 return appenders; 096 } 097 098 @XmlElement(name = "logger") 099 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}