org.springframework.beans.factory.support
Class PropertiesBeanDefinitionReader

org.springframework.beans.factory.support.AbstractBeanDefinitionReader
  |
  +--org.springframework.beans.factory.support.PropertiesBeanDefinitionReader

public class PropertiesBeanDefinitionReader
extends AbstractBeanDefinitionReader

Bean definition reader for a simple properties format. Provides bean definition registration methods for Map/Properties and ResourceBundle. Typically applied to a DefaultListableBeanFactory.

Author:
Rod Johnson, Juergen Hoeller
Since: 26.11.2003
See Also: DefaultListableBeanFactory

Field Summary
 final static StringCLASS_KEY
          Prefix for the class property of a root bean definition.
 final static StringLAZY_INIT_KEY
          Special string added to distinguish owner.(lazy-init)=true Default is false.
 final static StringPARENT_KEY
          Reserved "property" to indicate the parent of a child bean definition.
 final static StringREF_PREFIX
          Prefix before values referencing other beans.
 final static StringREF_SUFFIX
          Property suffix for references to other beans in the current BeanFactory: e.g.
 final static StringSEPARATOR
          Separator between bean name and property name.
 final static StringSINGLETON_KEY
          Special string added to distinguish owner.(singleton)=true Default is true.
 final static StringTRUE_VALUE
          Value of a T/F attribute that represents true.

Constructor Summary
PropertiesBeanDefinitionReader(BeanDefinitionRegistry beanFactory)
          Create new PropertiesBeanDefinitionReader for the given bean factory.

