aopaspectjexecutionpointcuts

AspectJ : Issue when combining multiple pointcuts in @Around advice


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
    }

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.

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

Hoping for the answers...


Solution

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