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

public Class SimpleBeanDefinitionRegistry

extends SimpleAliasRegistry
implements BeanDefinitionRegistry
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.support.BeanDefinitionRegistry, org.springframework.core.AliasRegistry
Imports
java.util.Map, java.util.concurrent.ConcurrentHashMap, org.springframework.beans.factory.BeanDefinitionStoreException, .NoSuchBeanDefinitionException, org.springframework.beans.factory.config.BeanDefinition, org.springframework.core.SimpleAliasRegistry, org.springframework.util.Assert, .StringUtils

Simple implementation of the BeanDefinitionRegistry interface. Provides registry capabilities only, with no factory capabilities built in. Can for example be used for testing bean definition readers.
Author
Juergen Hoeller
Since
2.5.2

Field Summary

Modifier and TypeField and Description
private final Map<String, BeanDefinition>
beanDefinitionMap

Map of bean definition objects, keyed by bean name.

Inherited from org.springframework.core.SimpleAliasRegistry:
logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
containsBeanDefinition(String
the name of the bean to look for
beanName
)

Implements org.springframework.beans.factory.support.BeanDefinitionRegistry.containsBeanDefinition.

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

public BeanDefinition
getBeanDefinition(String
name of the bean to find a definition for
beanName
)

Implements org.springframework.beans.factory.support.BeanDefinitionRegistry.getBeanDefinition.

Return the BeanDefinition for the given bean name.

public int
public String[]
public boolean
isBeanNameInUse(String
the name to check
beanName
)

Implements org.springframework.beans.factory.support.BeanDefinitionRegistry.isBeanNameInUse.

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
)

Implements org.springframework.beans.factory.support.BeanDefinitionRegistry.registerBeanDefinition.

Register a new bean definition with this registry.

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

Implements org.springframework.beans.factory.support.BeanDefinitionRegistry.removeBeanDefinition.

Remove the BeanDefinition for the given name.

Inherited from org.springframework.core.SimpleAliasRegistry:
allowAliasOverridingcanonicalNamecheckForAliasCirclegetAliaseshasAliasisAliasregisterAliasremoveAliasresolveAliases

Field Detail

beanDefinitionMapback to summary
private final Map<String, BeanDefinition> beanDefinitionMap

Map of bean definition objects, keyed by bean name.

Constructor Detail

SimpleBeanDefinitionRegistryback to summary
public SimpleBeanDefinitionRegistry()

Method Detail

containsBeanDefinitionback to summary
public boolean containsBeanDefinition(String beanName)

Implements org.springframework.beans.factory.support.BeanDefinitionRegistry.containsBeanDefinition.

Doc from org.springframework.beans.factory.support.BeanDefinitionRegistry.containsBeanDefinition.

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

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

Implements org.springframework.beans.factory.support.BeanDefinitionRegistry.getBeanDefinition.

Doc from org.springframework.beans.factory.support.BeanDefinitionRegistry.getBeanDefinition.

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)

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

Implements org.springframework.beans.factory.support.BeanDefinitionRegistry.getBeanDefinitionCount.

Doc from org.springframework.beans.factory.support.BeanDefinitionRegistry.getBeanDefinitionCount.

Return the number of beans defined in the registry.

Returns:int

the number of beans defined in the registry

Annotations
@Override
getBeanDefinitionNamesback to summary
public String[] getBeanDefinitionNames()

Implements org.springframework.beans.factory.support.BeanDefinitionRegistry.getBeanDefinitionNames.

Doc from org.springframework.beans.factory.support.BeanDefinitionRegistry.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

Annotations
@Override
isBeanNameInUseback to summary
public boolean isBeanNameInUse(String beanName)

Implements org.springframework.beans.factory.support.BeanDefinitionRegistry.isBeanNameInUse.

Doc from org.springframework.beans.factory.support.BeanDefinitionRegistry.isBeanNameInUse.

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

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

Implements org.springframework.beans.factory.support.BeanDefinitionRegistry.registerBeanDefinition.

Doc from org.springframework.beans.factory.support.BeanDefinitionRegistry.registerBeanDefinition.

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

Annotations
@Override
Exceptions
BeanDefinitionStoreException:
if the BeanDefinition is invalid
removeBeanDefinitionback to summary
public void removeBeanDefinition(String beanName) throws NoSuchBeanDefinitionException

Implements org.springframework.beans.factory.support.BeanDefinitionRegistry.removeBeanDefinition.

Doc from org.springframework.beans.factory.support.BeanDefinitionRegistry.removeBeanDefinition.

Remove the BeanDefinition for the given name.

Parameters
beanName:String

the name of the bean instance to register

Annotations
@Override
Exceptions
NoSuchBeanDefinitionException:
if there is no such bean definition