Configured AOPs not working in Spring Batch Samples
Hi All,
Am new to Spring Batch and even Spring AOP.
I am executing the FootBall Sample and its working as expected. But the AOPs that were configured for logging weren't working.
Code:
<!-- AOP Configurations -->
<bean id="logAdvice" class="org.springframework.batch.sample.common.LogAdvice" />
<bean id="eventAdvice" class="org.springframework.batch.sample.jmx.StepExecutionApplicationEventAdvice" />
<aop:config>
<aop:aspect id="moduleLogging" ref="logAdvice">
<aop:after
pointcut="execution( * org.springframework.batch.item.ItemWriter+.write(Object)) and args(item)"
method="doStronglyTypedLogging" />
</aop:aspect>
<aop:aspect ref="eventAdvice">
<aop:before
pointcut="execution( * org.springframework.batch..Step+.execute(..)) and args(stepExecution)"
method="before" />
<aop:after
pointcut="execution( * org.springframework.batch..Step+.execute(..)) and args(stepExecution)"
method="after" />
<aop:after-throwing throwing="t"
pointcut="execution( * org.springframework.batch..Step+.execute(..)) and args(stepExecution)"
method="onError" />
</aop:aspect>
</aop:config>
The above code is as provided in the samples. I modified LogAdvice class to use Log4j instead of Commons Logging.
When ran the tests, doStronglyTypedLogging in LogAdvice is never called.
For the other aop aspect, before and after methods for StepExecutionApplicationEventAdvice is invoked and able to log a message to console. But what happens after the below code is invoked ?
Code:
applicationEventPublisher.publishEvent(new SimpleMessageApplicationEvent(source, message));
When & How will the toString() method be called on SimpleMessageApplicationEvent ?
Am I missing any other configurations thats causing problem with aop logging.. Please advice.
Thanks,
Madan Narra