1

I have the following method in my Dao layer

public void setApples(List<Apple> apples)

I want to intercept the apples collection every time the method is executed and push instances of Apple to a sink.

I am trying to do the same using Aspects now which annotation do I use to capture the concerned objects and what should be the pointcut expression? I was trying @AfterReturning but this is a void method how do I capture the arguments of this? I am a beginner in AOP so please excuse if this question is too trivial.

UPDATE

The solution: Get method arguments using spring aop?

Community
  • 1
  • 1
Abhiroop Sarkar
  • 2,251
  • 1
  • 26
  • 45
  • Please instead of mentioning the answer in your updated question, write your own answer and self-accept it in order to close the question. At the moment it is still shown as unanswered. – kriegaex Aug 01 '15 at 10:18
  • I tried that but the answer got marked as trivial and got commented so I figured if I mention the answer in the question people can find help – Abhiroop Sarkar Aug 01 '15 at 20:41

1 Answers1

0

you have two options, either create a spring aop proxy (1) bean or use aspectj (2).

  1. would be used in runtime and it would create a proxy "wrapper" that would intercept the calls to method. take a look at ProxyFactoryBean/BeanNameAutoProxyCreator (advice), NameMatchMethodPointcut (pointcut).
  2. using AspectJ create the same intercepter. take a look at < aop:pointcut> and < aop:aspect>

in both cases you need to intercept before method execution. so either use < aop:before> or MethodBeforeAdvice

hahn
  • 3,588
  • 20
  • 31