View Javadoc
1   /**
2    * Copyright 2011 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.common.util.main.spring;
17  
18  import org.kuali.common.util.execute.Executable;
19  import org.kuali.common.util.main.MainContext;
20  import org.kuali.common.util.main.MainService;
21  import org.kuali.common.util.properties.spring.DefaultPropertySourceConfig;
22  import org.kuali.common.util.spring.SpringExecUtils;
23  import org.kuali.common.util.spring.config.annotation.Execute;
24  import org.kuali.common.util.spring.service.PropertySourceConfig;
25  import org.kuali.common.util.spring.service.SpringService;
26  import org.kuali.common.util.spring.service.SpringServiceConfig;
27  import org.springframework.beans.factory.annotation.Autowired;
28  import org.springframework.context.annotation.Configuration;
29  import org.springframework.context.annotation.Import;
30  import org.springframework.core.env.PropertySource;
31  
32  @Configuration
33  @Import({ SpringServiceConfig.class, MainServiceConfig.class })
34  public abstract class AbstractMainRunner implements MainConfig {
35  
36  	protected Class<? extends PropertySourceConfig> getPropertySourceConfig() {
37  		return DefaultPropertySourceConfig.class;
38  	}
39  
40  	protected abstract Class<?> getConfig();
41  
42  	@Autowired
43  	MainContext mainContext;
44  
45  	@Autowired
46  	MainService mainService;
47  
48  	@Autowired
49  	SpringService service;
50  
51  	@Override
52  	@Execute
53  	public Executable main() {
54  		PropertySource<?> source = mainService.getPropertySource(mainContext, getPropertySourceConfig());
55  		return SpringExecUtils.getSpringExecutable(service, source, getConfig());
56  	}
57  
58  }