Solon2 常用注解之 @Component 与 @ProxyComponent 的区别
在 Solon 提倡“克制”的原则下,托管组件分为:
- 普通组件:
- 主要由内核提供的:@Configuration、@Component、@Controller、@Remoting 注解的类
- 其中 @Controller、@Remoting 支持函数拦截
- 代理组件:
- 主要由内核提供的:@ProxyComponent(需要 solon.proxy 插件提供支持)注解的类
- 支持函数可拦截
1、区别
@ProxyComponent
- 被代理(即类的外面又包了一层类,看不见的),支持函数可拦截。例如支持:@Tran、@Cache 等借助函数拦截实现的能力
支持函数可拦截:
@ProxyComponent
public class UserService{
@Tran
public void addUser(User user){
}
}
@Component
- 不支持函数可拦截
- 支持特定形态自动处理
- 支持函数提取
- 支持 Bean、BeanWrap 订阅
支持特定形态自动处理:LifecycleBean、EventListener、Filter、RouterInterceptor、Handler、LoadBalance.Factory。例:EventListener 会自动注册 EventBus
@Component
public class DemoEventListener implements EventListener<DemoEvent>{
@Override
public void onEvent(DemoEvent event) throws Throwable{
}
}
支持函数被提取:通过 aopContext.beanExtractorAdd(Scheduled.class, new ScheduledExtractor()) 直接提取组件的 @Scheduled 函数
@Component
public class DemoJob{
@Scheduled
public void job1() throws Throwable{
}
}
支持Bean、BeanWrap 订阅:(订阅,也支持 @Configuration + @Bean 产生的)
//通过订阅获取多个 IXxx 实现的组件或Bean(要在容器扫描前,提前订阅)
aopContext.subBeansOfType(IXxx.class, bean->{
});
@Component
public class DemoBean1 implements IXxx{
}
@Component
public class DemoBean2 implements IXxx{
}
2、了解代理与拦截
Solon2 常用注解之 @Component 与 @ProxyComponent 的区别的更多相关文章
- [刘阳Java]_Spring常用注解介绍_第6讲
Spring的注解是在Spring2.5的版本中引入的,目的简化XML配置.在企业开发过程中使用注解的频率非常高,但是学习注解的前提是大家一定要对Spring基于XML配置要熟悉,这是我个人建议,因为 ...
- SpringMVC常用注解@Controller,@Service,@repository,@Component
SpringMVC常用注解@Controller,@Service,@repository,@Component controller层使用@controller注解 @Controller 用于标记 ...
- Spring 和 SpringMVC 常用注解和配置(@Autowired、@Resource、@Component、@Repository、@Service、@Controller的区别)
Spring 常用注解 总结内容 一.Spring部分 1.声明bean的注解 2.注入bean的注解 3.java配置类相关注解 4.切面(AOP)相关注解 5.事务注解 6.@Bean的属性支持 ...
- Spring系列之Spring常用注解总结
传统的Spring做法是使用.xml文件来对bean进行注入或者是配置aop.事物,这么做有两个缺点:1.如果所有的内容都配置在.xml文件中,那么.xml文件将会十分庞大:如果按需求分开.xml文件 ...
- Spring常用注解汇总
本文汇总了Spring的常用注解,以方便大家查询和使用,具体如下: 使用注解之前要开启自动扫描功能 其中base-package为需要扫描的包(含子包). <context:component- ...
- Spring常用注解,自动扫描装配Bean
1 引入context命名空间(在Spring的配置文件中),配置文件如下: xmlns:context="http://www.springframework.org/schema/con ...
- Spring常用注解介绍【经典总结】
Spring的一个核心功能是IOC,就是将Bean初始化加载到容器中,Bean是如何加载到容器的,可以使用Spring注解方式或者Spring XML配置方式. Spring注解方式减少了配置文件内容 ...
- 一 : springmvc常用注解
springmvc常用注解详解1.@Controller在SpringMVC 中,控制器Controller 负责处理由DispatcherServlet 分发的请求,它把用户请求的数据经过业务处理层 ...
- Spring Boot常用注解总结
Spring Boot常用注解总结 @RestController和@RequestMapping注解 @RestController注解,它继承自@Controller注解.4.0之前的版本,Spr ...
- SpringBoot | 第六章:常用注解介绍及简单使用
前言 之前几个章节,大部分都是算介绍springboot的一些外围配置,比如日志配置等.这章节开始,开始总结一些关于springboot的综合开发的知识点.由于SpringBoot本身是基于Sprin ...
随机推荐
- Mac Idea2018.1.6版 利用脚本激活安装详解
下载安装包:链接: https://pan.baidu.com/s/1W4alLXUeQ6xazkNEtB8I9w 提取码: w6rg 下载脚本:链接: https://pan.baidu.com/s ...
- 图模导入原理之 SVG图形基础与图形导入
一.svg图形基础 PMS图形中,图形svg文件内容一般由两部分组成: 1.<defs>标签中定义的是图元信息,即各种不同设备不同状态的图元应该如何显示: 2.各种<XXXXXX_L ...
- Flutter安装SDK及配置
一.下载SDK 1.官网下载 https://docs.flutter.dev/development/tools/sdk/releases?tab=macos 2.git下载 git clone h ...
- java文本转语音
下载jar包https://github.com/freemansoft/jacob-project/releases 解压,将jacob-1.18-xxx.dll相应放到项目使用的JAVA_HOME ...
- mergehex tools安装
(1)nRF5x command line tools包括Jlink驱动以及Nordic自己开发的一些命令行工具,具体包括Jlink驱动,nrfjprog,nrfutil以及mergehex等. 下载 ...
- 输入一段字符(只含有空格和字母,保证开头不为空格),里面有若干个字符串,求这些字符串的长度和,并输出最长字符串内容,如果有多个输出最先出现的那个字符串。以stop作为最后输入的字符串。
#include<stdio.h>#include<string.h>main(){ int i,j=0,m,count,max; char a[100]; ...
- The difference of src and href
href是Hypertext Reference的缩写,表示超文本引用.用来建立当前元素和文档之间的链接.常用的有:link.a.例如: <link href="reset.css&q ...
- 几种C#实现播放声音的方法 DirectX、SoundPlayer等
第一种是利用DirectX 1.安装了DirectX SDK(有9个DLL文件).这里我们只用到MicroSoft.DirectX.dll 和 Microsoft.Directx.DirectSou ...
- linux 修改文件内容命令
1.进入文件:vim 文件名 eg #vim /etc/httpd/httpd.conf 2.查找待修改内容位置 : (1)shift+":",使文件变成可查询状态 (2)输入 / ...
- CentOS7更改阿里源
阿里云yum源:1)备份当前yum源防止出现意外还可以还原回来cd /etc/yum.repos.d/cp /CentOS-Base.repo /CentOS-Base-repo.bak2)使用wge ...