简单对比
BeanFactory接口用来生产Bean,它处理生产bean的接口体系的最顶层,它为其他具体的IOC容器提供了最基本的规范,例如DefaultListableBeanFactory,XmlBeanFactory,ApplicationContext 等具体的容器都是实现了BeanFactory,再在其基础之上附加了其他的功能。
接口用来定制Bean的生产过程,getObject方法中可以实现自定义过程。
JDK1.8源码
BeanFactory接口
public interface BeanFactory { String FACTORY_BEAN_PREFIX = "&"; Object getBean(String var1) throws BeansException; T getBean(String var1, Class var2) throws BeansException; T getBean(Class var1) throws BeansException; Object getBean(String var1, Object... var2) throws BeansException; T getBean(Class var1, Object... var2) throws BeansException; boolean containsBean(String var1); boolean isSingleton(String var1) throws NoSuchBeanDefinitionException; boolean isPrototype(String var1) throws NoSuchBeanDefinitionException; boolean isTypeMatch(String var1, ResolvableType var2) throws NoSuchBeanDefinitionException; boolean isTypeMatch(String var1, Class var2) throws NoSuchBeanDefinitionException; Class getType(String var1) throws NoSuchBeanDefinitionException; String[] getAliases(String var1); }
FactoryBean接口
public interface FactoryBean { T getObject() throws Exception; Class getObjectType(); boolean isSingleton(); }