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