Hi everybody,
passing data through steps is OK.
To avoid writing too many data in the execution context, I decided to use an holder bean.
The holder bean
Config snippetsCode:public class AuthorListHolder { private List<Author> authorList; public List<Author> getAuthorList() { return authorList; } public void setAuthorList(List<Author> authorList) { this.authorList = authorList; } }
The write method of the writerCode:<bean id="authorListHolder" class="..."/> <bean id="savingAuthorListItemWriter" class="..."> <property name="authorListHolder" ref="authorListHolder"/> </bean> <bean id="retrievingAuthorItemReader" class="..."> <property name="authorListHolder" ref="authorListHolder"/> </bean>
The read method of the readerCode:@Override public void write(List<? extends List<Author>> items)throws Exception { for(List<Author> authorList : items) { // my SavingAuthorListItemWriter.setAuthorListHolder contains: this.authorListHolder.setAuthorList(new ArrayList<Author>()); authorListHolder.getGroupList().addAll(authorList); } }
I think the holder bean solution is ok, because it allowed me to restore DB job repository and to have a cleaner code.Code:@Override public Author read() throws Exception, UnexpectedInputException, ParseException, NonTransientResourceException { if(!authorListHolder.getAuthorList().isEmpty()) { return authorListHolder.getAuthorList().remove(0); } return null; }
Thank you for your patience!![]()


Reply With Quote
