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.PropertiesService;
28 import org.kuali.common.util.properties.spring.DefaultPropertiesServiceConfig;
29 import org.kuali.common.util.spring.service.PropertySourceConfig;
30 import org.kuali.rice.core.api.config.property.Config;
31 import org.kuali.rice.core.api.config.property.ConfigContext;
32 import org.kuali.rice.core.api.config.property.ConfigPropertySource;
33 import org.kuali.rice.sql.spring.SourceSqlPropertyLocationsConfig;
34 import org.kuali.rice.xml.ingest.RiceConfigUtils;
35 import org.kuali.rice.xml.spring.IngestXmlPropertyLocationsConfig;
36 import org.slf4j.Logger;
37 import org.springframework.beans.factory.annotation.Autowired;
38 import org.springframework.context.annotation.Bean;
39 import org.springframework.context.annotation.Configuration;
40 import org.springframework.context.annotation.Import;
41 import org.springframework.core.env.PropertySource;
42
43
44
45
46
47
48
49 @Configuration
50 @Import({SampleAppProjectConfig.class, JdbcPropertyLocationsConfig.class, DefaultPropertiesServiceConfig.class,
51 SourceSqlPropertyLocationsConfig.class, IngestXmlPropertyLocationsConfig.class})
52 public class SampleAppPSC implements PropertySourceConfig {
53
54 private static final String KR_SAMPLE_APP_CONFIG = "classpath:META-INF/sample-app-config.xml";
55
56 private static final Logger logger = LoggerUtils.make();
57
58 @Autowired
59 JdbcPropertyLocationsConfig jdbcConfig;
60
61 @Autowired
62 SourceSqlPropertyLocationsConfig sourceSqlConfig;
63
64 @Autowired
65 IngestXmlPropertyLocationsConfig ingestXmlConfig;
66
67 @Autowired
68 PropertiesService service;
69
70 @Autowired
71 ServletContext servletContext;
72
73 @Override
74 @Bean
75 public PropertySource<?> propertySource() {
76
77 List<Location> locations = new ArrayList<Location>();
78 locations.addAll(jdbcConfig.jdbcPropertyLocations());
79 locations.addAll(sourceSqlConfig.riceSourceSqlPropertyLocations());
80 locations.addAll(ingestXmlConfig.riceIngestXmlPropertyLocations());
81
82
83
84 Properties properties = service.getProperties(locations);
85 logger.info("Loaded {} regular properties", properties.size());
86
87
88 Config rootCfg = RiceConfigUtils.getRootConfig(properties, KR_SAMPLE_APP_CONFIG, servletContext);
89
90
91 ConfigContext.init(rootCfg);
92
93
94 return new ConfigPropertySource("riceConfig", rootCfg);
95 }
96
97 }