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.log.log4j; 017 018import org.kuali.common.util.Assert; 019import org.kuali.common.util.execute.Executable; 020import org.kuali.common.util.log.log4j.model.Log4JConfiguration; 021 022public final class Log4JExecutable implements Executable { 023 024 public static final boolean DEFAULT_SKIP = false; 025 026 private final boolean skip; 027 private final Log4JConfiguration context; 028 private final Log4JService service; 029 030 public Log4JExecutable(Log4JService service, Log4JConfiguration context) { 031 this(service, context, DEFAULT_SKIP); 032 } 033 034 public Log4JExecutable(Log4JService service, Log4JConfiguration context, boolean skip) { 035 Assert.noNulls(service, context); 036 this.service = service; 037 this.context = context; 038 this.skip = skip; 039 } 040 041 @Override 042 public void execute() { 043 044 // Might have nothing to do 045 if (skip) { 046 return; 047 } 048 049 // Configure log4j as indicated by the context 050 service.configure(context); 051 } 052 053 public boolean isSkip() { 054 return skip; 055 } 056 057 public Log4JService getService() { 058 return service; 059 } 060 061 public Log4JConfiguration getContext() { 062 return context; 063 } 064 065}