org.springframework.beans.factory.support
Class SimpleBeanDefinitionRegistry

java.lang.Object
  extended by org.springframework.core.SimpleAliasRegistry
      extended by 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

Constructor Summary
SimpleBeanDefinitionRegistry()
           
 
Method Summary
 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.
 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, 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
 

Constructor Detail

SimpleBeanDefinitionRegistry

public SimpleBeanDefinitionRegistry()
Method Detail

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 interface BeanDefinitionRegistry
Parameters:
beanName - the name of the bean instance to register
beanDefinition - definition of the bean instance to register
Throws:
BeanDefinitionStoreException - if the BeanDefinition is invalid or if there is already a BeanDefinition for the specified bean name (and we are not allowed to override it)
See Also:
RootBeanDefinition, ChildBeanDefinition

removeBeanDefinition

public void removeBeanDefinition(String beanName)
                          throws NoSuchBeanDefinitionException
Description copied from interface: BeanDefinitionRegistry
Remove the BeanDefinition for the given name.

Specified by:
removeBeanDefinition in interface BeanDefinitionRegistry
Parameters:
beanName - the name of the bean instance to register
Throws:
NoSuchBeanDefinitionException - if there is no such bean definition

getBeanDefinition

public BeanDefinition getBeanDefinition(String beanName)
                                 throws NoSuchBeanDefinitionException
Description copied from interface: BeanDefinitionRegistry
Return the BeanDefinition for the given bean name.

Specified by:
getBeanDefinition in interface BeanDefinitionRegistry
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

public boolean containsBeanDefinition(String beanName)
Description copied from interface: BeanDefinitionRegistry
Check if this registry contains a bean definition with the given name.

Specified by:
containsBeanDefinition in interface BeanDefinitionRegistry
Parameters:
beanName - the name of the bean to look for
Returns:
if this registry contains a bean definition with the given name

getBeanDefinitionNames

public String[] getBeanDefinitionNames()
Description copied from interface: BeanDefinitionRegistry
Return the names of all beans defined in this registry.

Specified by:
getBeanDefinitionNames in interface BeanDefinitionRegistry
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 interface BeanDefinitionRegistry
Returns:
the number of beans defined in the registry

isBeanNameInUse

public boolean isBeanNameInUse(String beanName)
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 interface BeanDefinitionRegistry
Parameters:
beanName - the name to check
Returns:
whether the given bean name is already in use