在 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 的区别的更多相关文章

  1. [刘阳Java]_Spring常用注解介绍_第6讲

    Spring的注解是在Spring2.5的版本中引入的,目的简化XML配置.在企业开发过程中使用注解的频率非常高,但是学习注解的前提是大家一定要对Spring基于XML配置要熟悉,这是我个人建议,因为 ...

  2. SpringMVC常用注解@Controller,@Service,@repository,@Component

    SpringMVC常用注解@Controller,@Service,@repository,@Component controller层使用@controller注解 @Controller 用于标记 ...

  3. Spring 和 SpringMVC 常用注解和配置(@Autowired、@Resource、@Component、@Repository、@Service、@Controller的区别)

    Spring 常用注解 总结内容 一.Spring部分 1.声明bean的注解 2.注入bean的注解 3.java配置类相关注解 4.切面(AOP)相关注解 5.事务注解 6.@Bean的属性支持 ...

  4. Spring系列之Spring常用注解总结

    传统的Spring做法是使用.xml文件来对bean进行注入或者是配置aop.事物,这么做有两个缺点:1.如果所有的内容都配置在.xml文件中,那么.xml文件将会十分庞大:如果按需求分开.xml文件 ...

  5. Spring常用注解汇总

    本文汇总了Spring的常用注解,以方便大家查询和使用,具体如下: 使用注解之前要开启自动扫描功能 其中base-package为需要扫描的包(含子包). <context:component- ...

  6. Spring常用注解,自动扫描装配Bean

    1 引入context命名空间(在Spring的配置文件中),配置文件如下: xmlns:context="http://www.springframework.org/schema/con ...

  7. Spring常用注解介绍【经典总结】

    Spring的一个核心功能是IOC,就是将Bean初始化加载到容器中,Bean是如何加载到容器的,可以使用Spring注解方式或者Spring XML配置方式. Spring注解方式减少了配置文件内容 ...

  8. 一 : springmvc常用注解

    springmvc常用注解详解1.@Controller在SpringMVC 中,控制器Controller 负责处理由DispatcherServlet 分发的请求,它把用户请求的数据经过业务处理层 ...

  9. Spring Boot常用注解总结

    Spring Boot常用注解总结 @RestController和@RequestMapping注解 @RestController注解,它继承自@Controller注解.4.0之前的版本,Spr ...

  10. SpringBoot | 第六章:常用注解介绍及简单使用

    前言 之前几个章节,大部分都是算介绍springboot的一些外围配置,比如日志配置等.这章节开始,开始总结一些关于springboot的综合开发的知识点.由于SpringBoot本身是基于Sprin ...

随机推荐

  1. element的el-table使用模板插槽在火狐和IE无法显示tooltip(浏览器兼容)

    el-table中使用show-overflow-tooltip属性,配合tooltip出现的浏览器兼容性问题 el-table中使用show-overflow-tooltip属性内容过长被隐藏时显示 ...

  2. http请求的方法

    1.OPTIONS 返回服务器针对特定资源所支持的HTTP请求方法,也可以利用向web服务器发送'*'的请求来测试服务器的功能性. 2.HEAD 向服务器索要与GET请求相一致的相应,只不过响应体将不 ...

  3. RabbitMQ博文收藏

    RabbitMQ基本概念 消息队列之 RabbitMQ

  4. Centos 配置网络自启和静态IP和主机名

    1. 修改配置文件 vim /etc/sysconfig/network-scripts 2. vim /etc/sysconfig/network-scripts/ifcfg-eth0 BOOTPR ...

  5. java map重写 转大写、转驼峰

    /** * @author admin * @Description * 转大写 */ public class HashMapUpper<V> extends HashMap<St ...

  6. MySQL代替in之临时表

    如果我们正常的使用IN去查询 SELECT * FROM a JOIN b ON a.id = b.id WHERE b.tag_id IN (1,2,3,4,5,6) 这种因为in里面的参数是连续的 ...

  7. P2345 [USACO04OPEN] MooFest G

    简单的一个分块处理:优雅的暴力枚举 #include<bits/stdc++.h>using namespace std; typedef long long ll;const int N ...

  8. python去除前中后多处空格的方法

    x=" asdf ada都 是 年 费 sdf sf " print("".join(x.split())) 测试全角半角空格都没有了

  9. 关于Windows10纯净启动的相关修改流程

    关于纯净启动的相关流程 自动登录 打开命令提示符运行control userpasswords2后回车 在弹出的用户账户窗口中,取消勾选"要使用本计算机,用户必须输入用户名和密码" ...

  10. 不同目录下npm run 报错

    不同目录下npm 报错sh: webpack: command not found npm ERR! file sh npm ERR! code ELIFECYCLE npm ERR! errno E ...