我们可以调用之前和周围建议之间的外部方法? (出于同样的切入点) [英] Can we call an external method between before and around advices? (For the same pointcut)

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

问题描述

我有一个大致的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.
}

所以我的问题是,我们可以像调用一个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.

在恢复,我怎样才能改变一个全局变量的方面的价值? (由aMethodIntheAspect())

In Resume, How can I change the value of a global variable in the aspect.? (by aMethodIntheAspect() )

有关详细code信息,请参考以下链接:
<一href=\"http://stackoverflow.com/questions/22862310/broadcastreceiver-doesnt-receive-the-broadcasted-intent-in-the-right-time\">BroadcastReceiver不接收广播的意图在正确的时间

For detailed code information please refer to this link: BroadcastReceiver doesn't receive the broadcasted intent in the right time

推荐答案

解决方案发现,这是不可能做出那样的问题中提到的操作,所以与其做这种过程中,我取消了原有的呼叫为了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.

这篇关于我们可以调用之前和周围建议之间的外部方法? (出于同样的切入点)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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