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.spring; 017 018import org.kuali.common.util.execute.Executable; 019import org.kuali.common.util.spring.service.DefaultSpringService; 020import org.kuali.common.util.spring.service.SpringContext; 021import org.kuali.common.util.spring.service.SpringService; 022import org.slf4j.Logger; 023import org.slf4j.LoggerFactory; 024 025public class SpringExecutable implements Executable { 026 027 private static final Logger logger = LoggerFactory.getLogger(SpringExecutable.class); 028 029 public static final SpringService DEFAULT_SPRING_SERVICE = new DefaultSpringService(); 030 031 SpringService service = DEFAULT_SPRING_SERVICE; 032 SpringContext context; 033 boolean skip; 034 035 public SpringExecutable() { 036 this(null); 037 } 038 039 public SpringExecutable(SpringContext context) { 040 this(DEFAULT_SPRING_SERVICE, context); 041 } 042 043 public SpringExecutable(SpringService service, SpringContext context) { 044 this.service = service; 045 this.context = context; 046 } 047 048 @Override 049 public void execute() { 050 if (skip) { 051 logger.info("Skipping execution"); 052 } else { 053 service.load(context); 054 } 055 } 056 057 public SpringService getService() { 058 return service; 059 } 060 061 public void setService(SpringService service) { 062 this.service = service; 063 } 064 065 public SpringContext getContext() { 066 return context; 067 } 068 069 public void setContext(SpringContext context) { 070 this.context = context; 071 } 072 073 public boolean isSkip() { 074 return skip; 075 } 076 077 public void setSkip(boolean skip) { 078 this.skip = skip; 079 } 080}