In the final step of my job, it would be easier for me to call an existing DAO that would query and return a complex graph of object i need to persist with an ItemWriter as an XML. I use XStream with annotation.
Every example of ItemReaderAdapter i see implements the initializingBean to initialize the collection of objects i need to iterate thru (Basically,do the query on the DB).
This would work great if my data would be in the DB when the afterPropertiesSet() is invoked(at the start of the job!), but the data i have to read is persisted in the steps of the current job. How can i use ItemReaderAdapter in this case?
Summary:
step 1 : read an xml and write the objects in the DB (trxA)
step 2 : read a flatFile and write the object in the DB (trxB)
step 3 : business logic on trxA
step 4 : business logic on trxB
step 5 : (this is the one ;-)) call the DAO that will return an unifiedObject of trxA and trxB.
basically, i need to know : Is there a way i can tell my adapter to initialize at the start of the step instead of the start of the job?
Regards
Edit: to be clear, here is an example taken in a book
public class ProductServiceAdapter implements InitializingBean {
private ProductService productService;
private List<Product> products;
public void afterPropertiesSet() throws Exception {
this.products = productService.getProducts();
}
public Product nextProduct() {
if (products.size()>0) {
return products.remove(0);
} else {
return null;
}
}
The DAO access is done in the afterPropertieSet() so it does not work in my case.