Top Description Methods
org.springframework.beans.factory.support

public Interface BeanDefinitionRegistry

extends AliasRegistry
Known Direct Implementers
org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry, org.springframework.beans.factory.support.DefaultListableBeanFactory
Imports
org.springframework.beans.factory.BeanDefinitionStoreException, .NoSuchBeanDefinitionException, org.springframework.beans.factory.config.BeanDefinition, org.springframework.core.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.

Author
Juergen Hoeller
Since
26.11.2003
See Also
org.springframework.beans.factory.config.BeanDefinition, AbstractBeanDefinition, RootBeanDefinition, ChildBeanDefinition, DefaultListableBeanFactory, org.springframework.context.support.GenericApplicationContext, org.springframework.beans.factory.xml.XmlBeanDefinitionReader, PropertiesBeanDefinitionReader

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

if this registry contains a bean definition with the given name
containsBeanDefinition
(String
the name of the bean to look for
beanName
)

Check if this registry contains a bean definition with the given name.

public BeanDefinition

Returns:

the BeanDefinition for the given name (never null)
getBeanDefinition
(String
name of the bean to find a definition for
beanName
)

Return the BeanDefinition for the given bean name.

public int

Returns:

the number of beans defined in the registry
getBeanDefinitionCount
()

Return the number of beans defined in the registry.

public String[]

Returns:

the names of all beans defined in this registry, or an empty array if none defined
getBeanDefinitionNames
()

Return the names of all beans defined in this registry.

public default boolean

Returns:

whether the definition for the given bean name is overridable
isBeanDefinitionOverridable
(String
the name to check
beanName
)

Determine whether the bean definition for the given name is overridable, i.e. whether registerBeanDefinition would successfully return against an existing definition of the same name.

public boolean

Returns:

whether the given bean name is already in use
isBeanNameInUse
(String
the name to check
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.

public void
registerBeanDefinition(String
the name of the bean instance to register
beanName
,
BeanDefinition
definition of the bean instance to register
beanDefinition
)

Register a new bean definition with this registry.

public void
removeBeanDefinition(String
the name of the bean instance to register
beanName
)

Remove the BeanDefinition for the given name.

Inherited from org.springframework.core.AliasRegistry:
getAliasesisAliasregisterAliasremoveAlias

Method Detail

containsBeanDefinitionback to summary
public boolean containsBeanDefinition(String beanName)

Check if this registry contains a bean definition with the given name.

Parameters
beanName:String

the name of the bean to look for

Returns:boolean

if this registry contains a bean definition with the given name

getBeanDefinitionback to summary
public BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException

Return the BeanDefinition for the given bean name.

Parameters
beanName:String

name of the bean to find a definition for

Returns:BeanDefinition

the BeanDefinition for the given name (never null)

Exceptions
NoSuchBeanDefinitionException:
if there is no such bean definition
getBeanDefinitionCountback to summary
public int getBeanDefinitionCount()

Return the number of beans defined in the registry.

Returns:int

the number of beans defined in the registry

getBeanDefinitionNamesback to summary
public String[] getBeanDefinitionNames()

Return the names of all beans defined in this registry.

Returns:String[]

the names of all beans defined in this registry, or an empty array if none defined

isBeanDefinitionOverridableback to summary
public default boolean isBeanDefinitionOverridable(String beanName)

Determine whether the bean definition for the given name is overridable, i.e. whether registerBeanDefinition would successfully return against an existing definition of the same name.

The default implementation returns true.

Parameters
beanName:String

the name to check

Returns:boolean

whether the definition for the given bean name is overridable

Since
6.1
isBeanNameInUseback to summary
public 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.

Parameters
beanName:String

the name to check

Returns:boolean

whether the given bean name is already in use

registerBeanDefinitionback to summary
public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) throws BeanDefinitionStoreException

Register a new bean definition with this registry. Must support RootBeanDefinition and ChildBeanDefinition.

Parameters
beanName:String

the name of the bean instance to register

beanDefinition:BeanDefinition

definition of the bean instance to register

Exceptions
BeanDefinitionStoreException:
if the BeanDefinition is invalid
BeanDefinitionOverrideException:
if there is already a BeanDefinition for the specified bean name and we are not allowed to override it
See Also
GenericBeanDefinition, RootBeanDefinition, ChildBeanDefinition
removeBeanDefinitionback to summary
public void removeBeanDefinition(String beanName) throws NoSuchBeanDefinitionException

Remove the BeanDefinition for the given name.

Parameters
beanName:String

the name of the bean instance to register

Exceptions
NoSuchBeanDefinitionException:
if there is no such bean definition