接口 BeanDefinitionRegistry
- 所有超级接口:
AliasRegistry
- 所有已知实现类:
AnnotationConfigApplicationContext
,DefaultListableBeanFactory
,GenericApplicationContext
,GenericGroovyApplicationContext
,GenericWebApplicationContext
,GenericXmlApplicationContext
,ResourceAdapterApplicationContext
,SimpleBeanDefinitionRegistry
,StaticApplicationContext
,StaticWebApplicationContext
,XmlBeanFactory
public interface BeanDefinitionRegistry extends AliasRegistry
Interface for registries that hold bean definitions, for example RootBeanDefinition and ChildBeanDefinition instances. Typically implemented by BeanFactories that internally work with the AbstractBeanDefinition hierarchy.This is the only interface in Spring's bean factory packages that encapsulates registration of bean definitions. The standard BeanFactory interfaces only cover access to a fully configured factory instance.
Spring's bean definition readers expect to work on an implementation of this interface. Known implementors within the Spring core are DefaultListableBeanFactory and GenericApplicationContext.
- 从以下版本开始:
- 26.11.2003
- 作者:
- Juergen Hoeller
- 另请参阅:
BeanDefinition
,AbstractBeanDefinition
,RootBeanDefinition
,ChildBeanDefinition
,DefaultListableBeanFactory
,GenericApplicationContext
,XmlBeanDefinitionReader
,PropertiesBeanDefinitionReader
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 boolean
containsBeanDefinition(String beanName)
Check if this registry contains a bean definition with the given name.BeanDefinition
getBeanDefinition(String beanName)
Return the BeanDefinition for the given bean name.int
getBeanDefinitionCount()
Return the number of beans defined in the registry.String[]
getBeanDefinitionNames()
Return the names of all beans defined in this registry.boolean
isBeanNameInUse(String beanName)
Determine whether the given bean name is already in use within this registry, i.e. whether there is a local bean or alias registered under this name.void
registerBeanDefinition(String beanName, BeanDefinition beanDefinition)
Register a new bean definition with this registry.void
removeBeanDefinition(String beanName)
Remove the BeanDefinition for the given name.从接口继承的方法 org.springframework.core.AliasRegistry
getAliases, isAlias, registerAlias, removeAlias
方法详细资料
registerBeanDefinition
void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) throws BeanDefinitionStoreException
Register a new bean definition with this registry. Must support RootBeanDefinition and ChildBeanDefinition.- 参数:
beanName
- the name of the bean instance to registerbeanDefinition
- definition of the bean instance to register- 抛出:
BeanDefinitionStoreException
- if the BeanDefinition is invalidBeanDefinitionOverrideException
- if there is already a BeanDefinition for the specified bean name and we are not allowed to override it- 另请参阅:
GenericBeanDefinition
,RootBeanDefinition
,ChildBeanDefinition
removeBeanDefinition
void removeBeanDefinition(String beanName) throws NoSuchBeanDefinitionException
Remove the BeanDefinition for the given name.- 参数:
beanName
- the name of the bean instance to register- 抛出:
NoSuchBeanDefinitionException
- if there is no such bean definition
getBeanDefinition
BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException
Return the BeanDefinition for the given bean name.- 参数:
beanName
- name of the bean to find a definition for- 返回:
- the BeanDefinition for the given name (never
null
) - 抛出:
NoSuchBeanDefinitionException
- if there is no such bean definition
containsBeanDefinition
boolean containsBeanDefinition(String beanName)
Check if this registry contains a bean definition with the given name.- 参数:
beanName
- the name of the bean to look for- 返回:
- if this registry contains a bean definition with the given name
getBeanDefinitionNames
String[] getBeanDefinitionNames()
Return the names of all beans defined in this registry.- 返回:
- the names of all beans defined in this registry, or an empty array if none defined
getBeanDefinitionCount
int getBeanDefinitionCount()
Return the number of beans defined in the registry.- 返回:
- the number of beans defined in the registry
isBeanNameInUse
boolean isBeanNameInUse(String beanName)
Determine whether the given bean name is already in use within this registry, i.e. whether there is a local bean or alias registered under this name.- 参数:
beanName
- the name to check- 返回:
- whether the given bean name is already in use