【问题标题】:Can we call an external method between before and around advices? (For the same pointcut)我们可以在 before 和 around 通知之间调用外部方法吗? (对于相同的切入点)
【发布时间】:2014-04-15 20:23:54
【问题描述】:

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

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

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

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

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

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

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

详细的代码信息请参考此链接: BroadcastReceiver doesn't receive the broadcasted intent in the right time(Receiver's onReceive is being late to be called)

【问题讨论】:

  • 无意冒犯,但我阅读了您的几个问题,并希望建议您更多地考虑应用程序和方面设计。从头脑中的问题开始,并专注于寻找合适的解决方案,而不是专注于假设的技术解决方案并使其适合您的问题。其次,请尝试更好地解释您的意图,也许通过提供更明确的代码示例和更少的不清楚的解释。

标签: android broadcastreceiver aop aspectj


【解决方案1】:

找到解决方法,无法进行问题中提到的操作,所以我不做这种过程,而是取消原来对 methodA() 的调用,然后调用它在 Aspect 内的方法中手动操作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-14
    • 2013-03-14
    • 2020-01-05
    • 2014-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多