Mar 8th, 2009, 08:16 PM
Logging complete file name in BATCH_JOB_PARAMS table
I am passing file name as job parameter like file:/test/PO_TR_*.TXT . In database this is getting
logged as same.
But I want to log the complete file name like 'file:/test/PO_TR_020120091129' in BATCH_JOB_PARAMS table.
Can anybody tell me how this can be done?
Mar 8th, 2009, 11:08 PM
The only thing I can think of is to actually resolve the resource before launching. You could probably use a composite JobLauncher to do this. Either that or us a listener to write the value out somewhere else.
Mar 10th, 2009, 08:37 AM
Thanks for yor reply. I am still not sure how this can be done. Pardon me if this is a stupid question.
CompisiteJobLauncher may not work for my case. I use MultiResourceItemReader and I think its 'resources' property takes a directory or a pattern like PO_* for finding list of files.
So the other option is using a listener and write to another table. Can you tell me how the listener can access 'resource' property of a FlatFileItemReader? What listner should I use?
I appreciate your time and help!
Mar 10th, 2009, 11:00 AM
Since the MultiResourceItemReader has a delegate of type ResourceAwareItemReaderItemStream, normally you would pass your FlatFileItemReader in as the delegate. The MRIR finds a resource and passes it to the FFIR (via the setResource method) before starting to read.
To capture the filename, you should insert a layer in between that the resource must pass through to get to the FFIR. You should proxy the FFIR (implementing ResourceAwareItemReaderItemStream). Your proxy's setResource method will pass the given resource to it's delegate FFIR, but it should also store the filename in a list. You can also have an afterStep listener method on your proxy that logs out the list of filenames.
Mar 10th, 2009, 12:42 PM
That is very helpful. Thanks a lot!