编程语言
首页 > 编程语言> > springboot源码解析-管中窥豹系列之BeanDefinition(八)

springboot源码解析-管中窥豹系列之BeanDefinition(八)

作者:互联网

一、前言

 简介

二、BeanDefinition

三、源码分析

我们先看看这个类:BeanDefinition

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;

	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();
	}


	boolean isSingleton();


	boolean isPrototype();


	boolean isAbstract();


	int getRole();


	@Nullable
	String getDescription();

	@Nullable
	String getResourceDescription();

	@Nullable
	BeanDefinition getOriginatingBeanDefinition();

}

定义了一个bean的各种属性:

我们用idea打开图属性看看:

 beanDefinition

我们在看看它的实现类:

 beanDefinition

此外还有一个封装类:BeanDefinitionHolder

public class BeanDefinitionHolder implements BeanMetadataElement {

	private final BeanDefinition beanDefinition;

	private final String beanName;

	@Nullable
	private final String[] aliases;

    ...

}

 丰极

欢迎关注微信公众号:丰极,更多技术学习分享。

标签:springboot,Nullable,void,管中窥豹,boolean,BeanDefinition,源码,String
来源: https://blog.csdn.net/mczb1989/article/details/113760576