BeanDefinition属性 BeanDefinition是用来描述一个Bean实例的,包括属性值、构造方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 public interface BeanDefinition extends AttributeAccessor , BeanMetadataElement { String SCOPE_SINGLETON = ConfigurableBeanFactory.SCOPE_SINGLETON; String SCOPE_PROTOTYPE = ConfigurableBeanFactory.SCOPE_PROTOTYPE; void setScope (String scope) ; String getScope () ; int ROLE_APPLICATION = 0 ; int ROLE_SUPPORT = 1 ; int ROLE_INFRASTRUCTURE = 2 ; void setParentName (String parentName) ; String getParentName () ; void setBeanClassName (String beanClassName) ; String getBeanClassName () ; void setLazyInit (boolean lazyInit) ; boolean isLazyInit () ; void setDependsOn (String... dependsOn) ; String[] getDependsOn(); void setAutowireCandidate (boolean autowireCandidate) ; boolean isAutowireCandidate () ; void setPrimary (boolean primary) ; boolean isPrimary () ; void setFactoryBeanName (String factoryBeanName) ; String getFactoryBeanName () ; void setFactoryMethodName (String factoryMethodName) ; String getFactoryMethodName () ; ConstructorArgumentValues getConstructorArgumentValues () ; MutablePropertyValues getPropertyValues () ; boolean isSingleton () ; boolean isPrototype () ; boolean isAbstract () ; int getRole () ; String getDescription () ; String getResourceDescription () ; BeanDefinition getOriginatingBeanDefinition () ; }
子类 AbstractBeanDefinition AbstractBeanDefinition是一个抽象类,定义了BeanDefinition中对应的get/set方法的属性
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccessor implements BeanDefinition , Cloneable { public static final String SCOPE_DEFAULT = "" ; public static final int AUTOWIRE_NO = AutowireCapableBeanFactory.AUTOWIRE_NO; public static final int AUTOWIRE_BY_NAME = AutowireCapableBeanFactory.AUTOWIRE_BY_NAME; public static final int AUTOWIRE_BY_TYPE = AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE; public static final int AUTOWIRE_CONSTRUCTOR = AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR; public static final int DEPENDENCY_CHECK_NONE = 0 ; public static final int DEPENDENCY_CHECK_OBJECTS = 1 ; public static final int DEPENDENCY_CHECK_SIMPLE = 2 ; public static final int DEPENDENCY_CHECK_ALL = 3 ; public static final String INFER_METHOD = "(inferred)" ; private volatile Object beanClass; private String scope = SCOPE_DEFAULT; private boolean abstractFlag = false ; private boolean lazyInit = false ; private int autowireMode = AUTOWIRE_NO; private int dependencyCheck = DEPENDENCY_CHECK_NONE; private String[] dependsOn; private boolean autowireCandidate = true ; private boolean primary = false ; private final Map<String, AutowireCandidateQualifier> qualifiers = new LinkedHashMap<String, AutowireCandidateQualifier>(0 ); private boolean nonPublicAccessAllowed = true ; private boolean lenientConstructorResolution = true ; private String factoryBeanName; private String factoryMethodName; private ConstructorArgumentValues constructorArgumentValues; private MutablePropertyValues propertyValues; private MethodOverrides methodOverrides = new MethodOverrides(); private String initMethodName; private String destroyMethodName; private boolean enforceInitMethod = true ; private boolean enforceDestroyMethod = true ; private boolean synthetic = false ; private int role = BeanDefinition.ROLE_APPLICATION; private String description; private Resource resource; }
RootBeanDefinition 对应了一般的元素标签
1 public class RootBeanDefinition extends AbstractBeanDefinition
ChildBeanDefinition 可以让子BeanDefinition定义拥有从父BeanDefinition那里继承配置的能力
1 public class ChildBeanDefinition extends AbstractBeanDefinition
GenericBeanDefinition 可以动态设置父Bean,同时兼具了RootBeanDefinition和ChildBeanDefinition的功能
1 public class GenericBeanDefinition extends AbstractBeanDefinition
AnnotatedBeanDefinition 接口,表示注解类型的BeanDefinition,拥有获取元数据和方法元数据的能力
1 public interface AnnotatedBeanDefinition extends BeanDefinition
AnnotatedGenericBeanDefinition 使用了@Configuration注解的配置类会被解析为AnnotatedGenericBeanDefinition
1 public class AnnotatedGenericBeanDefinition extends GenericBeanDefinition implements AnnotatedBeanDefinition