Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

SpringBatch-Passing an Object to Listener from the Processor

Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have the requirement where I need to construct a Map with all incoming entities into the processor. When the processing is done, I need to make the Map available to Listener where I need to look into each object in the map and remove the objects which are not required after further processing.

My question is: How to make the Map which is constructed in the processor be available to Listener. Is there any alternative approach(other than listener)? I am looking for a kind of delegator where I can hand over the map(which is constructed in the processor) to delegator so that I can do the final processing in the delegator e.g. updating to db or creating error report etc.

Thanks and any suggestions are welcome!
Ranch Hand
Posts: 608
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There a quite a few ways in which you could pass the map to the listener.

a) have the processor itself implement the listener (StepExecutionListener with @AfterJob)
Then do the end processing here or pass the map to a DelegateObject that will do the processing.

b) have the map created by spring (in the spring config)
Then you an create any listener and have this map passed to it

c) Save the map in the StepExecutionContext. Then it can be retrieved in the listener
Note: This is the correct way, in case you want your job to be re-startable from the point of failure.
There is no greater crime than stealing somebody's best friend. I miss you tiny ad:
We need your help - Coderanch server fundraiser
    Bookmark Topic Watch Topic
  • New Topic