View Javadoc

1   package org.kuali.common.util.log4j;
2   
3   import org.kuali.common.util.Assert;
4   import org.kuali.common.util.execute.Executable;
5   import org.kuali.common.util.log4j.model.Log4JContext;
6   
7   public class Log4JExecutable implements Executable {
8   
9   	boolean skip;
10  	Log4JContext context;
11  	Log4JService service;
12  
13  	public Log4JExecutable() {
14  		this(null, null);
15  	}
16  
17  	public Log4JExecutable(Log4JService service, Log4JContext context) {
18  		this(service, context, false);
19  	}
20  
21  	public Log4JExecutable(Log4JService service, Log4JContext context, boolean skip) {
22  		super();
23  		this.service = service;
24  		this.context = context;
25  		this.skip = skip;
26  	}
27  
28  	@Override
29  	public void execute() {
30  
31  		// Might have nothing to do
32  		if (skip) {
33  			return;
34  		}
35  
36  		// Make sure we are configured correctly
37  		Assert.notNull(service, "service is null");
38  		Assert.notNull(context, "context is null");
39  
40  		// Configure log4j as indicated by the context
41  		service.configure(context);
42  	}
43  
44  	public boolean isSkip() {
45  		return skip;
46  	}
47  
48  	public void setSkip(boolean skip) {
49  		this.skip = skip;
50  	}
51  
52  	public Log4JService getService() {
53  		return service;
54  	}
55  
56  	public void setService(Log4JService service) {
57  		this.service = service;
58  	}
59  
60  	public Log4JContext getContext() {
61  		return context;
62  	}
63  
64  	public void setContext(Log4JContext context) {
65  		this.context = context;
66  	}
67  
68  }