public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
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
DefaultListableBeanFactory| Modifier and Type | Field and Description | 
|---|---|
| static String | ABSTRACT_KEYSpecial key to distinguish  owner.(abstract)=trueDefault is "false". | 
| static String | CLASS_KEYSpecial key to distinguish  owner.(class)=com.myapp.MyClass. | 
| static String | CONSTRUCTOR_ARG_PREFIXPrefix used to denote a constructor argument definition. | 
| static String | LAZY_INIT_KEYSpecial key to distinguish  owner.(lazy-init)=trueDefault is "false". | 
| static String | PARENT_KEYSpecial key to distinguish  owner.(parent)=parentBeanName. | 
| static String | REF_PREFIXPrefix before values referencing other beans. | 
| static String | REF_SUFFIXProperty suffix for references to other beans in the current
 BeanFactory: e.g. | 
| static String | SCOPE_KEYSpecial key to distinguish  owner.(scope)=prototype. | 
| static String | SEPARATORSeparator between bean name and property name. | 
| static String | SINGLETON_KEYSpecial key to distinguish  owner.(singleton)=false. | 
| static String | TRUE_VALUEValue of a T/F attribute that represents true. | 
logger| Constructor and Description | 
|---|
| PropertiesBeanDefinitionReader(BeanDefinitionRegistry registry)Create new PropertiesBeanDefinitionReader for the given bean factory. | 
| Modifier and Type | Method and Description | 
|---|---|
| String | getDefaultParentBean()Return the default parent bean for this bean factory. | 
| org.springframework.util.PropertiesPersister | getPropertiesPersister()Return the PropertiesPersister to use for parsing properties files. | 
| int | loadBeanDefinitions(org.springframework.core.io.support.EncodedResource encodedResource)Load bean definitions from the specified properties file. | 
| int | loadBeanDefinitions(org.springframework.core.io.support.EncodedResource encodedResource,
                   String prefix)Load bean definitions from the specified properties file. | 
