站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 1.2.9 API 文档英文版

ConfigurableBeanFactory (Spring Framework) - Spring Framework 1.2.9 API 文档英文版


org.springframework.beans.factory.config
Interface ConfigurableBeanFactory

All Superinterfaces:
BeanFactory, HierarchicalBeanFactory
All Known Subinterfaces:
ConfigurableListableBeanFactory
All Known Implementing Classes:
AbstractAutowireCapableBeanFactory, AbstractBeanFactory, DefaultListableBeanFactory, XmlBeanFactory

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.

Since:
03.11.2003
Author:
Juergen Hoeller
See Also:
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

setParentBeanFactory

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:
parentBeanFactory - the parent bean factory

registerCustomEditor

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:
requiredType - type of the property
propertyEditor - editor to register

addBeanPostProcessor

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:
beanPostProcessor - the bean processor to register

getBeanPostProcessorCount

int getBeanPostProcessorCount()
Return the current number of registered BeanPostProcessors.


registerAlias

void registerAlias(String beanName,
                   String alias)
                   throws BeansException
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:
beanName - name of the bean
alias - alias that will behave the same as the bean name
Throws:
NoSuchBeanDefinitionException - if there is no bean with the given name
BeansException - if the alias is already in use

registerSingleton

void registerSingleton(String beanName,
                       Object singletonObject)
                       throws BeansException
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:
beanName - name of the bean
singletonObject - the existing object
Throws:
BeansException - if the singleton could not be registered
See Also:
InitializingBean.afterPropertiesSet(), DisposableBean.destroy(), DefaultListableBeanFactory.registerBeanDefinition(java.lang.String, org.springframework.beans.factory.config.BeanDefinition)

containsSingleton

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:
beanName - the name of the bean to look for
Returns:
if this bean factory contains a singleton instance with the given name
See Also:
registerSingleton(java.lang.String, java.lang.Object), BeanFactory.containsBean(java.lang.String), HierarchicalBeanFactory.containsLocalBean(java.lang.String), ListableBeanFactory.containsBeanDefinition(java.lang.String)

destroySingletons

void destroySingletons()
Destroy all cached singletons in this factory. To be called on shutdown of a factory.



Copyright (c) 2002-2007 The Spring Framework Project.