Method Summary
 StringgetDefaultParentBean()
          Return the default parent bean for this bean factory.
 intloadBeanDefinitions(Resource resource)
          Load bean definitions from the specified properties file, using all property keys (i.e.
 intloadBeanDefinitions(Resource resource, String prefix)
          Load bean definitions from the specified properties file.
 intregisterBeanDefinitions(ResourceBundle rb)
          Register bean definitions contained in a resource bundle, using all property keys (i.e.
 intregisterBeanDefinitions(ResourceBundle rb, String prefix)
          Register bean definitions contained in a ResourceBundle.
 intregisterBeanDefinitions(Map m)
          Register bean definitions contained in a Map, using all property keys (i.e.
 intregisterBeanDefinitions(Map m, String prefix)
          Register bean definitions contained in a Map.
 intregisterBeanDefinitions(Map m, String prefix, String resourceDescription)
          Register bean definitions contained in a Map.
 voidsetDefaultParentBean(String defaultParentBean)
          Set the default parent bean for this bean factory.

Methods inherited from class org.springframework.beans.factory.support.AbstractBeanDefinitionReader
getBeanClassLoader, getBeanFactory, setBeanClassLoader

Field Detail

CLASS_KEY

public final static String CLASS_KEY
Prefix for the class property of a root bean definition.

LAZY_INIT_KEY

public final static String LAZY_INIT_KEY
Special string added to distinguish owner.(lazy-init)=true Default is false.

PARENT_KEY

public final static String PARENT_KEY
Reserved "property" to indicate the parent of a child bean definition.

REF_PREFIX

public final static String REF_PREFIX
Prefix before values referencing other beans.

REF_SUFFIX

public final static String REF_SUFFIX
Property suffix for references to other beans in the current BeanFactory: e.g. owner.dog(ref)=fido. Whether this is a reference to a singleton or a prototype will depend on the definition of the target bean.

SEPARATOR

public final static String SEPARATOR
Separator between bean name and property name. We follow normal Java conventions.

SINGLETON_KEY

public final static String SINGLETON_KEY
Special string added to distinguish owner.(singleton)=true Default is true.

TRUE_VALUE

public final static String TRUE_VALUE
Value of a T/F attribute that represents true. Anything else represents false. Case seNsItive.
Constructor Detail

PropertiesBeanDefinitionReader

public PropertiesBeanDefinitionReader(BeanDefinitionRegistry beanFactory)
Create new PropertiesBeanDefinitionReader for the given bean factory.
Method Detail

getDefaultParentBean

public String getDefaultParentBean()
Return the default parent bean for this bean factory.

loadBeanDefinitions

public int loadBeanDefinitions(Resource resource)
Load bean definitions from the specified properties file, using all property keys (i.e. not filtering by prefix).
Parameters:
resource - the resource descriptor for the properties file
Returns: the number of bean definitions found
Throws:
BeansException - in case of loading or parsing errors
See Also:
loadBeanDefinitions(org.springframework.core.io.Resource,java.lang.String)

loadBeanDefinitions

public int loadBeanDefinitions(Resource resource, String prefix)
Load bean definitions from the specified properties file.
Parameters:
resource - the resource descriptor for the properties file
Returns: the number of bean definitions found
Throws:
BeansException - in case of loading or parsing errors

registerBeanDefinitions

public int registerBeanDefinitions(ResourceBundle rb)
throws org.springframework.beans.factory.BeanDefinitionStoreException
Register bean definitions contained in a resource bundle, using all property keys (i.e. not filtering by prefix).
Returns: the number of bean definitions found
Throws:
BeansException - in case of loading or parsing errors
See Also:
registerBeanDefinitions(java.util.ResourceBundle,java.lang.String)

registerBeanDefinitions

public int registerBeanDefinitions(ResourceBundle rb, String prefix)
throws org.springframework.beans.factory.BeanDefinitionStoreException
Register bean definitions contained in a ResourceBundle.

Similar syntax as for a Map. This method is useful to enable standard Java internationalization support.

Returns: the number of bean definitions found
Throws:
BeansException - in case of loading or parsing errors

registerBeanDefinitions

public int registerBeanDefinitions(Map m)
throws org.springframework.beans.BeansException
Register bean definitions contained in a Map, using all property keys (i.e. not filtering by prefix).
Returns: the number of bean definitions found
Throws:
BeansException - in case of loading or parsing errors
See Also:
registerBeanDefinitions(java.util.Map,java.lang.String,java.lang.String)

registerBeanDefinitions

public int registerBeanDefinitions(Map m, String prefix)
throws org.springframework.beans.BeansException
Register bean definitions contained in a Map. Ignore ineligible properties.
Parameters:
m - Map name -> property (String or Object). Property values will be strings if coming from a Properties file etc. Property names (keys) must be strings. Class keys must be Strings. employee.class=MyClass // special property //employee.abstract=true // this prototype can't be instantiated directly employee.group=Insurance Services // real property employee.usesDialUp=false // default unless overriden employee.manager(ref)=tony // reference to another prototype defined in the same file // cyclic and unresolved references will be detected salesrep.parent=employee salesrep.department=Sales and Marketing techie.parent=employee techie.department=Software Engineering techie.usesDialUp=true // overridden property
prefix - The match or filter within the keys in the map: e.g. 'beans.'
Returns: the number of bean definitions found
Throws:
BeansException - in case of loading or parsing errors

registerBeanDefinitions

public int registerBeanDefinitions(Map m, String prefix, String resourceDescription)
throws org.springframework.beans.BeansException
Register bean definitions contained in a Map. Ignore ineligible properties.
Parameters:
m - Map name -> property (String or Object). Property values will be strings if coming from a Properties file etc. Property names (keys) must be strings. Class keys must be Strings.
prefix - The match or filter within the keys in the map: e.g. 'beans.'
resourceDescription - description of the resource that the Map came from (for logging purposes)
Returns: the number of bean definitions found
Throws:
BeansException - in case of loading or parsing errors
See Also:
registerBeanDefinitions(java.util.Map,java.lang.String)

setDefaultParentBean

public void setDefaultParentBean(String defaultParentBean)
Set the default parent bean for this bean factory. If a child bean definition (i.e. a definition without class attribute) handled by this factory doesn't provide a parent attribute, this default value gets used.

Can be used e.g. for view definition files, to define a parent with common attributes for all views.

Association Links

to Class java.lang.String

Value of a T/F attribute that represents true. Anything else represents false. Case seNsItive.

to Class java.lang.String

Separator between bean name and property name. We follow normal Java conventions.

to Class java.lang.String

Prefix for the class property of a root bean definition.

to Class java.lang.String

Special string added to distinguish owner.(singleton)=true Default is true.

to Class java.lang.String

Special string added to distinguish owner.(lazy-init)=true Default is false.

to Class java.lang.String

Reserved "property" to indicate the parent of a child bean definition.

to Class java.lang.String

Property suffix for references to other beans in the current BeanFactory: e.g. owner.dog(ref)=fido. Whether this is a reference to a singleton or a prototype will depend on the definition of the target bean.

to Class java.lang.String

Prefix before values referencing other beans.

to Class java.lang.String

Name of default parent bean