AutowireCapableBeanFactory
在BeanFactory
基础上实现了对存在实例的管理。可以使用这个接口集成其它框架,捆绑并填充并不由Spring管理生命周期并已存在的实例。像集成WebWork的Actions 和Tapestry Page就很实用。
一般应用开发者不会使用这个接口,所以像ApplicationContext这样的外观实现类不会实现这个接口。如果真手痒痒可以通过ApplicationContext的getAutowireCapableBeanFactory接口获取。
public interface AutowireCapableBeanFactory extends BeanFactory {
int AUTOWIRE_NO = 0; // 这个常量表明工厂没有自动装配的Bean
int AUTOWIRE_BY_NAME = 1; // 表明根据名称自动装配
int AUTOWIRE_BY_TYPE = 2; // 表明根据类型自动装配
int AUTOWIRE_CONSTRUCTOR = 3; // 表明根据构造方法快速装配
/** @deprecated */
@Deprecated
int AUTOWIRE_AUTODETECT = 4;
String ORIGINAL_INSTANCE_SUFFIX = ".ORIGINAL";
// 创建和填充外部bean实例的典型方法
<T> T createBean(Class<T> var1) throws BeansException;
// 自动装配属性,填充属性值,使用诸如setBeanName,setBeanFactory这样的工厂回调填充属性,最好还要调用post processor
void autowireBean(Object var1) throws BeansException;
Object configureBean(Object var1, String var2) throws BeansException;
// 会执行bean完整的初始化,包括BeanPostProcessors和initializeBean
Object createBean(Class<?> var1, int var2, boolean var3) throws BeansException;
Object autowire(Class<?> var1, int var2, boolean var3) throws BeansException;
// 使用autowireBeanProperties装配属性
void autowireBeanProperties(Object var1, int var2, boolean var3) throws BeansException;
void applyBeanPropertyValues(Object var1, String var2) throws BeansException;
Object initializeBean(Object var1, String var2) throws BeansException;
Object applyBeanPostProcessorsBeforeInitialization(Object var1, String var2) throws BeansException;
Object applyBeanPostProcessorsAfterInitialization(Object var1, String var2) throws BeansException;
void destroyBean(Object var1);
<T> NamedBeanHolder<T> resolveNamedBean(Class<T> var1) throws BeansException;
Object resolveBeanByName(String var1, DependencyDescriptor var2) throws BeansException;
@Nullable
Object resolveDependency(DependencyDescriptor var1, @Nullable String var2) throws BeansException;
@Nullable
Object resolveDependency(DependencyDescriptor var1, @Nullable String var2, @Nullable Set<String> var3, @Nullable TypeConverter var4) throws BeansException;
}