【问题标题】:the difference between the Calling Object and the Target Object?调用对象和目标对象的区别?
【发布时间】:2020-08-15 00:01:00
【问题描述】:

我正在学习 Spring AOP,并且有一些关于这个概念的术语,例如 Advice、PointCut、JoinPoint .. 其中之一是 AOP 代理,我发现代理是 AOP 框架引入的中间对象,在调用对象和目标对象。所以我的问题是调用对象和目标对象有什么区别?

【问题讨论】:

    标签: spring-aop


    【解决方案1】:

    请浏览参考文档部分:Understanding AOP Proxies

    下图描述了代理的概念。

    考虑一个带有方法run() 的类TestService 和一个带有方法foo() 的类Pojo。还要考虑 Spring 框架为 Pojo 创建一个代理。

    @Component
    public class TestService{
    
      @Autowired  
      Pojo pojo;
    
      public void run(){
         pojo.foo()
      }
    
    }
    

    这里TestService 的实例是调用对象,Pojo 的实例是目标对象。

    【讨论】:

      猜你喜欢
      • 2010-12-17
      • 2011-10-07
      • 2012-04-16
      • 1970-01-01
      • 2010-10-28
      • 2023-03-03
      • 1970-01-01
      • 2016-01-11
      相关资源
      最近更新 更多