1

I have a situation where there is a generic pointcut and several other specific pointcuts. All I want is generic should execute first and then only specific ones should.

Generic point cut is say,

  @Before("execution(public * com.java.*.data(..))") 

Specific point cut number 1

  @Before("execution(public * com.java.science.*.data(..))") 

Specific point cut number 2

  @Before("execution(public * com.java.history.*.data(..))") 

Specific point cut number 3

  @Before("execution(public * com.java.geography.*.data(..))")

Genric point cut should execute first and then the specific ones. Can I have control on that?

Anders R. Bystrup
  • 15,729
  • 10
  • 59
  • 55
NitZRobotKoder
  • 1,046
  • 8
  • 44
  • 74

1 Answers1

1

You can set the priority using an @Order( value = ... ) on the @Aspect-annotated class:

@Aspect
@Order( value=0 )
public class MyFirstPointcut
{
    @Before("execution(public * com.java.*.data(..))")
    public void something(...) { ... }
}

@Aspect
@Order( value=1 )
public class MySecondPointcut
{
    @Before("execution(public * com.java.science.*.data(..))") 
    public void somethingElse(...) { ... }
}

...etc
Anders R. Bystrup
  • 15,729
  • 10
  • 59
  • 55