1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.config;
17
18 import java.util.ArrayList;
19 import java.util.List;
20 import java.util.Properties;
21
22 import javax.servlet.ServletContext;
23
24 import org.kuali.common.jdbc.project.spring.JdbcPropertyLocationsConfig;
25 import org.kuali.common.util.log.LoggerUtils;
26 import org.kuali.common.util.properties.Location;
27 import org.kuali.common.util.properties.PropertiesLocationService;
28 import org.kuali.common.util.properties.PropertiesService;
29 import org.kuali.common.util.properties.spring.DefaultPropertiesServiceConfig;
30 import org.kuali.common.util.properties.spring.PropertiesLocationServiceConfig;
31 import org.kuali.common.util.spring.service.PropertySourceConfig;
32 import org.kuali.rice.core.api.config.property.Config;
33 import org.kuali.rice.core.api.config.property.ConfigContext;
34 import org.kuali.rice.core.api.config.property.ConfigPropertySource;
35 import org.kuali.rice.sql.spring.SourceSqlPropertyLocationsConfig;
36 import org.kuali.rice.xml.ingest.RiceConfigUtils;
37 import org.kuali.rice.xml.spring.IngestXmlPropertyLocationsConfig;
38 import org.slf4j.Logger;
39 import org.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.context.annotation.Bean;
41 import org.springframework.context.annotation.Configuration;
42 import org.springframework.context.annotation.Import;
43 import org.springframework.core.env.PropertySource;
44
45
46
47
48
49
50 @Configuration
51 @Import({ KradSampleAppProjectConfig.class, JdbcPropertyLocationsConfig.class, SourceSqlPropertyLocationsConfig.class, IngestXmlPropertyLocationsConfig.class,
52 PropertiesLocationServiceConfig.class, DefaultPropertiesServiceConfig.class })
53 public class KradSampleAppPSC implements PropertySourceConfig {
54
55 private static final String KRAD_SAMPLE_APP_CONFIG = "classpath:META-INF/krad-sampleapp-config.xml";
56
57 private static final Logger logger = LoggerUtils.make();
58
59 @Autowired
60 JdbcPropertyLocationsConfig jdbcConfig;
61
62 @Autowired
63 SourceSqlPropertyLocationsConfig sourceSqlConfig;
64
65 @Autowired
66 IngestXmlPropertyLocationsConfig ingestXmlConfig;
67
68 @Autowired
69 PropertiesLocationService locationService;
70
71 @Autowired
72 PropertiesService service;
73
74 @Autowired
75 ServletContext servletContext;
76
77 @Override
78 @Bean
79 public PropertySource<?> propertySource() {
80
81 List<Location> locations = new ArrayList<Location>();
82 locations.addAll(jdbcConfig.jdbcPropertyLocations());
83 locations.addAll(sourceSqlConfig.riceSourceSqlPropertyLocations());
84 locations.addAll(ingestXmlConfig.riceIngestXmlPropertyLocations());
85
86
87
88 Properties properties = service.getProperties(locations);
89 logger.info("Loaded {} regular properties", properties.size());
90
91
92 Config rootCfg = RiceConfigUtils.getRootConfig(properties, KRAD_SAMPLE_APP_CONFIG, servletContext);
93
94
95 ConfigContext.init(rootCfg);
96
97
98 return new ConfigPropertySource("riceConfig", rootCfg);
99 }
100
101 }