|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.beans.factory.support.AbstractBeanDefinitionReader org.springframework.beans.factory.support.PropertiesBeanDefinitionReader
public class 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.(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)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.
DefaultListableBeanFactory
Field Summary | |
---|---|
static String |
ABSTRACT_KEY
Special key to distinguish owner. |
static String |
CLASS_KEY
Special key to distinguish owner. |
static String |
LAZY_INIT_KEY
Special key to distinguish owner. |
static String |
PARENT_KEY
Special key to distinguish owner. |
static String |
REF_PREFIX
Prefix before values referencing other beans. |
static String |
REF_SUFFIX
Property suffix for references to other beans in the current BeanFactory: e.g. owner.dog(ref)=fido. |
static String |
SEPARATOR
Separator between bean name and property name. |
static String |
SINGLETON_KEY
Special key to distinguish owner. |
static String |
TRUE_VALUE
Value of a T/F attribute that represents true. |
Fields inherited from class org.springframework.beans.factory.support.AbstractBeanDefinitionReader |
---|
logger |
Constructor Summary | |
---|---|
PropertiesBeanDefinitionReader(BeanDefinitionRegistry beanFactory)
Create new PropertiesBeanDefinitionReader for the given bean factory. |
Method Summary | |
---|---|
String |
getDefaultParentBean()
Return the default parent bean for this bean factory. |
PropertiesPersister |
getPropertiesPersister()
Return the PropertiesPersister to use for parsing properties files. |
int |
loadBeanDefinitions(EncodedResource encodedResource)
Load bean definitions from the specified properties file. |
int |
loadBeanDefinitions(EncodedResource encodedResource,
String prefix)
Load bean definitions from the specified properties file. |
int |
loadBeanDefinitions(Resource resource)
Load bean definitions from the specified properties file, using all property keys (i.e. not filtering by prefix). |
int |
loadBeanDefinitions(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. not filtering by prefix). |
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. not filtering by prefix). |
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(PropertiesPersister propertiesPersister)
Set the PropertiesPersister to use for parsing properties files. |
Methods inherited from class org.springframework.beans.factory.support.AbstractBeanDefinitionReader |
---|
getBeanClassLoader, getBeanFactory, getResourceLoader, loadBeanDefinitions, loadBeanDefinitions, loadBeanDefinitions, setBeanClassLoader, setResourceLoader |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String TRUE_VALUE
public static final String SEPARATOR
public static final String CLASS_KEY
public static final String PARENT_KEY
public static final String ABSTRACT_KEY
public static final String SINGLETON_KEY
public static final String LAZY_INIT_KEY
public static final String REF_SUFFIX
public static final String REF_PREFIX
Constructor Detail |
---|
public PropertiesBeanDefinitionReader(BeanDefinitionRegistry beanFactory)
Method Detail |
---|
public void setDefaultParentBean(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 compatiblity reasons. It still matches the typical use case.
public String getDefaultParentBean()
public void setPropertiesPersister(PropertiesPersister propertiesPersister)
DefaultPropertiesPersister
public PropertiesPersister getPropertiesPersister()
public int loadBeanDefinitions(Resource resource) throws BeansException
resource
- the resource descriptor for the properties file
BeansException
- in case of loading or parsing errorsloadBeanDefinitions(org.springframework.core.io.Resource, String)
public int loadBeanDefinitions(Resource resource, String prefix) throws BeansException
resource
- the resource descriptor for the properties fileprefix
- match or filter within the keys in the map: e.g. 'beans.'
(can be empty or null
)
BeansException
- in case of loading or parsing errorspublic int loadBeanDefinitions(EncodedResource encodedResource) throws BeansException
encodedResource
- the resource descriptor for the properties file,
allowing to specify an encoding to use for parsing the file
BeansException
- in case of loading or parsing errorspublic int loadBeanDefinitions(EncodedResource encodedResource, String prefix) throws BeansException
encodedResource
- the resource descriptor for the properties file,
allowing to specify an encoding to use for parsing the file
BeansException
- in case of loading or parsing errorspublic int registerBeanDefinitions(ResourceBundle rb) throws BeanDefinitionStoreException
rb
- the ResourceBundle to load from
BeansException
- in case of loading or parsing errors
BeanDefinitionStoreException
registerBeanDefinitions(java.util.ResourceBundle, String)
public int registerBeanDefinitions(ResourceBundle rb, 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
- match or filter within the keys in the map: e.g. 'beans.'
(can be empty or null
)
BeansException
- in case of loading or parsing errors
BeanDefinitionStoreException
public int registerBeanDefinitions(Map map) throws BeansException
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 errorsregisterBeanDefinitions(java.util.Map, String, String)
public int registerBeanDefinitions(Map map, String prefix) throws BeansException
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
- The match or filter within the keys in the map: e.g. 'beans.'
BeansException
- in case of loading or parsing errorspublic int registerBeanDefinitions(Map map, String prefix, String resourceDescription) throws BeansException
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
- match or 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
- 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
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |