我们可以在 before 和 around 通知之间调用外部方法吗?(对于相同的切入点) [英] Can we call an external method between before and around advices? (For the same pointcut)

查看:12
本文介绍了我们可以在 before 和 around 通知之间调用外部方法吗?(对于相同的切入点)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个一般性的 AOP 问题,请在这种情况下澄清我,假设我们有一个捕获方法执行的执行切入点:在我们方面,我们有一个:

I have a general AOP question, please clarify me on this situation, let's assume we have an execution pointcut that catches a method execution : In our aspect we have a :

pointcut pointcut_CatchMethod(Activity activity) :  execution(String methodA(..))
     && target(activity);

这里,我们在目标活动中有一个 methodA().我们前后有 2 条建议.喜欢:

Here, we have a methodA() in target activity. and we have 2 advices before and around. Like :

    before(Activity activity) : pointcut_CatchMethod(activity){
//Do something...
}

    String around(Activity activity) : pointcut_CatchMethod(activity){
//Do something different.
}

所以我的问题是,我们是否可以在这些 before 和 around 建议之间调用像 aMethodIntheAspect() 这样的方法(这个方法在方面).我无法做到这一点,因为我认为之前和周围的建议以某种方式同时执行.

So my question is, could we call a method like aMethodIntheAspect() (this method is in the aspect) between these before and around advices. I'm not capable of doing it because I think before and around advices execute in the same time in some manner.

在 Resume 中,如何更改方面中全局变量的值.?(通过 aMethodIntheAspect() )

详细代码信息请参考此链接:BroadcastReceiver 没有在正确的时间收到广播的意图(接收方的 onReceive 迟到了)

For detailed code information please refer to this link: BroadcastReceiver doesn't receive the broadcasted intent in the right time(Receiver's onReceive is being late to be called)

推荐答案

找到解决方案,无法进行问题中提到的操作,所以我没有做这种过程,而是取消了对 的原始调用methodA() 使用围绕方面,然后在方面内部的方法中手动调用它.

Solution found, It's not possible to make operation like mentioned in the question, So instead of doing this kind of process, I cancel the original call to methodA() with around aspect, then calling it manually inside a method inside the Aspect.

这篇关于我们可以在 before 和 around 通知之间调用外部方法吗?(对于相同的切入点)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