java.lang.Object | ||
↳ | org.springframework.beans.factory.support.AbstractBeanDefinitionReader | |
↳ | org.springframework.beans.factory.support.PropertiesBeanDefinitionReader |
Bean definition reader for a simple properties format.
Provides bean definition registration methods for Map/Properties and ResourceBundle. Typically applied to a DefaultListableBeanFactory.
Example:
employee.(class)=MyClass // bean is of class MyClass employee.(abstract)=true // this bean can't be instantiated directly employee.group=Insurance // real property employee.usesDialUp=false // real property (potentially overridden) salesrep.(parent)=employee // derives from "employee" bean definition salesrep.(lazy-init)=true // lazily initialize this singleton bean salesrep.manager(ref)=tony // reference to another bean salesrep.department=Sales // real property techie.(parent)=employee // derives from "employee" bean definition techie.(scope)=prototype // bean is a prototype (not a shared instance) techie.manager(ref)=jeff // reference to another bean techie.department=Engineering // real property techie.usesDialUp=true // real property (overriding parent value) ceo.$0(ref)=secretary // inject 'secretary' bean as 0th constructor arg ceo.$1=1000000 // inject value '1000000' at 1st constructor arg
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | ABSTRACT_KEY | Special key to distinguish owner.(abstract)=true
Default is "false". |
|||||||||
String | CLASS_KEY | Special key to distinguish owner.(class)=com.myapp.MyClass -
|
|||||||||
String | CONSTRUCTOR_ARG_PREFIX | Prefix used to denote a constructor argument definition. | |||||||||
String | LAZY_INIT_KEY | Special key to distinguish owner.(lazy-init)=true
Default is "false". |
|||||||||
String | PARENT_KEY | Special key to distinguish owner.(parent)=parentBeanName . |
|||||||||
String | REF_PREFIX | Prefix before values referencing other beans. | |||||||||
String | REF_SUFFIX | Property suffix for references to other beans in the current BeanFactory: e.g. | |||||||||
String | SCOPE_KEY | Special key to distinguish owner.(scope)=prototype . |
|||||||||
String | SEPARATOR | Separator between bean name and property name. | |||||||||
String | SINGLETON_KEY | Special key to distinguish owner.(singleton)=false . |
|||||||||
String | TRUE_VALUE | Value of a T/F attribute that represents true. |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.beans.factory.support.AbstractBeanDefinitionReader
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create new PropertiesBeanDefinitionReader for the given bean factory.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Return the default parent bean for this bean factory.
| |||||||||||
Return the PropertiesPersister to use for parsing properties files.
| |||||||||||
Load bean definitions from the specified properties file.
| |||||||||||
Load bean definitions from the specified properties file,
using all property keys (i.e.
| |||||||||||
Load bean definitions from the specified properties file.
| |||||||||||
Load bean definitions from the specified properties file.
| |||||||||||
Register bean definitions contained in a resource bundle,
using all property keys (i.e.
| |||||||||||
Register bean definitions contained in a Map.
| |||||||||||
Register bean definitions contained in a Map,
using all property keys (i.e.
| |||||||||||
Register bean definitions contained in a Map.
| |||||||||||
Register bean definitions contained in a ResourceBundle.
| |||||||||||
Set the default parent bean for this bean factory.
| |||||||||||
Set the PropertiesPersister to use for parsing properties files.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Get all property values, given a prefix (which will be stripped)
and add the bean they define to the factory with the given name
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.beans.factory.support.AbstractBeanDefinitionReader
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.support.BeanDefinitionReader
| |||||||||||
From interface
org.springframework.core.env.EnvironmentCapable
|
Special key to distinguish owner.(abstract)=true
Default is "false".
Special key to distinguish owner.(class)=com.myapp.MyClass
-
Prefix used to denote a constructor argument definition.
Special key to distinguish owner.(lazy-init)=true
Default is "false".
Special key to distinguish owner.(parent)=parentBeanName
.
Prefix before values referencing other beans.
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.
Special key to distinguish owner.(scope)=prototype
.
Default is "true".
Separator between bean name and property name. We follow normal Java conventions.
Special key to distinguish owner.(singleton)=false
.
Default is "true".
Value of a T/F attribute that represents true. Anything else represents false. Case seNsItive.
Create new PropertiesBeanDefinitionReader for the given bean factory.
registry | the BeanFactory to load bean definitions into, in the form of a BeanDefinitionRegistry |
---|
Return the default parent bean for this bean factory.
Return the PropertiesPersister to use for parsing properties files.
Load bean definitions from the specified properties file.
resource | the resource descriptor for the properties file |
---|---|
prefix | a filter within the keys in the map: e.g. 'beans.'
(can be empty or null ) |
BeanDefinitionStoreException | in case of loading or parsing errors |
---|
Load bean definitions from the specified properties file, using all property keys (i.e. not filtering by prefix).
resource | the resource descriptor for the properties file |
---|
BeanDefinitionStoreException | in case of loading or parsing errors |
---|
Load bean definitions from the specified properties file.
encodedResource | the resource descriptor for the properties file, allowing to specify an encoding to use for parsing the file |
---|---|
prefix | a filter within the keys in the map: e.g. 'beans.'
(can be empty or null ) |
BeanDefinitionStoreException | in case of loading or parsing errors |
---|
Load bean definitions from the specified properties file.
encodedResource | the resource descriptor for the properties file, allowing to specify an encoding to use for parsing the file |
---|
BeanDefinitionStoreException | in case of loading or parsing errors |
---|
Register bean definitions contained in a resource bundle, using all property keys (i.e. not filtering by prefix).
rb | the ResourceBundle to load from |
---|
BeanDefinitionStoreException | in case of loading or parsing errors |
---|
Register bean definitions contained in a Map. Ignore ineligible properties.
map | 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 | a filter within the keys in the map: e.g. 'beans.'
(can be empty or null ) |
BeansException | in case of loading or parsing errors |
---|
Register bean definitions contained in a Map, using all property keys (i.e. not filtering by prefix).
map | 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. |
---|
BeansException | in case of loading or parsing errors |
---|
Register bean definitions contained in a Map. Ignore ineligible properties.
map | 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 | a filter within the keys in the map: e.g. 'beans.'
(can be empty or null ) |
resourceDescription | description of the resource that the Map came from (for logging purposes) |
BeansException | in case of loading or parsing errors |
---|
Register bean definitions contained in a ResourceBundle.
Similar syntax as for a Map. This method is useful to enable standard Java internationalization support.
rb | the ResourceBundle to load from |
---|---|
prefix | a filter within the keys in the map: e.g. 'beans.'
(can be empty or null ) |
BeanDefinitionStoreException | in case of loading or parsing errors |
---|
Set the default parent bean for this bean factory. If a child bean definition handled by this factory provides neither a parent nor a class attribute, this default value gets used.
Can be used e.g. for view definition files, to define a parent with a default view class and common attributes for all views. View definitions that define their own parent or carry their own class can still override this.
Strictly speaking, the rule that a default parent setting does not apply to a bean definition that carries a class is there for backwards compatiblity reasons. It still matches the typical use case.
Set the PropertiesPersister to use for parsing properties files. The default is DefaultPropertiesPersister.
Get all property values, given a prefix (which will be stripped) and add the bean they define to the factory with the given name
beanName | name of the bean to define |
---|---|
map | Map containing string pairs |
prefix | prefix of each entry, which will be stripped |
resourceDescription | description of the resource that the Map came from (for logging purposes) |
BeansException | if the bean definition could not be parsed or registered |
---|