1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.main;
17
18 import java.util.Arrays;
19 import java.util.Collections;
20 import java.util.List;
21 import java.util.Map;
22
23 import org.kuali.common.util.Assert;
24 import org.kuali.common.util.spring.service.PropertySourceConfig;
25 import org.kuali.common.util.spring.service.PropertySourceService;
26 import org.springframework.core.env.PropertySource;
27
28 public class DefaultMainService implements MainService {
29
30 private final PropertySourceService service;
31
32 public DefaultMainService(PropertySourceService service) {
33 Assert.noNulls(service);
34 this.service = service;
35 }
36
37 @Override
38 public PropertySource<?> getPropertySource(MainContext context, Class<? extends PropertySourceConfig> config) {
39 Assert.noNulls(context, config);
40 Map<String, Object> beans = Collections.singletonMap(MainUtils.MAIN_CONTEXT_BEAN_NAME, (Object) context);
41 List<String> activeProfiles = Arrays.asList(MainUtils.MAIN_PROFILE_NAME);
42 return service.getPropertySource(beans, null, activeProfiles, config);
43 }
44
45 public PropertySourceService getService() {
46 return service;
47 }
48
49 }