I have the following configuration to intercept a method and apply advice after returning from method, But, the following configuration does not work. Could you suggest on what I am missing?
@Service("txnEventSubscriber")
EventSubscriberImpl
...
@Resource(name="txnEventSubscriber")
private EventSubscriberImpl subscriber;
@Bean
public Advice myAdvice() {
return new AfterReturningAdvice() {
@Override
public void afterReturning(Object returnValue, Method method, Object[] args, Object target)
{
System.out.println("inside advice");
}
};
}
@Bean
public ProxyFactoryBean myProxyFactoryBean() {
return new ProxyFactoryBean() {
private static final long serialVersionUID = 6296720408391985671L;
@PostConstruct
public void afterPropertiesSet() throws ClassNotFoundException {
setTarget(subscriber);
setInterceptorNames(new String[] {"myAdvice"});
}
};
}
I have the EventSubscriber which when invoked and when method is returned, I need to intercept the method call and do something... in this case, print "inside advice".
I am not seeing any exceptions, just method advice is not getting called.