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

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

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

@Pointcut("execution(*com.connection.sendRequest(..))&& cflow(execution(*com.soapService.sendSoapRequest(..)))")
public void interceptSendRequestOnSoapService() {
};

@Before("interceptSendRequestOnSoapService()") 
public void interceptSoapRequest(JoinPoint point){
...
};

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

@Around("interceptSendRequestOnSoapService()") 
public void interceptSoapRequest(JoinPoint point){
...
};

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

wpx232ag

wpx232ag1#

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

相关问题