View Javadoc
1   /**
2    * Copyright 2010-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  }