1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.xml.spring;
17
18 import java.util.List;
19 import java.util.Properties;
20
21 import com.google.common.collect.Lists;
22 import org.kuali.common.jdbc.project.spring.JdbcPropertyLocationsConfig;
23 import org.kuali.common.util.project.ProjectUtils;
24 import org.kuali.common.util.properties.Location;
25 import org.kuali.common.util.properties.PropertiesService;
26 import org.kuali.common.util.properties.spring.DefaultPropertiesServiceConfig;
27 import org.kuali.common.util.spring.service.PropertySourceConfig;
28 import org.kuali.rice.core.api.config.property.Config;
29 import org.kuali.rice.sql.spring.SourceSqlPropertyLocationsConfig;
30 import org.kuali.rice.xml.ingest.RiceConfigUtils;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.context.annotation.Bean;
33 import org.springframework.context.annotation.Configuration;
34 import org.springframework.context.annotation.Import;
35 import org.springframework.core.env.PropertiesPropertySource;
36 import org.springframework.core.env.PropertySource;
37
38
39
40
41
42
43 @Configuration
44 @Import({ JdbcPropertyLocationsConfig.class, DefaultPropertiesServiceConfig.class, SourceSqlPropertyLocationsConfig.class, IngestXmlPropertyLocationsConfig.class })
45 public class IngestXmlPSC implements PropertySourceConfig {
46
47
48
49
50 @Autowired
51 JdbcPropertyLocationsConfig jdbcConfig;
52
53
54
55
56 @Autowired
57 SourceSqlPropertyLocationsConfig sourceSqlConfig;
58
59
60
61
62 @Autowired
63 IngestXmlPropertyLocationsConfig ingestXmlConfig;
64
65
66
67
68 @Autowired
69 PropertiesService service;
70
71
72
73
74
75
76
77
78 @Override
79 @Bean
80 public PropertySource<?> propertySource() {
81 List<Location> locations = Lists.newArrayList();
82
83 locations.addAll(jdbcConfig.jdbcPropertyLocations());
84 locations.addAll(sourceSqlConfig.riceSourceSqlPropertyLocations());
85 locations.addAll(ingestXmlConfig.riceIngestXmlPropertyLocations());
86
87 Properties properties = service.getProperties(locations);
88
89 String location = ProjectUtils.getPath(RiceXmlProperties.APP.getResource());
90 Config riceConfig = RiceConfigUtils.parseAndInit(location);
91 RiceConfigUtils.putProperties(riceConfig, properties);
92
93 return new PropertiesPropertySource("properties", riceConfig.getProperties());
94 }
95
96 }