Can we call an external method between before and around advices? (For the same pointcut)

依然范特西╮ 提交于 2019-12-23 02:57:26

问题


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);

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.
}

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.

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

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)


回答1:


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.



来源:https://stackoverflow.com/questions/22911734/can-we-call-an-external-method-between-before-and-around-advices-for-the-same

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!