org.sakaiproject.util
Class PropertyOverrideConfigurer

java.lang.Object
  extended byorg.springframework.core.io.support.PropertiesLoaderSupport
      extended byorg.springframework.beans.factory.config.PropertyResourceConfigurer
          extended byorg.sakaiproject.util.PropertyOverrideConfigurer
All Implemented Interfaces:
BeanFactoryPostProcessor, Ordered

public class PropertyOverrideConfigurer
extends PropertyResourceConfigurer

Sakai's extension to the Spring PropertyOverrideConfigurer - allow our dotted bean ids, use @ as a separator between the bean id and the property name.

This could be an extension, just defining a new processKey(), but for the *private* members that the extension does not have access to...

Version:
$Revision: 632 $
Author:
University of Michigan, Sakai Software Development Team

Field Summary
protected  Set beanNames
          Contains names of beans that have overrides
protected  boolean ignoreInvalidKeys
           
protected  Map m_entries
          Here are all the name=value entries we read in.
 
Fields inherited from class org.springframework.core.io.support.PropertiesLoaderSupport
logger, XML_FILE_EXTENSION
 
Constructor Summary
PropertyOverrideConfigurer()
           
 
Method Summary
protected  void applyPropertyValue(ConfigurableListableBeanFactory factory, String beanName, String property, String value)
          Apply the given property value to the corresponding bean.
 String getValue(String name)
          Access the value of the entry with this name key
 boolean hasPropertyOverridesFor(String beanName)
          Were there overrides for this bean?
protected  void processKey(ConfigurableListableBeanFactory factory, String key, String value)
          Process the given key as 'beanName@property' entry.
protected  void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)
           
 void setIgnoreInvalidKeys(boolean ignoreInvalidKeys)
          Set whether to ignore invalid keys.
 
Methods inherited from class org.springframework.beans.factory.config.PropertyResourceConfigurer
convertProperties, convertPropertyValue, getOrder, postProcessBeanFactory, setOrder
 
Methods inherited from class org.springframework.core.io.support.PropertiesLoaderSupport
loadProperties, mergeProperties, setFileEncoding, setIgnoreResourceNotFound, setLocalOverride, setLocation, setLocations, setProperties, setPropertiesPersister
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ignoreInvalidKeys

protected boolean ignoreInvalidKeys

beanNames

protected Set beanNames
Contains names of beans that have overrides


m_entries

protected Map m_entries
Here are all the name=value entries we read in.

Constructor Detail

PropertyOverrideConfigurer

public PropertyOverrideConfigurer()
Method Detail

getValue

public String getValue(String name)
Access the value of the entry with this name key

Parameters:
name - The key to search for.
Returns:
The value for this key, or null if not defined.

setIgnoreInvalidKeys

public void setIgnoreInvalidKeys(boolean ignoreInvalidKeys)
Set whether to ignore invalid keys. Default is false.

If you ignore invalid keys, keys that do not follow the 'beanName.property' format will just be logged as warning. This allows to have arbitrary other keys in a properties file.


processProperties

protected void processProperties(ConfigurableListableBeanFactory beanFactory,
                                 Properties props)
                          throws BeansException
Throws:
BeansException

processKey

protected void processKey(ConfigurableListableBeanFactory factory,
                          String key,
                          String value)
                   throws BeansException
Process the given key as 'beanName@property' entry.

Throws:
BeansException

applyPropertyValue

protected void applyPropertyValue(ConfigurableListableBeanFactory factory,
                                  String beanName,
                                  String property,
                                  String value)
Apply the given property value to the corresponding bean.


hasPropertyOverridesFor

public boolean hasPropertyOverridesFor(String beanName)
Were there overrides for this bean? Only valid after processing has occurred at least once.

Parameters:
beanName - name of the bean to query status for
Returns:
whether there were property overrides for the named bean