1 /**
2 * Copyright 2010-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.common.util.config.spring;
17
18 import java.util.Collections;
19 import java.util.List;
20 import java.util.Properties;
21
22 import org.kuali.common.util.spring.SpringUtils;
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.context.annotation.Bean;
25 import org.springframework.context.annotation.Configuration;
26 import org.springframework.context.annotation.Import;
27 import org.springframework.core.env.PropertySource;
28
29 /**
30 * @deprecated
31 */
32 @Deprecated
33 @Configuration
34 @Import({ ConfigServiceConfig.class })
35 public class BasicPropertySourceConfig {
36
37 @Autowired
38 ConfigServiceConfig utilConfigServiceConfig;
39
40 /**
41 * <p>
42 * Returns <code>Collections.emptyList()</code> by default. Override this method to pull in properties from other locations
43 * </p>
44 *
45 * Example configIds:
46 *
47 * <pre>
48 * org.kuali.common:kuali-sql
49 * org.kuali.common:kuali-util:scm
50 * org.kuali.common:kuali-util:metainf:mpx
51 * org.kuali.common:kuali-util:metainf:sql
52 * </pre>
53 */
54 protected List<String> getConfigIds() {
55 return Collections.emptyList();
56 }
57
58 /**
59 * <p>
60 * Returns an empty properties object by default. Override this method to inject properties that will override anything loaded from other locations
61 * </p>
62 */
63 protected Properties getOverrides() {
64 return new Properties();
65 }
66
67 /**
68 * Combine loaded properties, project properties, and system/environment properties into a <code>PropertySource<?></code>
69 */
70 protected PropertySource<?> getPropertySource() {
71 org.kuali.common.util.config.service.ConfigService service = utilConfigServiceConfig.configService();
72 List<String> configIds = getConfigIds();
73 Properties properties = service.getProperties(configIds, getOverrides());
74 return SpringUtils.getGlobalPropertySource(properties);
75 }
76
77 @Bean
78 public PropertySource<?> springPropertySource() {
79 return getPropertySource();
80 }
81
82 }