| int | loadBeanDefinitions(org.springframework.core.io.Resource resource)Load bean definitions from the specified properties file,
 using all property keys (i.e. | 
| int | loadBeanDefinitions(org.springframework.core.io.Resource resource,
                   String prefix)Load bean definitions from the specified properties file. | 
| protected void | registerBeanDefinition(String beanName,
                      Map<?,?> map,
                      String prefix,
                      String resourceDescription)Get all property values, given a prefix (which will be stripped)
 and add the bean they define to the factory with the given name. | 
| int | registerBeanDefinitions(Map<?,?> map)Register bean definitions contained in a Map, using all property keys (i.e. | 
| int | registerBeanDefinitions(Map<?,?> map,
                       String prefix)Register bean definitions contained in a Map. | 
| int | registerBeanDefinitions(Map<?,?> map,
                       String prefix,
                       String resourceDescription)Register bean definitions contained in a Map. | 
| int | registerBeanDefinitions(ResourceBundle rb)Register bean definitions contained in a resource bundle,
 using all property keys (i.e. | 
| int | registerBeanDefinitions(ResourceBundle rb,
                       String prefix)Register bean definitions contained in a ResourceBundle. | 
| void | setDefaultParentBean(String defaultParentBean)Set the default parent bean for this bean factory. | 
| void | setPropertiesPersister(org.springframework.util.PropertiesPersister propertiesPersister)Set the PropertiesPersister to use for parsing properties files. | 
getBeanClassLoader, getBeanFactory, getBeanNameGenerator, getEnvironment, getRegistry, getResourceLoader, loadBeanDefinitions, loadBeanDefinitions, loadBeanDefinitions, loadBeanDefinitions, setBeanClassLoader, setBeanNameGenerator, setEnvironment, setResourceLoaderpublic static final String TRUE_VALUE
public static final String SEPARATOR
public static final String CLASS_KEY
owner.(class)=com.myapp.MyClass.public static final String PARENT_KEY
owner.(parent)=parentBeanName.public static final String SCOPE_KEY
owner.(scope)=prototype.
 Default is "true".public static final String SINGLETON_KEY
owner.(singleton)=false.
 Default is "true".public static final String ABSTRACT_KEY
owner.(abstract)=true
 Default is "false".public static final String LAZY_INIT_KEY
owner.(lazy-init)=true
 Default is "false".public static final String REF_SUFFIX
owner.dog(ref)=fido.
 Whether this is a reference to a singleton or a prototype
 will depend on the definition of the target bean.public static final String REF_PREFIX
public static final String CONSTRUCTOR_ARG_PREFIX
public PropertiesBeanDefinitionReader(BeanDefinitionRegistry registry)
registry - the BeanFactory to load bean definitions into,
 in the form of a BeanDefinitionRegistrypublic void setDefaultParentBean(@Nullable
                                 String defaultParentBean)
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 compatibility reasons. It still matches the typical use case.
@Nullable public String getDefaultParentBean()
public void setPropertiesPersister(@Nullable
                                   org.springframework.util.PropertiesPersister propertiesPersister)
DefaultPropertiesPersisterpublic org.springframework.util.PropertiesPersister getPropertiesPersister()
public int loadBeanDefinitions(org.springframework.core.io.Resource resource)
                        throws BeanDefinitionStoreException
resource - the resource descriptor for the properties fileBeanDefinitionStoreException - in case of loading or parsing errorsloadBeanDefinitions(org.springframework.core.io.Resource, String)public int loadBeanDefinitions(org.springframework.core.io.Resource resource,
                               @Nullable
                               String prefix)
                        throws BeanDefinitionStoreException
resource - the resource descriptor for the properties fileprefix - a filter within the keys in the map: e.g. 'beans.'
 (can be empty or null)BeanDefinitionStoreException - in case of loading or parsing errorspublic int loadBeanDefinitions(org.springframework.core.io.support.EncodedResource encodedResource)
                        throws BeanDefinitionStoreException
encodedResource - the resource descriptor for the properties file,
 allowing to specify an encoding to use for parsing the fileBeanDefinitionStoreException - in case of loading or parsing errorspublic int loadBeanDefinitions(org.springframework.core.io.support.EncodedResource encodedResource,
                               @Nullable
                               String prefix)
                        throws BeanDefinitionStoreException
encodedResource - the resource descriptor for the properties file,
 allowing to specify an encoding to use for parsing the fileprefix - a filter within the keys in the map: e.g. 'beans.'
 (can be empty or null)BeanDefinitionStoreException - in case of loading or parsing errorspublic int registerBeanDefinitions(ResourceBundle rb) throws BeanDefinitionStoreException
rb - the ResourceBundle to load fromBeanDefinitionStoreException - in case of loading or parsing errorsregisterBeanDefinitions(java.util.ResourceBundle, String)public int registerBeanDefinitions(ResourceBundle rb, @Nullable String prefix) throws BeanDefinitionStoreException
Similar syntax as for a Map. This method is useful to enable standard Java internationalization support.
rb - the ResourceBundle to load fromprefix - a filter within the keys in the map: e.g. 'beans.'
 (can be empty or null)BeanDefinitionStoreException - in case of loading or parsing errorspublic int registerBeanDefinitions(Map<?,?> map) throws BeansException
map - a map of name to 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 errorsregisterBeanDefinitions(java.util.Map, String, String)public int registerBeanDefinitions(Map<?,?> map, @Nullable String prefix) throws BeansException
map - a map of name to 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 errorspublic int registerBeanDefinitions(Map<?,?> map, @Nullable String prefix, String resourceDescription) throws BeansException
map - a map of name to 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 errorsregisterBeanDefinitions(Map, String)protected void registerBeanDefinition(String beanName, Map<?,?> map, String prefix, String resourceDescription) throws BeansException
beanName - name of the bean to definemap - a Map containing string pairsprefix - prefix of each entry, which will be strippedresourceDescription - description of the resource that the
 Map came from (for logging purposes)BeansException - if the bean definition could not be parsed or registered