View Javadoc
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.ole.sys.context;
17  
18  import java.io.IOException;
19  import java.util.Properties;
20  
21  import org.kuali.rice.core.api.config.property.Config;
22  import org.kuali.rice.core.api.config.property.ConfigContext;
23  import org.kuali.rice.core.impl.config.property.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 the workflow configuration.
28   * 
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public class ConfigPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer {
32      protected static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ConfigPropertyPlaceholderConfigurer.class);
33  
34      public ConfigPropertyPlaceholderConfigurer() {
35          setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE);
36      }
37  
38      @Override
39      protected void loadProperties(Properties props) throws IOException {
40          // perform standard property resource file loading
41          super.loadProperties(props);
42          // put the properties into the Rice configuration context
43          ConfigContext.getCurrentContextConfig().putProperties(props);
44          // load the Rice properties
45          if ( LOG.isDebugEnabled() ) {
46              Config config = ConfigContext.getCurrentContextConfig();
47              if (config != null) {
48                  LOG.debug("Replacing parameters in Spring using config:\r\n" + config);
49                  ConfigLogger.logConfig(config);
50              }
51          }
52      }
53  }