|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ConfigurableBeanFactory
Configuration interface to be implemented by most bean factories. Provides facilities for configuring a bean factory, in addition to the client view in the BeanFactory and HierarchicalBeanFactory interfaces.
This subinterface of BeanFactory is not meant to be used in normal application code: Stick to BeanFactory or ListableBeanFactory for typical use cases. This interface is just meant to allow for framework-internal plug'n'play even when needing access to bean factory configuration methods.
BeanFactory
,
HierarchicalBeanFactory
,
ListableBeanFactory
,
ConfigurableListableBeanFactory
Field Summary |
---|
Fields inherited from interface org.springframework.beans.factory.BeanFactory |
---|
FACTORY_BEAN_PREFIX |
Method Summary | |
---|---|
void |
addBeanPostProcessor(BeanPostProcessor beanPostProcessor)
Add a new BeanPostProcessor that will get applied to beans created by this factory. |
boolean |
containsSingleton(String beanName)
Check if this bean factory contains a singleton instance with the given name. |
void |
destroySingletons()
Destroy all cached singletons in this factory. |
int |
getBeanPostProcessorCount()
Return the current number of registered BeanPostProcessors. |
void |
registerAlias(String beanName,
String alias)
Given a bean name, create an alias. |
void |
registerCustomEditor(Class requiredType,
PropertyEditor propertyEditor)
Register the given custom property editor for all properties of the given type. |
void |
registerSingleton(String beanName,
Object singletonObject)
Register the given existing object as singleton in the bean factory, under the given bean name. |
void |
setParentBeanFactory(BeanFactory parentBeanFactory)
Set the parent of this bean factory. |
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory |
---|
containsLocalBean, getParentBeanFactory |
Methods inherited from interface org.springframework.beans.factory.BeanFactory |
---|
containsBean, getAliases, getBean, getBean, getType, isSingleton |
Method Detail |
---|
void setParentBeanFactory(BeanFactory parentBeanFactory)
Note that the parent shouldn't be changed: It should only be set outside a constructor if it isn't available when an object of this class is created.
parentBeanFactory
- the parent bean factoryvoid registerCustomEditor(Class requiredType, PropertyEditor propertyEditor)
requiredType
- type of the propertypropertyEditor
- editor to registervoid addBeanPostProcessor(BeanPostProcessor beanPostProcessor)
beanPostProcessor
- the bean processor to registerint getBeanPostProcessorCount()
void registerAlias(String beanName, String alias) throws BeansException
Typically invoked during factory configuration, but can also be used for runtime registration of aliases. Therefore, a factory implementation should synchronize alias access.
beanName
- name of the beanalias
- alias that will behave the same as the bean name
NoSuchBeanDefinitionException
- if there is no bean with the given name
BeansException
- if the alias is already in usevoid registerSingleton(String beanName, Object singletonObject) throws BeansException
The given instance is supposed to be fully initialized; the factory
will not perform any initialization callbacks (in particular, it won't
call InitializingBean's afterPropertiesSet
method).
The given instance will not receive any destruction callbacks
(like DisposableBean's destroy
method) either.
Register a bean definition instead of an existing instance if your bean is supposed to receive initialization and/or destruction callbacks.
Typically invoked during factory configuration, but can also be used for runtime registration of singletons. Therefore, a factory implementation should synchronize singleton access; it will have to do this anyway if it supports lazy initialization of singletons.
beanName
- name of the beansingletonObject
- the existing object
BeansException
- if the singleton could not be registeredInitializingBean.afterPropertiesSet()
,
DisposableBean.destroy()
,
DefaultListableBeanFactory.registerBeanDefinition(java.lang.String, org.springframework.beans.factory.config.BeanDefinition)
boolean containsSingleton(String beanName)
The main purpose of this method is to check manually registered singletons
(see registerSingleton
). Can also be used to check whether a
singleton defined by a bean definition has already been created.
To check whether a bean factory contains a bean definition with a given name,
use ListableBeanFactory's containsBeanDefinition
. Analogous to the
present method, this checks whether the factory contains a registered bean definition.
Note that both of those methods check for the actual given bean name, ignoring aliases.
Use BeanFactory's containsBean
for general checks whether the
factory knows about a bean with a given name (whether manually registed singleton
instance or created by bean definition), also checking ancestor factories. To check
the local factory only, use HierarchicalBeanFactory's containsLocalBean
.
Both of those methods translate aliases back to the corresponding canonical bean name.
beanName
- the name of the bean to look for
registerSingleton(java.lang.String, java.lang.Object)
,
BeanFactory.containsBean(java.lang.String)
,
HierarchicalBeanFactory.containsLocalBean(java.lang.String)
,
ListableBeanFactory.containsBeanDefinition(java.lang.String)
void destroySingletons()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |