001package org.kuali.common.util.log.log4j;
002
003import org.kuali.common.util.Assert;
004import org.kuali.common.util.execute.Executable;
005import org.kuali.common.util.log.log4j.model.Log4JConfiguration;
006
007public final class Log4JExecutable implements Executable {
008
009        public static final boolean DEFAULT_SKIP = false;
010
011        private final boolean skip;
012        private final Log4JConfiguration context;
013        private final Log4JService service;
014
015        public Log4JExecutable(Log4JService service, Log4JConfiguration context) {
016                this(service, context, DEFAULT_SKIP);
017        }
018
019        public Log4JExecutable(Log4JService service, Log4JConfiguration context, boolean skip) {
020                Assert.noNulls(service, context);
021                this.service = service;
022                this.context = context;
023                this.skip = skip;
024        }
025
026        @Override
027        public void execute() {
028
029                // Might have nothing to do
030                if (skip) {
031                        return;
032                }
033
034                // Configure log4j as indicated by the context
035                service.configure(context);
036        }
037
038        public boolean isSkip() {
039                return skip;
040        }
041
042        public Log4JService getService() {
043                return service;
044        }
045
046        public Log4JConfiguration getContext() {
047                return context;
048        }
049
050}