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.sql.spring;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.common.jdbc.project.spring.JdbcPropertyLocationsConfig;
22  import org.kuali.common.util.properties.Location;
23  import org.kuali.common.util.properties.PropertiesService;
24  import org.kuali.common.util.properties.spring.DefaultPropertiesServiceConfig;
25  import org.kuali.common.util.spring.PropertySourceUtils;
26  import org.kuali.common.util.spring.service.PropertySourceConfig;
27  import org.springframework.beans.factory.annotation.Autowired;
28  import org.springframework.context.annotation.Bean;
29  import org.springframework.context.annotation.Configuration;
30  import org.springframework.context.annotation.Import;
31  import org.springframework.core.env.PropertySource;
32  
33  /**
34   * Holds the property source for all of the different properties needed for the database reset process.
35   * 
36   * @author Kuali Rice Team (rice.collab@kuali.org)
37   */
38  @Configuration
39  @Import({ SourceSqlProjectConfig.class, SourceSqlPropertyLocationsConfig.class, JdbcPropertyLocationsConfig.class, DefaultPropertiesServiceConfig.class })
40  public class SourceSqlPSC implements PropertySourceConfig {
41  
42  	@Autowired
43  	JdbcPropertyLocationsConfig jdbcConfig;
44  
45  	@Autowired
46  	SourceSqlPropertyLocationsConfig sourceSqlConfig;
47  
48  	@Autowired
49  	PropertiesService service;
50  
51  	@Override
52  	@Bean
53  	public PropertySource<?> propertySource() {
54  		// Combine them making sure Rice properties go in last
55  		List<Location> locations = new ArrayList<Location>();
56  		locations.addAll(jdbcConfig.jdbcPropertyLocations());
57  		locations.addAll(sourceSqlConfig.riceSourceSqlPropertyLocations());
58  		return PropertySourceUtils.getPropertySource(service, locations);
59  	}
60  
61  }