aspectj;使用“before”而不是“around”注解时调用的方面

m1m5dgzv  于 2021-07-13  发布在  Java
关注(0)|答案(1)|浏览(472)

所以我需要截获一个方法,当它从一个特定的方法中被调用时。
我已经准备好了,正在工作:

  1. @Pointcut("execution(*com.connection.sendRequest(..))&& cflow(execution(*com.soapService.sendSoapRequest(..)))")
  2. public void interceptSendRequestOnSoapService() {
  3. };
  4. @Before("interceptSendRequestOnSoapService()")
  5. public void interceptSoapRequest(JoinPoint point){
  6. ...
  7. };

这个很好,我需要它来拦截。
但是,当我把涂鸦改成“around”的时候:

  1. @Around("interceptSendRequestOnSoapService()")
  2. public void interceptSoapRequest(JoinPoint point){
  3. ...
  4. };

它根本不叫。它甚至从未进入相位。它不会拦截。为什么,我怎样才能让它在@around上工作?

wpx232ag

wpx232ag1#

嗯,我好像已经弄明白了。
我把第一次执行改为“呼叫”。so调用(*com.connection.sendrequest(..)
我让我的方法返回一个对象。所以“return joinpoint.procedue()”

相关问题