View Javadoc
1   package org.kuali.common.util.log4j;
2   
3   import org.apache.commons.lang3.ObjectUtils;
4   import org.kuali.common.util.Assert;
5   import org.kuali.common.util.CollectionUtils;
6   import org.kuali.common.util.nullify.Nullifier;
7   
8   /**
9    * @deprecated
10   */
11  @Deprecated
12  public class Log4JContextNullifier implements Nullifier {
13  
14  	org.kuali.common.util.log4j.model.Log4JContext context;
15  
16  	public Log4JContextNullifier() {
17  		this(null);
18  	}
19  
20  	public Log4JContextNullifier(org.kuali.common.util.log4j.model.Log4JContext context) {
21  		super();
22  		this.context = context;
23  	}
24  
25  	@Override
26  	public void nullify() {
27  
28  		Assert.notNull(context);
29  
30  		nullify(context);
31  		nullify(context.getRoot());
32  		for (org.kuali.common.util.log4j.model.Logger logger : CollectionUtils.toEmptyList(context.getLoggers())) {
33  			nullify(logger);
34  		}
35  
36  	}
37  
38  	protected void nullify(org.kuali.common.util.log4j.model.Log4JContext context) {
39  		if (ObjectUtils.equals(org.kuali.common.util.log4j.model.Log4JContext.DEFAULT_RESET_VALUE, context.getReset())) {
40  			context.setReset(null);
41  		}
42  
43  		if (ObjectUtils.equals(org.kuali.common.util.log4j.model.Log4JContext.DEFAULT_DEBUG_VALUE, context.getDebug())) {
44  			context.setDebug(null);
45  		}
46  
47  		if (ObjectUtils.equals(org.kuali.common.util.log4j.model.Log4JContext.DEFAULT_THRESHOLD_VALUE, context.getThreshold())) {
48  			context.setThreshold(null);
49  		}
50  	}
51  
52  	protected void nullify(org.kuali.common.util.log4j.model.Logger logger) {
53  		if (logger == null) {
54  			return;
55  		}
56  		if (ObjectUtils.equals(org.kuali.common.util.log4j.model.Logger.DEFAULT_ADDITIVITY_VALUE, logger.getAdditivity())) {
57  			logger.setAdditivity(null);
58  		}
59  		if (logger.getLevel() == null) {
60  			return;
61  		}
62  		if (ObjectUtils.equals(org.kuali.common.util.log4j.model.Level.DEFAULT_JAVA_CLASS, logger.getLevel().getJavaClass())) {
63  			logger.getLevel().setJavaClass(null);
64  		}
65  	}
66  
67  	public org.kuali.common.util.log4j.model.Log4JContext getContext() {
68  		return context;
69  	}
70  
71  	public void setContext(org.kuali.common.util.log4j.model.Log4JContext context) {
72  		this.context = context;
73  	}
74  
75  }