我们可以调用之前和周围建议之间的外部方法? (出于同样的切入点)我们可以、切入点、建议、方法

2023-09-06 08:39:28 作者:老来伴

我有一个大致的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信息,请参考以下链接: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.

 
精彩推荐
图片推荐