Spring BeanFactory学习

Spring Ioc容器是Spring的核心,其中BeanFactory定义了IoC容器的基本功能,所有Ioc容器实现该接口。其最重要的是getBean(),它是BeanFactory的主要方法,通过这个方法,可以取得IoC的容器管理的Bean。我们所熟悉的ApplicationContext也是实现了该接口。

 

下面是BeanFactory接口的源代码:

public interface BeanFactory {

		String FACTORY_BEAN_PREFIX = "&";

		Object getBean(String name) throws BeansException;

		<T> T getBean(String name, Class<T> requiredType) throws BeansException;

		<T> T getBean(Class<T> requiredType) throws BeansException;

		Object getBean(String name, Object... args) throws BeansException;

		boolean containsBean(String name);

		boolean isSingleton(String name) throws NoSuchBeanDefinitionException;

		boolean isPrototype(String name) throws NoSuchBeanDefinitionException;

		boolean isTypeMatch(String name, Class<?> targetType) throws NoSuchBeanDefinitionException;

		Class<?> getType(String name) throws NoSuchBeanDefinitionException;

		String[] getAliases(String name);

}

 

 

你可能感兴趣的:(beanfactory)