ch.elca.el4j.core.config
Class ListPropertyMergeConfigurer

java.lang.Object
  extended by org.springframework.core.io.support.PropertiesLoaderSupport
      extended by org.springframework.beans.factory.config.PropertyResourceConfigurer
          extended by org.springframework.beans.factory.config.PropertyOverrideConfigurer
              extended by ch.elca.el4j.core.config.ListPropertyMergeConfigurer
All Implemented Interfaces:
BeanFactoryPostProcessor, Ordered, PriorityOrdered

public class ListPropertyMergeConfigurer
extends PropertyOverrideConfigurer

Adds an entry to a list property of a Spring bean. A file, e.g. "listmerge.properties", whose values are of type "beanName"."propertyName"="value 1", "value 2", ... can be referenced in the bean definition of this class under the property name "location". The defined values will be added to the list with name "propertyName" of the bean with name "beanName".

The postProcessBeanFactory method from abstract class PropertyResourceConfigurer is overridden in order to prevent the properties from being overridden. Another possibility would be to suggest a refactoring of this method in abstract class PropertyResourceConfigurer.

TODO This class handles only lists. Extensions could also manage Maps. A possible pattern for defining map entries in a properties file is (tbd): "bean_name.property_name = key1=value1, key2=value2".

Author:
Raphael Boog (RBO), Martin Zeltner (MZE)
File-location:
ListPropertyMergeConfigurer
Last check-in date:
2009-12-01 10:59:54 +0100 (Di, 01. Dez 2009) by jonasha for revision 4010

Field Summary
 
Fields inherited from class org.springframework.beans.factory.config.PropertyOverrideConfigurer
DEFAULT_BEAN_NAME_SEPARATOR
 
Fields inherited from class org.springframework.core.io.support.PropertiesLoaderSupport
logger, XML_FILE_EXTENSION
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
ListPropertyMergeConfigurer()
           
 
Method Summary
protected  void addDefaultProperties(Properties mergedProps)
          Adds default properties to the properties container.
protected  void applyPropertyValue(ConfigurableListableBeanFactory factory, String beanName, String property, String value)
          
 String getFileEncoding()
           
 Resource[] getLocations()
           
 Properties getProperties()
           
 PropertiesPersister getPropertiesPersister()
           
 boolean isIgnoreResourceNotFound()
           
 boolean isInsertNewItemsAfter()
          Marks if new items should be pre- or appended to the old values.
 boolean isInsertNewItemsBefore()
          Marks if new items should be pre- or appended to the old values.
protected  void loadProperties(Properties mergedProps, Resource location)
          Loads the properties from the given location.
 void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
          
 void setFileEncoding(String encoding)
          
 void setIgnoreResourceNotFound(boolean ignoreResourceNotFound)
          
 void setInsertNewItemsAfter(boolean insertNewItemsAfter)
          Marks if new items should be pre- or appended to the old values.
 void setInsertNewItemsBefore(boolean insertNewItemsBefore)
          Marks if new items should be pre- or appended to the old values.
 void setLocation(Resource location)
          
 void setLocations(Resource[] locations)
          
 void setProperties(Properties properties)
          
 void setPropertiesPersister(PropertiesPersister propertiesPersister)
          
 
Methods inherited from class org.springframework.beans.factory.config.PropertyOverrideConfigurer
hasPropertyOverridesFor, processKey, processProperties, setBeanNameSeparator, setIgnoreInvalidKeys
 
Methods inherited from class org.springframework.beans.factory.config.PropertyResourceConfigurer
convertProperties, convertProperty, convertPropertyValue, getOrder, setOrder
 
Methods inherited from class org.springframework.core.io.support.PropertiesLoaderSupport
loadProperties, mergeProperties, setLocalOverride, setPropertiesArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListPropertyMergeConfigurer

public ListPropertyMergeConfigurer()
Method Detail

setProperties

public final void setProperties(Properties properties)

Overrides:
setProperties in class PropertiesLoaderSupport

setLocation

public final void setLocation(Resource location)

Overrides:
setLocation in class PropertiesLoaderSupport

setLocations

public final void setLocations(Resource[] locations)

Overrides:
setLocations in class PropertiesLoaderSupport

setFileEncoding

public final void setFileEncoding(String encoding)

Overrides:
setFileEncoding in class PropertiesLoaderSupport

setPropertiesPersister

public final void setPropertiesPersister(PropertiesPersister propertiesPersister)

Overrides:
setPropertiesPersister in class PropertiesLoaderSupport

setIgnoreResourceNotFound

public final void setIgnoreResourceNotFound(boolean ignoreResourceNotFound)

Overrides:
setIgnoreResourceNotFound in class PropertiesLoaderSupport

getFileEncoding

public final String getFileEncoding()
Returns:
Returns the fileEncoding.

isIgnoreResourceNotFound

public final boolean isIgnoreResourceNotFound()
Returns:
Returns the ignoreResourceNotFound.

getLocations

public final Resource[] getLocations()
Returns:
Returns the locations.

getProperties

public final Properties getProperties()
Returns:
Returns the properties.

getPropertiesPersister

public final PropertiesPersister getPropertiesPersister()
Returns:
Returns the propertiesPersister.

isInsertNewItemsAfter

public final boolean isInsertNewItemsAfter()
Marks if new items should be pre- or appended to the old values.

Returns:
Returns the insertNewItemsAfter.

setInsertNewItemsAfter

public final void setInsertNewItemsAfter(boolean insertNewItemsAfter)
Marks if new items should be pre- or appended to the old values.

Parameters:
insertNewItemsAfter - The insertNewItemsAfter to set.

isInsertNewItemsBefore

public final boolean isInsertNewItemsBefore()
Marks if new items should be pre- or appended to the old values. Is the opposite of method isInsertNewItemsAfter.

Returns:
Returns the insertNewItemsBefore.
See Also:
isInsertNewItemsAfter()

setInsertNewItemsBefore

public final void setInsertNewItemsBefore(boolean insertNewItemsBefore)
Marks if new items should be pre- or appended to the old values. Is the opposite of method setInsertNewItemsAfter.

Parameters:
insertNewItemsBefore - The insertNewItemsBefore to set.
See Also:
setInsertNewItemsAfter(boolean)

postProcessBeanFactory

public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)

Specified by:
postProcessBeanFactory in interface BeanFactoryPostProcessor
Overrides:
postProcessBeanFactory in class PropertyResourceConfigurer

addDefaultProperties

protected void addDefaultProperties(Properties mergedProps)
Adds default properties to the properties container.

Parameters:
mergedProps - Is the properties container to write into.

loadProperties

protected void loadProperties(Properties mergedProps,
                              Resource location)
Loads the properties from the given location.

Parameters:
mergedProps - Is the properties container to write into.
location - Is the resource location to read properties from.

applyPropertyValue

protected void applyPropertyValue(ConfigurableListableBeanFactory factory,
                                  String beanName,
                                  String property,
                                  String value)

Overrides:
applyPropertyValue in class PropertyOverrideConfigurer


Copyright © 2005-2011 ELCA. All Rights Reserved.