Announcement Announcement Module
No announcement yet.
Bean ID for the list of items produced by Spring Batch Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bean ID for the list of items produced by Spring Batch

    In Spring Batch, after a ItemReader or ItemProcessor returns it's item object, the framework puts that item into an ArrayList to be passed to the ItemWriter.
    I need to gain access to that ArrayList of items in an ItemProcessor. The core functionality I need is to access the Arraylist while the ItemReader/ItemProcessor is processing it's chunk.
    My thought was to use an ApplicationContextAware ItemProcessor, allowing me to make the call below:

    ArrayList<? extends Item> items = contect.getBean("items", ArrayList.class) But the bean is not named items.
    Do you know how I can gain access to that ArrayList, or the name of the Bean so I can force it in there?

  • #2
    The entire list isn't available in the ItemProcessor. The ItemProcessor contract is intended to work on a single item. If you need to do something with all the items within a given chunk, you'll need to do it in an ItemWriter (or an ItemWriteListener).