tags:

views:

104

answers:

0

I would like to setup a base step has a logger listener attached for making sure that all the error logs end up in the correct file.

The setup below i simple enough and rather similar to the example presented on http://static.springsource.org/spring-batch/reference/html/configureStep.html#mergingListsOnStep but according http://www.springframework.org/schema/batch/spring-batch.xsd, it seems that listeners don't belong under step but rather under tasklet.

<step id="baseLoggedStep">
    <listeners>
        <listener>
            <bean class="org.example...StepLogListener"/>
        </listener>
    </listeners>
</step>

<step id="myJobStep" parent="baseLoggedStep">
... 
</step>

So, who is correct and how do I use the correct xsd to produce the desired result?

The following base step seems to do the trick, where StepLogListener listener implements StepExecutionListener.

<batch:step id="baseLoggedStep" abstract="true">
    <batch:tasklet>
        <batch:listeners>
            <batch:listener ref="stepLogListener">
                <bean class="com.bossmedia.gem.platform.batch.StepLogListener"/>
            </batch:listener>
        </batch:listeners>
    </batch:tasklet>
</batch:step>

However it doesn't seem optimal and frankly not entirely correct. This would mean that baseLoggedStep is an abstract instance of TaskletStep right?