London
London

Reputation: 15274

Spring aop more than one method

How do I intercept two methods instead of one? Here is what I've got working so far :

@Before("execution(* models.service.*.get(..)) && !execution(* models.service.Delegate.get(..))")
    public void beforeSave(JoinPoint joinPoint) {

So I'm intercepting all get methods from service package except get method from Delegate class.

Since now I have more classes that I don't want to intercept, it would be easier if I could list the class gets which I want to intercept. I tried :

@Before("execution(* models.service.ClsOne.get(..)) && execution(* models.service.ClsTwo.get(..))")

This doesn't work, what would be the correct way of doing this?

Upvotes: 0

Views: 325

Answers (1)

Sergey Makarov
Sergey Makarov

Reputation: 2531

You should use OR(||) instead of AND (&&) in your second @Before clause - in this case it should work as expected.

Upvotes: 1

Related Questions