Difference between call and execution in AOP

只愿长相守 提交于 2019-12-01 22:13:00
Hakan

If we look at the HelloWorldSayer class again, there are 4 join point shadows (2 execution pointcuts and 2 call pointcuts).

In other words, public static void main (String[] args) and public static void sayHello() refer to the execution pointcut. (HelloWorldSayer.)sayHello(); and System.out.println("Hello"); refer to the call pointcut.

If you change the declared pointcut as follows, the pointcut selects sayHello();

public pointcut hello():
    call(static void HelloWorldSayer.sayHello());

On the other hand, you change the declared pointcut as follows, the pointcut selects the sayHello method declaration public static void sayHello().

public pointcut hello():
    execution(static void HelloWorldSayer.sayHello());

At last, please read this answer to get better understanding about call() and execution(): https://stackoverflow.com/a/18149106/904745

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!