Class SimpleBeanDefinitionRegistry
java.lang.Object
org.springframework.core.SimpleAliasRegistry
org.springframework.beans.factory.support.SimpleBeanDefinitionRegistry
- All Implemented Interfaces:
BeanDefinitionRegistry
,AliasRegistry
public class SimpleBeanDefinitionRegistry
extends SimpleAliasRegistry
implements BeanDefinitionRegistry
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.- Since:
- 2.5.2
- Author:
- Juergen Hoeller
-
Field Summary
Fields inherited from class org.springframework.core.SimpleAliasRegistry
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsBeanDefinition
(String beanName) Check if this registry contains a bean definition with the given name.getBeanDefinition
(String beanName) Return the BeanDefinition for the given bean name.int
Return the number of beans defined in the registry.String[]
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.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.Methods inherited from class org.springframework.core.SimpleAliasRegistry
allowAliasOverriding, canonicalName, checkForAliasCircle, getAliases, hasAlias, isAlias, registerAlias, removeAlias, resolveAliases
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.core.AliasRegistry
getAliases, isAlias, registerAlias, removeAlias
Methods inherited from interface org.springframework.beans.factory.support.BeanDefinitionRegistry
isBeanDefinitionOverridable
-
Constructor Details
-
SimpleBeanDefinitionRegistry
public SimpleBeanDefinitionRegistry()
-
-
Method Details
-
registerBeanDefinition
public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) throws BeanDefinitionStoreException Description copied from interface:BeanDefinitionRegistry
Register a new bean definition with this registry. Must support RootBeanDefinition and ChildBeanDefinition.- Specified by:
registerBeanDefinition
in interfaceBeanDefinitionRegistry
- Parameters:
beanName
- the name of the bean instance to registerbeanDefinition
- definition of the bean instance to register- Throws:
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- See Also:
-
removeBeanDefinition
Description copied from interface:BeanDefinitionRegistry
Remove the BeanDefinition for the given name.- Specified by:
removeBeanDefinition
in interfaceBeanDefinitionRegistry
- Parameters:
beanName
- the name of the bean instance to register- Throws:
NoSuchBeanDefinitionException
- if there is no such bean definition
-
getBeanDefinition
Description copied from interface:BeanDefinitionRegistry
Return the BeanDefinition for the given bean name.- Specified by:
getBeanDefinition
in interfaceBeanDefinitionRegistry
- Parameters:
beanName
- name of the bean to find a definition for- Returns:
- the BeanDefinition for the given name (never
null
) - Throws:
NoSuchBeanDefinitionException
- if there is no such bean definition
-
containsBeanDefinition
Description copied from interface:BeanDefinitionRegistry
Check if this registry contains a bean definition with the given name.- Specified by:
containsBeanDefinition
in interfaceBeanDefinitionRegistry
- Parameters:
beanName
- the name of the bean to look for- Returns:
- if this registry contains a bean definition with the given name
-
getBeanDefinitionNames
Description copied from interface:BeanDefinitionRegistry
Return the names of all beans defined in this registry.- Specified by:
getBeanDefinitionNames
in interfaceBeanDefinitionRegistry
- Returns:
- the names of all beans defined in this registry, or an empty array if none defined
-
getBeanDefinitionCount
public int getBeanDefinitionCount()Description copied from interface:BeanDefinitionRegistry
Return the number of beans defined in the registry.- Specified by:
getBeanDefinitionCount
in interfaceBeanDefinitionRegistry
- Returns:
- the number of beans defined in the registry
-
isBeanNameInUse
Description copied from interface:BeanDefinitionRegistry
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.- Specified by:
isBeanNameInUse
in interfaceBeanDefinitionRegistry
- Parameters:
beanName
- the name to check- Returns:
- whether the given bean name is already in use
-