1
2
3
4
5
6
7
8
9
10
11
12
13
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 }