站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.1.0 API 文档英文版

BeanDefinitionRegistry (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.beans.factory.support
Interface BeanDefinitionRegistry

All Known Implementing Classes:
DefaultListableBeanFactory, GenericApplicationContext, GenericWebApplicationContext, ResourceAdapterApplicationContext, StaticApplicationContext, StaticPortletApplicationContext, StaticWebApplicationContext, XmlBeanFactory

public interface BeanDefinitionRegistry

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.

Since:
26.11.2003
Author:
Juergen Hoeller
See Also:
BeanDefinition, AbstractBeanDefinition, RootBeanDefinition, ChildBeanDefinition, DefaultListableBeanFactory, GenericApplicationContext, XmlBeanDefinitionReader, PropertiesBeanDefinitionReader

Method Summary
 boolean containsBeanDefinition(String beanName)
          Check if this registry contains a bean definition with the given name.
 String[] getAliases(String beanName)
          Return the aliases for the given bean name, if defined.
 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.
 void registerAlias(String beanName, String alias)
          Given a bean name, create an alias.
 void registerBeanDefinition(String beanName, BeanDefinition beanDefinition)
          Register a new bean definition with this registry.
 

Method Detail

registerBeanDefinition

void registerBeanDefinition(String beanName,
                            BeanDefinition beanDefinition)
                            throws BeanDefinitionStoreException
Register a new bean definition with this registry. Must support RootBeanDefinition and ChildBeanDefinition.

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

getBeanDefinition

BeanDefinition getBeanDefinition(String beanName)
                                 throws NoSuchBeanDefinitionException
Return the BeanDefinition for the given bean name.

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

boolean containsBeanDefinition(String beanName)
Check if this registry contains a bean definition with the given name.

Parameters:
beanName - the name of the bean to look for
Returns:
if this registry contains a bean definition with the given name

getBeanDefinitionNames

String[] getBeanDefinitionNames()
Return the names of all beans defined in this registry.

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

getBeanDefinitionCount

int getBeanDefinitionCount()
Return the number of beans defined in the registry.

Returns:
the number of beans defined in the registry

registerAlias

void registerAlias(String beanName,
                   String alias)
                   throws BeanDefinitionStoreException
Given a bean name, create an alias. We typically use this method to support names that are illegal within XML ids (used for bean names).

Parameters:
beanName - the canonical name of the bean
alias - the alias to be registered for the bean
Throws:
BeanDefinitionStoreException - if the alias is already in use

getAliases

String[] getAliases(String beanName)
Return the aliases for the given bean name, if defined.

Parameters:
beanName - the bean name to check for aliases
Returns:
the aliases, or an empty array if none

The Spring Framework

Copyright © 2002-2007 The Spring Framework.