001/** 002 * Copyright 2011 The Kuali Foundation Licensed under the 003 * Educational Community License, Version 2.0 (the "License"); you may 004 * not use this file except in compliance with the License. You may 005 * obtain a copy of the License at 006 * 007 * http://www.osedu.org/licenses/ECL-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, 010 * software distributed under the License is distributed on an "AS IS" 011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 012 * or implied. See the License for the specific language governing 013 * permissions and limitations under the License. 014 */ 015 016package org.kuali.common.util.main.spring; 017 018import org.kuali.common.util.execute.Executable; 019import org.kuali.common.util.main.MainContext; 020import org.kuali.common.util.main.MainService; 021import org.kuali.common.util.properties.spring.DefaultPropertySourceConfig; 022import org.kuali.common.util.spring.SpringExecUtils; 023import org.kuali.common.util.spring.config.annotation.Execute; 024import org.kuali.common.util.spring.service.PropertySourceConfig; 025import org.kuali.common.util.spring.service.SpringService; 026import org.kuali.common.util.spring.service.SpringServiceConfig; 027import org.springframework.beans.factory.annotation.Autowired; 028import org.springframework.context.annotation.Configuration; 029import org.springframework.context.annotation.Import; 030import org.springframework.core.env.PropertySource; 031 032@Configuration 033@Import({ SpringServiceConfig.class, MainServiceConfig.class }) 034public abstract class AbstractMainRunner implements MainConfig { 035 036 protected Class<? extends PropertySourceConfig> getPropertySourceConfig() { 037 return DefaultPropertySourceConfig.class; 038 } 039 040 protected abstract Class<?> getConfig(); 041 042 @Autowired 043 MainContext mainContext; 044 045 @Autowired 046 MainService mainService; 047 048 @Autowired 049 SpringService service; 050 051 @Override 052 @Execute 053 public Executable main() { 054 PropertySource<?> source = mainService.getPropertySource(mainContext, getPropertySourceConfig()); 055 return SpringExecUtils.getSpringExecutable(service, source, getConfig()); 056 } 057 058}