Passing arguments to Spring Aspect

848 views Asked by At

I have Aspect in Spring that performs methods execution as "save(Answer)" from repository. How to correctly pass the Answer object argument in the following case:

@Before("com.examination.repository.AnswerRepository.save(answer)........//here to be continued
private void save(Answer entity) throws Throwable
       { ...}
1

There are 1 answers

0
Nir Levy On

the annotation should be:

@Before("com.examination.repository.AnswerRepository.save() && args(answer)")

One thing though - from your code it looks like you're putting the annotation on the method you want the aspect to be called before - the annotation belongs to you aspect class, not the method you want it to be executed before