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.ArrayList;
19 import java.util.List;
20 import java.util.Properties;
21
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 @Autowired
48 JdbcPropertyLocationsConfig jdbcConfig;
49
50 @Autowired
51 SourceSqlPropertyLocationsConfig sourceSqlConfig;
52
53 @Autowired
54 IngestXmlPropertyLocationsConfig ingestXmlConfig;
55
56 @Autowired
57 PropertiesService service;
58
59 @Override
60 @Bean
61 public PropertySource<?> propertySource() {
62
63 List<Location> locations = new ArrayList<Location>();
64 locations.addAll(jdbcConfig.jdbcPropertyLocations());
65 locations.addAll(sourceSqlConfig.riceSourceSqlPropertyLocations());
66 locations.addAll(ingestXmlConfig.riceIngestXmlPropertyLocations());
67
68 Properties properties = service.getProperties(locations);
69
70 String location = ProjectUtils.getPath(RiceXmlProperties.APP.getResource());
71 Config riceConfig = RiceConfigUtils.parseAndInit(location);
72 RiceConfigUtils.putProperties(riceConfig, properties);
73 return new PropertiesPropertySource("properties", riceConfig.getProperties());
74 }
75
76 }