View Javadoc
1   /**
2    * Copyright 2005-2016 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.List;
19  
20  import com.google.common.collect.Lists;
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      /**
43       * The general JDBC property locations.
44       */
45  	@Autowired
46  	JdbcPropertyLocationsConfig jdbcConfig;
47  
48      /**
49       * The Rice property locations for the database reset process.
50       */
51  	@Autowired
52  	SourceSqlPropertyLocationsConfig sourceSqlConfig;
53  
54      /**
55       * The property locator.
56       */
57  	@Autowired
58  	PropertiesService service;
59  
60      /**
61       * {@inheritDoc}
62       *
63       * <p>
64       * Here we combine all properties, making sure that the Rice project properties go in last.
65       * </p>
66       */
67  	@Override
68  	@Bean
69  	public PropertySource<?> propertySource() {
70  		List<Location> locations = Lists.newArrayList();
71  
72          locations.addAll(jdbcConfig.jdbcPropertyLocations());
73  		locations.addAll(sourceSqlConfig.riceSourceSqlPropertyLocations());
74  
75  		return PropertySourceUtils.getPropertySource(service, locations);
76  	}
77  
78  }