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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsBeanDefinition(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.intReturn the number of beans defined in the registry.String[]Return the names of all beans defined in this registry.booleanisBeanNameInUse(String beanName) Determine whether the given bean name is already in use within this registry, i.e.voidregisterBeanDefinition(String beanName, BeanDefinition beanDefinition) Register a new bean definition with this registry.voidremoveBeanDefinition(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, resolveAliasesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.core.AliasRegistry
getAliases, isAlias, registerAlias, removeAliasMethods 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:BeanDefinitionRegistryRegister a new bean definition with this registry. Must support RootBeanDefinition and ChildBeanDefinition.- Specified by:
registerBeanDefinitionin 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:BeanDefinitionRegistryRemove the BeanDefinition for the given name.- Specified by:
removeBeanDefinitionin 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:BeanDefinitionRegistryReturn the BeanDefinition for the given bean name.- Specified by:
getBeanDefinitionin 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:BeanDefinitionRegistryCheck if this registry contains a bean definition with the given name.- Specified by:
containsBeanDefinitionin 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:BeanDefinitionRegistryReturn the names of all beans defined in this registry.- Specified by:
getBeanDefinitionNamesin 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:BeanDefinitionRegistryReturn the number of beans defined in the registry.- Specified by:
getBeanDefinitionCountin interfaceBeanDefinitionRegistry- Returns:
- the number of beans defined in the registry
-
isBeanNameInUse
Description copied from interface:BeanDefinitionRegistryDetermine 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:
isBeanNameInUsein interfaceBeanDefinitionRegistry- Parameters:
beanName- the name to check- Returns:
- whether the given bean name is already in use
-