AspectJ:在@Around 建议中组合多个切入点时出现问题 [英] AspectJ : Issue when combining multiple pointcuts in @Around advice

查看:43
本文介绍了AspectJ:在@Around 建议中组合多个切入点时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 AspectJ 的初学者,所以请指导我按照以下方法解决发生的问题.

I'm a beginner in AspectJ so please guide me to resolve the issue happening as per the below approach.

    @Aspect
    public class TestAop {

    @Pointcut("execution(public * com.packg.foo.ClassOne.*(..))")
    public void fooPoint()

    @Pointcut("execution(public * com.packg.cat.ClassTwo.*(..))")
    public void catPoint()

    @Pointcut("execution(public * com.packg.roo.ClassThree.*(..))")
    public void rooPoint()

    @Around("fooPoint() || catPoint() || rooPoint()") 
    public Object myAdvice(ProceedingJoinPoint joinPoint) {
    //do something like joint proceed and all
    }

什么时候不工作?如果我将所有三个切入点与 OR 结合起来.

When it is not working ? If I combine all the three pointcuts with OR .

什么时候开始工作?如果我只保留两个切入点,它就可以工作.

When it is working ? If i keep only two pointcuts it is working.

我是否违反了@around 建议的任何规则.是否可以有多个执行/切入点?

Am I vioalating any rules of @around advice. Is it possible to have multiple execution/pointcuts?

希望得到答案...

推荐答案

我有同样的问题,但更好的解决方案 IMO 是(对我有用):

I had same problem but better solution IMO is(works for me):

@Aspect
public class TestAop {

@Pointcut("execution(public * com.packg.foo.ClassOne.*(..)) || execution(public * com.packg.cat.ClassTwo.*(..)) || execution(public * com.packg.roo.ClassThree.*(..))")
public void fooPoint(){}

@Around("fooPoint()")
public Object myAdvice(ProceedingJoinPoint joinPoint) {
//do something like joint proceed and all
}

这篇关于AspectJ:在@Around 建议中组合多个切入点时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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