Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ConfigPropertyPlaceholderConfigurer |
|
| 1.5;1.5 |
1 | /* | |
2 | * Copyright 2007-2008 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.core.config.spring; | |
17 | ||
18 | import java.io.IOException; | |
19 | import java.util.Properties; | |
20 | ||
21 | import org.kuali.rice.core.config.Config; | |
22 | import org.kuali.rice.core.config.ConfigContext; | |
23 | import org.kuali.rice.core.config.ConfigLogger; | |
24 | import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; | |
25 | ||
26 | /** | |
27 | * Configures a property placeholder in Spring which will allow access to the properties configured in | |
28 | * the workflow configuration. | |
29 | * | |
30 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
31 | */ | |
32 | public class ConfigPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer { | |
33 | 0 | protected final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(getClass()); |
34 | ||
35 | 0 | public ConfigPropertyPlaceholderConfigurer() { |
36 | 0 | setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE); |
37 | 0 | } |
38 | ||
39 | @Override | |
40 | protected void loadProperties(Properties props) throws IOException { | |
41 | // perform standard property resource file loading | |
42 | 0 | super.loadProperties(props); |
43 | // load the Rice properties | |
44 | 0 | Config config = ConfigContext.getCurrentContextConfig(); |
45 | 0 | if (config != null) { |
46 | 0 | log.debug("Replacing parameters in Spring using config:\r\n" + config); |
47 | 0 | ConfigLogger.logConfig(config); |
48 | 0 | props.putAll(config.getProperties()); |
49 | } | |
50 | 0 | } |
51 | } |