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.log.log4j;
17  
18  import org.kuali.common.util.Assert;
19  import org.kuali.common.util.execute.Executable;
20  import org.kuali.common.util.log.log4j.model.Log4JConfiguration;
21  
22  public final class Log4JExecutable implements Executable {
23  
24  	public static final boolean DEFAULT_SKIP = false;
25  
26  	private final boolean skip;
27  	private final Log4JConfiguration context;
28  	private final Log4JService service;
29  
30  	public Log4JExecutable(Log4JService service, Log4JConfiguration context) {
31  		this(service, context, DEFAULT_SKIP);
32  	}
33  
34  	public Log4JExecutable(Log4JService service, Log4JConfiguration context, boolean skip) {
35  		Assert.noNulls(service, context);
36  		this.service = service;
37  		this.context = context;
38  		this.skip = skip;
39  	}
40  
41  	@Override
42  	public void execute() {
43  
44  		// Might have nothing to do
45  		if (skip) {
46  			return;
47  		}
48  
49  		// Configure log4j as indicated by the context
50  		service.configure(context);
51  	}
52  
53  	public boolean isSkip() {
54  		return skip;
55  	}
56  
57  	public Log4JService getService() {
58  		return service;
59  	}
60  
61  	public Log4JConfiguration getContext() {
62  		return context;
63  	}
64  
65  }