We are looking at providing some local, common services to applications running in Spring Batch.
We will provide and own the 'Runner' used to run the Jobs and so will prepare an Application Context etc proir to running the job.
Obvioulsy, we want to minmise the impact of our implementation on the application. The less configuration that they have to do to enable our services the better. We will be using Spring AOP to 'get in, under the covers' at approriate points to perform/provide required activities/services. The other area which is of use to us, in terms of 'getting in under the covers', is through Listeners. But, ideally, we do not want every Step and Job to configure in our set of Listeners (we are aware of 'parents' and 'inheritting', but we would like to not even have to suggest that approach). We would like to attach the Listeners programmatically, and believe it should be possible. Using the Application Context, we can attached our common Listeners to JobExecution, Step and Chunk (using getJob and registerStepExecutionListener (onAbstractJob) and StepListenerFactoryBean for instance), e.g.
But we are struggling to do similar things with ItemRead/ItemWrite/ItemProcess/SkipListeners.We can create the required Listener, for exmaple:
((AbstractStep) step).registerStepExecutionListener((StepExecutionListener)(StepListenerFactoryBean.getListener(new MyStepExecListener())));
... but can not see what to do with it!!!
Does anyone have any suggestions, ideas or thoughts that might help out with attaching these type of Listeners.