BeanDefinition是描述bean的一个接口
public interface BeanDefinition extends AttributeAccessor, BeanMetadataElement {
//单例常量
String SCOPE_SINGLETON = ConfigurableBeanFactory.SCOPE_SINGLETON;
·
String SCOPE_PROTOTYPE = ConfigurableBeanFactory.SCOPE_PROTOTYPE;
int ROLE_APPLICATION = 0;
int ROLE_SUPPORT = 1;
int ROLE_INFRASTRUCTURE = 2;
//设置父bean的名称
void setParentName(@Nullable String parentName);
@Nullable
String getParentName();
//设置类名
void setBeanClassName(@Nullable String beanClassName);
@Nullable
String getBeanClassName();
void setScope(@Nullable String scope);
@Nullable
String getScope();
//是否懒加载
void setLazyInit(boolean lazyInit);
boolean isLazyInit();
void setDependsOn(@Nullable String... dependsOn);
@Nullable
String[] getDependsOn();
void setAutowireCandidate(boolean autowireCandidate);
boolean isAutowireCandidate();
void setPrimary(boolean primary);
boolean isPrimary();
void setFactoryBeanName(@Nullable String factoryBeanName);
@Nullable
String getFactoryBeanName();
void setFactoryMethodName(@Nullable String factoryMethodName);
@Nullable
String getFactoryMethodName();
ConstructorArgumentValues getConstructorArgumentValues();
default boolean hasConstructorArgumentValues() {
return !getConstructorArgumentValues().isEmpty();
}
MutablePropertyValues getPropertyValues();
default boolean hasPropertyValues() {
return !getPropertyValues().isEmpty();
}
void setInitMethodName(@Nullable String initMethodName);
@Nullable
String getInitMethodName();
void setDestroyMethodName(@Nullable String destroyMethodName);
@Nullable
String getDestroyMethodName();
void setRole(int role);
int getRole();
void setDescription(@Nullable String description);
@Nullable
String getDescription();
ResolvableType getResolvableType();
boolean isSingleton();
boolean isPrototype();
boolean isAbstract();
@Nullable
String getResourceDescription();
@Nullable
BeanDefinition getOriginatingBeanDefinition();
}
AnnotatedBeanDefinition继承了BeanDefiniton并新增了两个方法,getMetadata和getFactoryMethodMetadata
public interface AnnotatedBeanDefinition extends BeanDefinition {
//获取类的注解信息
AnnotationMetadata getMetadata();
//获取factory方法的注解信息
@Nullable
MethodMetadata getFactoryMethodMetadata();
}
此接口用于解析注解的bean