Class PropertiesBeanDefinitionReader
java.lang.Object
org.springframework.beans.factory.support.AbstractBeanDefinitionReader
org.springframework.beans.factory.support.PropertiesBeanDefinitionReader
- All Implemented Interfaces:
BeanDefinitionReader,org.springframework.core.env.EnvironmentCapable
Deprecated.
as of 5.3, in favor of Spring's common bean definition formats
and/or custom reader implementations
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
- Since:
- 26.11.2003
- Author:
- Rod Johnson, Juergen Hoeller, Rob Harrop
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.Special key to distinguishowner.(abstract)=trueDefault is "false".static final StringDeprecated.Special key to distinguishowner.(class)=com.myapp.MyClass.static final StringDeprecated.Prefix used to denote a constructor argument definition.static final StringDeprecated.Special key to distinguishowner.(lazy-init)=trueDefault is "false".static final StringDeprecated.Special key to distinguishowner.(parent)=parentBeanName.static final StringDeprecated.Prefix before values referencing other beans.static final StringDeprecated.Property suffix for references to other beans in the current BeanFactory: for example,owner.dog(ref)=fido.static final StringDeprecated.Special key to distinguishowner.(scope)=prototype.static final StringDeprecated.Separator between bean name and property name.static final StringDeprecated.Special key to distinguishowner.(singleton)=false.static final StringDeprecated.Value of a T/F attribute that represents true.Fields inherited from class org.springframework.beans.factory.support.AbstractBeanDefinitionReader
logger -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.Create new PropertiesBeanDefinitionReader for the given bean factory. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Return the default parent bean for this bean factory.org.springframework.util.PropertiesPersisterDeprecated.Return the PropertiesPersister to use for parsing properties files.intloadBeanDefinitions(org.springframework.core.io.Resource resource) Deprecated.Load bean definitions from the specified properties file, using all property keys (i.e.intloadBeanDefinitions(org.springframework.core.io.Resource resource, String prefix) Deprecated.Load bean definitions from the specified properties file.intloadBeanDefinitions(org.springframework.core.io.support.EncodedResource encodedResource) Deprecated.Load bean definitions from the specified properties file.intloadBeanDefinitions(org.springframework.core.io.support.EncodedResource encodedResource, String prefix) Deprecated.Load bean definitions from the specified properties file.protected voidregisterBeanDefinition(String beanName, Map<?, ?> map, String prefix, String resourceDescription) Deprecated.Get all property values, given a prefix (which will be stripped) and add the bean they define to the factory with the given name.intregisterBeanDefinitions(Map<?, ?> map) Deprecated.Register bean definitions contained in a Map, using all property keys (i.e.intregisterBeanDefinitions(Map<?, ?> map, String prefix) Deprecated.Register bean definitions contained in a Map.intregisterBeanDefinitions(Map<?, ?> map, String prefix, String resourceDescription) Deprecated.Register bean definitions contained in a Map.intDeprecated.Register bean definitions contained in a resource bundle, using all property keys (i.e.intregisterBeanDefinitions(ResourceBundle rb, String prefix) Deprecated.Register bean definitions contained in a ResourceBundle.voidsetDefaultParentBean(String defaultParentBean) Deprecated.Set the default parent bean for this bean factory.voidsetPropertiesPersister(org.springframework.util.PropertiesPersister propertiesPersister) Deprecated.Set the PropertiesPersister to use for parsing properties files.Methods inherited from class org.springframework.beans.factory.support.AbstractBeanDefinitionReader
getBeanClassLoader, getBeanNameGenerator, getEnvironment, getRegistry, getResourceLoader, loadBeanDefinitions, loadBeanDefinitions, loadBeanDefinitions, loadBeanDefinitions, setBeanClassLoader, setBeanNameGenerator, setEnvironment, setResourceLoader
-
Field Details
-
TRUE_VALUE
Deprecated.Value of a T/F attribute that represents true. Anything else represents false. Case seNsItive.- See Also:
-
SEPARATOR
Deprecated.Separator between bean name and property name. We follow normal Java conventions.- See Also:
-
CLASS_KEY
Deprecated.Special key to distinguishowner.(class)=com.myapp.MyClass.- See Also:
-
PARENT_KEY
Deprecated.Special key to distinguishowner.(parent)=parentBeanName.- See Also:
-
SCOPE_KEY
Deprecated.Special key to distinguishowner.(scope)=prototype. Default is "true".- See Also:
-
SINGLETON_KEY
Deprecated.Special key to distinguishowner.(singleton)=false. Default is "true".- See Also:
-
ABSTRACT_KEY
Deprecated.Special key to distinguishowner.(abstract)=trueDefault is "false".- See Also:
-
LAZY_INIT_KEY
Deprecated.Special key to distinguishowner.(lazy-init)=trueDefault is "false".- See Also:
-
REF_SUFFIX
Deprecated.Property suffix for references to other beans in the current BeanFactory: for example,owner.dog(ref)=fido. Whether this is a reference to a singleton or a prototype will depend on the definition of the target bean.- See Also:
-
REF_PREFIX
Deprecated.Prefix before values referencing other beans.- See Also:
-
CONSTRUCTOR_ARG_PREFIX
Deprecated.Prefix used to denote a constructor argument definition.- See Also:
-
-
Constructor Details
-
PropertiesBeanDefinitionReader
Deprecated.Create new PropertiesBeanDefinitionReader for the given bean factory.- Parameters:
registry- the BeanFactory to load bean definitions into, in the form of a BeanDefinitionRegistry
-
-
Method Details
-
setDefaultParentBean
Deprecated.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, for example, 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.
-
getDefaultParentBean
Deprecated.Return the default parent bean for this bean factory. -
setPropertiesPersister
public void setPropertiesPersister(@Nullable org.springframework.util.PropertiesPersister propertiesPersister) Deprecated.Set the PropertiesPersister to use for parsing properties files. The default isDefaultPropertiesPersister.- See Also:
-
DefaultPropertiesPersister.INSTANCE
-
getPropertiesPersister
public org.springframework.util.PropertiesPersister getPropertiesPersister()Deprecated.Return the PropertiesPersister to use for parsing properties files. -
loadBeanDefinitions
public int loadBeanDefinitions(org.springframework.core.io.Resource resource) throws BeanDefinitionStoreException Deprecated.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:
BeanDefinitionStoreException- in case of loading or parsing errors- See Also:
-
loadBeanDefinitions
public int loadBeanDefinitions(org.springframework.core.io.Resource resource, @Nullable String prefix) throws BeanDefinitionStoreException Deprecated.Load bean definitions from the specified properties file.- Parameters:
resource- the resource descriptor for the properties fileprefix- a filter within the keys in the map: for example, 'beans.' (can be empty ornull)- Returns:
- the number of bean definitions found
- Throws:
BeanDefinitionStoreException- in case of loading or parsing errors
-
loadBeanDefinitions
public int loadBeanDefinitions(org.springframework.core.io.support.EncodedResource encodedResource) throws BeanDefinitionStoreException Deprecated.Load bean definitions from the specified properties file.- Parameters:
encodedResource- the resource descriptor for the properties file, allowing to specify an encoding to use for parsing the file- Returns:
- the number of bean definitions found
- Throws:
BeanDefinitionStoreException- in case of loading or parsing errors
-
loadBeanDefinitions
public int loadBeanDefinitions(org.springframework.core.io.support.EncodedResource encodedResource, @Nullable String prefix) throws BeanDefinitionStoreException Deprecated.Load bean definitions from the specified properties file.- Parameters:
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: for example, 'beans.' (can be empty ornull)- Returns:
- the number of bean definitions found
- Throws:
BeanDefinitionStoreException- in case of loading or parsing errors
-
registerBeanDefinitions
Deprecated.Register bean definitions contained in a resource bundle, using all property keys (i.e. not filtering by prefix).- Parameters:
rb- the ResourceBundle to load from- Returns:
- the number of bean definitions found
- Throws:
BeanDefinitionStoreException- in case of loading or parsing errors- See Also:
-
registerBeanDefinitions
public int registerBeanDefinitions(ResourceBundle rb, @Nullable String prefix) throws BeanDefinitionStoreException Deprecated.Register bean definitions contained in a ResourceBundle.Similar syntax as for a Map. This method is useful to enable standard Java internationalization support.
- Parameters:
rb- the ResourceBundle to load fromprefix- a filter within the keys in the map: for example, 'beans.' (can be empty ornull)- Returns:
- the number of bean definitions found
- Throws:
BeanDefinitionStoreException- in case of loading or parsing errors
-
registerBeanDefinitions
Deprecated.Register bean definitions contained in a Map, using all property keys (i.e. not filtering by prefix).- Parameters:
map- a map ofnametoproperty(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.- Returns:
- the number of bean definitions found
- Throws:
BeansException- in case of loading or parsing errors- See Also:
-
registerBeanDefinitions
Deprecated.Register bean definitions contained in a Map. Ignore ineligible properties.- Parameters:
map- a map ofnametoproperty(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: for example, 'beans.' (can be empty ornull)- Returns:
- the number of bean definitions found
- Throws:
BeansException- in case of loading or parsing errors
-
registerBeanDefinitions
public int registerBeanDefinitions(Map<?, ?> map, @Nullable String prefix, String resourceDescription) throws BeansExceptionDeprecated.Register bean definitions contained in a Map. Ignore ineligible properties.- Parameters:
map- a map ofnametoproperty(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: for example, 'beans.' (can be empty ornull)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:
-
registerBeanDefinition
protected void registerBeanDefinition(String beanName, Map<?, ?> map, String prefix, String resourceDescription) throws BeansExceptionDeprecated.Get all property values, given a prefix (which will be stripped) and add the bean they define to the factory with the given name.- Parameters:
beanName- the name of the bean to definemap- a Map containing string pairsprefix- the prefix of each entry, which will be strippedresourceDescription- the description of the resource that the Map came from (for logging purposes)- Throws:
BeansException- if the bean definition could not be parsed or registered
-