org.springframework.beans.factory.config
Class PropertyResourceConfigurer

java.lang.Object
  extended byorg.springframework.beans.factory.config.PropertyResourceConfigurer
All Implemented Interfaces:
BeanFactoryPostProcessor, Ordered
Direct Known Subclasses:
PropertyOverrideConfigurer, PropertyPlaceholderConfigurer

public abstract class PropertyResourceConfigurer
extends java.lang.Object
implements BeanFactoryPostProcessor, Ordered

Allows for configuration of individual bean property values from a property resource, i.e. a properties file. Useful for custom config files targetted at system administrators that override bean properties configured in the application context.

2 concrete implementations are provided in the distribution:

Since:
02.10.2003
Author:
Juergen Hoeller
See Also:
PropertyOverrideConfigurer, PropertyPlaceholderConfigurer

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
PropertyResourceConfigurer()
           
 
Method Summary
 int getOrder()
          Return the order value of this object, higher value meaning greater in terms of sorting.
 void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
          Modify the application context's internal bean factory after its standard initialization.
protected abstract  void processProperties(ConfigurableListableBeanFactory beanFactory, java.util.Properties props)
          Apply the given Properties to the bean factory.
 void setIgnoreResourceNotFound(boolean ignoreResourceNotFound)
          Set if failure to find the property resource should be ignored.
 void setLocation(Resource location)
          Set a location of a properties file to be loaded.
 void setLocations(Resource[] locations)
          Set locations of properties files to be loaded.
 void setOrder(int order)
           
 void setProperties(java.util.Properties properties)
          Set local properties, e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

PropertyResourceConfigurer

public PropertyResourceConfigurer()
Method Detail

setOrder

public void setOrder(int order)

getOrder

public int getOrder()
Description copied from interface: Ordered
Return the order value of this object, higher value meaning greater in terms of sorting. Normally starting with 0 or 1, Integer.MAX_VALUE indicating greatest. Same order values will result in arbitrary positions for the affected objects.

Higher value can be interpreted as lower priority, consequently the first object has highest priority (somewhat analogous to Servlet "load-on-startup" values).

Specified by:
getOrder in interface Ordered
Returns:
the order value

setProperties

public void setProperties(java.util.Properties properties)
Set local properties, e.g. via the "props" tag in XML bean definitions. These can be considered defaults, to be overridden by properties loaded from files.


setLocation

public void setLocation(Resource location)
Set a location of a properties file to be loaded.


setLocations

public void setLocations(Resource[] locations)
Set locations of properties files to be loaded.


setIgnoreResourceNotFound

public void setIgnoreResourceNotFound(boolean ignoreResourceNotFound)
Set if failure to find the property resource should be ignored. True is appropriate if the properties file is completely optional. Default is false.


postProcessBeanFactory

public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
                            throws BeansException
Description copied from interface: BeanFactoryPostProcessor
Modify the application context's internal bean factory after its standard initialization. All bean definitions will have been loaded, but no beans will have been instantiated yet. This allows for overriding or adding properties even to eager-initializing beans.

Specified by:
postProcessBeanFactory in interface BeanFactoryPostProcessor
Parameters:
beanFactory - the bean factory used by the application context
Throws:
BeansException - in case of errors

processProperties

protected abstract void processProperties(ConfigurableListableBeanFactory beanFactory,
                                          java.util.Properties props)
                                   throws BeansException
Apply the given Properties to the bean factory.

Parameters:
beanFactory - the bean factory used by the application context
props - the Properties to apply
Throws:
BeansException - in case of errors


Copyright (C) 2003-2004 The Spring Framework Project.