注册启用基于代理的注解驱动事务管理所需的Spring基础结构bean。
1. ProxyTransactionManagementConfiguration类分析
image.png
2. @Role注解
定义如下:
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Role {
int value();
}
指示给定bean的“角色”提示。
可以直接或间接地在任何带有@Component 注解或使用@Bean注解标记的方法。
如果组件或Bean定义中不存在此注解,则会设置为默认的 BeanDefinition.ROLE_APPLICATION。
如果@Configuration类上存在Role,则表示配置类bean定义的角色,而不是级联到其中定义的所有@bean方法。例如,这种行为不同于@Lazy注解。
在BeanDefinition接口有@Role取值的定义,分别是
BeanDefinition.ROLE_APPLICATION, BeanDefinition.ROLE_INFRASTRUCTURE, BeanDefinition.ROLE_SUPPORT
2.1 BeanDefinition.ROLE_APPLICATION
角色提示,指示BeanDefinition是应用程序的主要部分。通常对应于用户定义的bean。
2.2 BeanDefinition.ROLE_INFRASTRUCTURE
角色提示,表示BeanDefinition提供的是完全后台角色,与最终用户无关。当注册完全属于组织内部工作的bean时,使用此提示。org.springframework.beans.factory.parsing.ComponentDefinition。
2.3 BeanDefinition.ROLE_SUPPORT
Role hint indicating that a BeanDefinition is a supporting part of some larger configuration, typically an outer org.springframework.beans.factory.parsing.ComponentDefinition. SUPPORT beans are considered important enough to be aware of when looking more closely at a particular org.springframework.beans.factory.parsing.ComponentDefinition, but not when looking at the overall configuration of an application.













网友评论