View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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   * Holds the property source for all of the different properties needed for the workflow XML ingestion process.
40   * 
41   * @author Kuali Rice Team (rice.collab@kuali.org)
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  		// Making sure Rice properties go in last
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  }