org.springframework.beans.factory.config
Interface ConfigurableBeanFactory

public interface ConfigurableBeanFactory
extends HierarchicalBeanFactory
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.

Since03.11.2003
VersionNot specified.
AuthorJuergen Hoeller
Wiki javadoc Use textile entry format.
Add your comments here.
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 org.springframework.beans.factoryHierarchicalBeanFactory
addBeanPostProcessor
public void addBeanPostProcessor ( BeanPostProcessor beanPostProcessor )
Add a new BeanPostProcessor that will get applied to beans created by this factory. To be invoked during factory configuration.
Parameters
TypeNameDescription
BeanPostProcessor beanPostProcessor the bean processor to register
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
containsSingleton
public boolean containsSingleton ( String beanName )
Check if this bean factory contains a singleton instance with the given name. Only checks already instantiated singletons; does not return true for singleton bean definitions that have not been instantiated yet.

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.

Parameters
TypeNameDescription
String beanName the name of the bean to look for
Wiki javadoc Use textile entry format.
Add your comments here.
destroySingletons
public void destroySingletons ( )
Destroy all cached singletons in this factory. To be called on shutdown of a factory.
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
getBeanPostProcessorCount
public int getBeanPostProcessorCount ( )
Return the current number of registered BeanPostProcessors.
Wiki javadoc Use textile entry format.
Add your comments here.
registerAlias
public void registerAlias ( String beanName, String alias )
Given a bean name, create an alias. We typically use this method to support names that are illegal within XML ids (used for bean names).

Typically invoked during factory configuration, but can also be used for runtime registration of aliases. Therefore, a factory implementation should synchronize alias access.

Parameters
TypeNameDescription
String beanName name of the bean
String alias alias that will behave the same as the bean name
Returns void No description provided.
Exceptions
BeansException if the alias is already in use
Wiki javadoc Use textile entry format.
Add your comments here.
registerCustomEditor
public void registerCustomEditor ( Class requiredType, PropertyEditor propertyEditor )
Register the given custom property editor for all properties of the given type. To be invoked during factory configuration.
Parameters
TypeNameDescription
Class requiredType type of the property
PropertyEditor propertyEditor editor to register
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.
registerSingleton
public void registerSingleton ( String beanName, Object singletonObject )
Register the given existing object as singleton in the bean factory, under the given bean name.

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.

Parameters
TypeNameDescription
String beanName name of the bean
Object singletonObject the existing object
Returns void No description provided.
Exceptions
BeansException if the singleton could not be registered
Wiki javadoc Use textile entry format.
Add your comments here.
setParentBeanFactory
public void setParentBeanFactory ( BeanFactory parentBeanFactory )
Set the parent of this bean factory.

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.

Parameters
TypeNameDescription
BeanFactory parentBeanFactory the parent bean factory
Returns void No description provided.
Wiki javadoc Use textile entry format.
Add your comments here.