| java.lang.Object org.springframework.beans.factory.support.AbstractBeanDefinitionReader org.springframework.beans.factory.support.PropertiesBeanDefinitionReader
PropertiesBeanDefinitionReader | public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader (Code) | | 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.(singleton)=false // 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
Note: As of Spring 1.2.6, the use of class and
parent has been deprecated in favor of (class) and
(parent) , for consistency with all other special properties.
Users should note that support for class and parent
as special properties rather then actual bean properties will be removed in a
future version.
author: Rod Johnson author: Juergen Hoeller author: Rob Harrop since: 26.11.2003 See Also: DefaultListableBeanFactory |
Field Summary | |
final public static String | ABSTRACT_KEY Special key to distinguish owner.(abstract)=true
Default is "false". | final public static String | CLASS_KEY | final public static String | CONSTRUCTOR_ARG_PREFIX Prefix used to denote a constructor argument definition. | final public static String | LAZY_INIT_KEY Special key to distinguish owner.(lazy-init)=true
Default is "false". | final public static String | PARENT_KEY | final public static String | REF_PREFIX Prefix before values referencing other beans. | final public static String | REF_SUFFIX Property suffix for references to other beans in the current
BeanFactory: e.g. | final public static String | SEPARATOR Separator between bean name and property name. | final public static String | SINGLETON_KEY Special key to distinguish owner.(singleton)=true
Default is "true". | final public static String | TRUE_VALUE Value of a T/F attribute that represents true.
Anything else represents false. |
Method Summary | |
public String | getDefaultParentBean() Return the default parent bean for this bean factory. | public PropertiesPersister | getPropertiesPersister() Return the PropertiesPersister to use for parsing properties files. | public int | loadBeanDefinitions(Resource resource) Load bean definitions from the specified properties file,
using all property keys (i.e. | public int | loadBeanDefinitions(Resource resource, String prefix) Load bean definitions from the specified properties file.
Parameters: resource - the resource descriptor for the properties file Parameters: prefix - match or filter within the keys in the map: e.g. | public int | loadBeanDefinitions(EncodedResource encodedResource) Load bean definitions from the specified properties file. | public int | loadBeanDefinitions(EncodedResource encodedResource, String prefix) Load bean definitions from the specified properties file. | protected void | registerBeanDefinition(String beanName, Map map, String prefix, String resourceDescription) | public int | registerBeanDefinitions(ResourceBundle rb) Register bean definitions contained in a resource bundle,
using all property keys (i.e. | public int | registerBeanDefinitions(ResourceBundle rb, String prefix) Register bean definitions contained in a ResourceBundle.
Similar syntax as for a Map. | public int | registerBeanDefinitions(Map map) Register bean definitions contained in a Map,
using all property keys (i.e. | public int | registerBeanDefinitions(Map map, String prefix) Register bean definitions contained in a Map.
Ignore ineligible properties.
Parameters: map - Map name -> property (String or Object). | public int | registerBeanDefinitions(Map map, String prefix, String resourceDescription) Register bean definitions contained in a Map.
Ignore ineligible properties.
Parameters: map - Map name -> property (String or Object). | public void | setDefaultParentBean(String defaultParentBean) 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. | public void | setPropertiesPersister(PropertiesPersister propertiesPersister) Set the PropertiesPersister to use for parsing properties files. |
ABSTRACT_KEY | final public static String ABSTRACT_KEY(Code) | | Special key to distinguish owner.(abstract)=true
Default is "false".
|
CLASS_KEY | final public static String CLASS_KEY(Code) | | Special key to distinguish owner.(class)=com.myapp.MyClass
|
CONSTRUCTOR_ARG_PREFIX | final public static String CONSTRUCTOR_ARG_PREFIX(Code) | | Prefix used to denote a constructor argument definition.
|
LAZY_INIT_KEY | final public static String LAZY_INIT_KEY(Code) | | Special key to distinguish owner.(lazy-init)=true
Default is "false".
|
PARENT_KEY | final public static String PARENT_KEY(Code) | | Special key to distinguish owner.(parent)=parentBeanName
|
REF_PREFIX | final public static String REF_PREFIX(Code) | | Prefix before values referencing other beans.
|
REF_SUFFIX | final public static String REF_SUFFIX(Code) | | 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 | final public static String SEPARATOR(Code) | | Separator between bean name and property name.
We follow normal Java conventions.
|
SINGLETON_KEY | final public static String SINGLETON_KEY(Code) | | Special key to distinguish owner.(singleton)=true
Default is "true".
|
TRUE_VALUE | final public static String TRUE_VALUE(Code) | | Value of a T/F attribute that represents true.
Anything else represents false. Case seNsItive.
|
PropertiesBeanDefinitionReader | public PropertiesBeanDefinitionReader(BeanDefinitionRegistry beanFactory)(Code) | | Create new PropertiesBeanDefinitionReader for the given bean factory.
|
getDefaultParentBean | public String getDefaultParentBean()(Code) | | Return the default parent bean for this bean factory.
|
getPropertiesPersister | public PropertiesPersister getPropertiesPersister()(Code) | | Return the PropertiesPersister to use for parsing properties files.
|
loadBeanDefinitions | public int loadBeanDefinitions(Resource resource, String prefix) throws BeansException(Code) | | Load bean definitions from the specified properties file.
Parameters: resource - the resource descriptor for the properties file Parameters: prefix - match or filter within the keys in the map: e.g. 'beans.'(can be empty or null ) the number of bean definitions found throws: BeansException - in case of loading or parsing errors |
loadBeanDefinitions | public int loadBeanDefinitions(EncodedResource encodedResource) throws BeansException(Code) | | 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 the number of bean definitions found throws: BeansException - in case of loading or parsing errors |
loadBeanDefinitions | public int loadBeanDefinitions(EncodedResource encodedResource, String prefix) throws BeansException(Code) | | 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 the number of bean definitions found throws: BeansException - in case of loading or parsing errors |
registerBeanDefinition | protected void registerBeanDefinition(String beanName, Map map, String prefix, String resourceDescription) throws BeansException(Code) | | 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 - name of the bean to define Parameters: map - Map containing string pairs Parameters: prefix - prefix of each entry, which will be stripped Parameters: resourceDescription - description of the resource that the Map came from(for logging purposes) throws: BeansException - if the bean definition could not be parsed or registered |
registerBeanDefinitions | public int registerBeanDefinitions(ResourceBundle rb, String prefix) throws BeanDefinitionStoreException(Code) | | 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 from Parameters: prefix - match or filter within the keys in the map: e.g. 'beans.'(can be empty or null ) the number of bean definitions found throws: BeansException - in case of loading or parsing errors |
registerBeanDefinitions | public int registerBeanDefinitions(Map map, String prefix) throws BeansException(Code) | | Register bean definitions contained in a Map.
Ignore ineligible properties.
Parameters: map - Map name -> property (String or Object). Property valueswill be strings if coming from a Properties file etc. Property names(keys) must be Strings. Class keys must be Strings. Parameters: prefix - The match or filter within the keys in the map: e.g. 'beans.' the number of bean definitions found throws: BeansException - in case of loading or parsing errors |
registerBeanDefinitions | public int registerBeanDefinitions(Map map, String prefix, String resourceDescription) throws BeansException(Code) | | Register bean definitions contained in a Map.
Ignore ineligible properties.
Parameters: map - Map name -> property (String or Object). Property valueswill be strings if coming from a Properties file etc. Property names(keys) must be strings. Class keys must be Strings. Parameters: prefix - match or filter within the keys in the map: e.g. 'beans.'(can be empty or null ) Parameters: resourceDescription - description of the resource that the Map came from(for logging purposes) the number of bean definitions found throws: BeansException - in case of loading or parsing errors See Also: PropertiesBeanDefinitionReader.registerBeanDefinitions(Map,String) |
setDefaultParentBean | public void setDefaultParentBean(String defaultParentBean)(Code) | | 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.
|
Fields inherited from org.springframework.beans.factory.support.AbstractBeanDefinitionReader | final protected Log logger(Code)(Java Doc)
|
|
|