1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.spring;
17
18 import java.util.Collections;
19 import java.util.List;
20
21 import org.kuali.common.util.CollectionUtils;
22 import org.kuali.common.util.spring.service.PropertySourceContext;
23 import org.kuali.common.util.spring.service.SpringContext;
24 import org.kuali.common.util.spring.service.SpringService;
25 import org.springframework.core.env.PropertySource;
26
27 public class SpringExecUtils {
28
29
30
31
32 public static SpringExecutable getSpringExecutable(SpringService service, PropertySource<?> source, Class<?> annotatedClass, List<String> activeProfiles) {
33 SpringContext context = getSinglePropertySourceContext(source);
34 context.setActiveProfiles(activeProfiles);
35 context.setAnnotatedClasses(CollectionUtils.asList(annotatedClass));
36 return new SpringExecutable(service, context);
37 }
38
39
40
41
42 public static SpringExecutable getSpringExecutable(SpringService service, PropertySource<?> source, Class<?> annotatedClass) {
43 return getSpringExecutable(service, source, annotatedClass, Collections.<String> emptyList());
44 }
45
46
47
48
49 @Deprecated
50 public static SpringExecutable getSpringExecutable(PropertySource<?> source, Class<?> annotatedClass) {
51 return getSpringExecutable(SpringExecutable.DEFAULT_SPRING_SERVICE, source, annotatedClass);
52 }
53
54
55
56
57 public static SpringContext getSinglePropertySourceContext(PropertySource<?> source) {
58
59
60 PropertySourceContext psc = new PropertySourceContext(source, true);
61
62
63 return new SpringContext(psc);
64 }
65
66 }