-
Jul 11th, 2008, 10:23 AM
#1
How to pass resource pattern to MultiResourceItemReader
The example use case of MultiResourceItemReader has the resources pattern "hard-coded" in the job application context configuration (see multiResourceJob.xml). Is there an example on how to pass the pattern as a job parameter? Is there anything similar to StepExecutionResourceProxy for single input or output file readers or writers?
-
Jul 11th, 2008, 11:52 AM
#2
The only way to do this in 1.x is to use properties files or System properties (for a command line launcher that works out fine). The problem is that the JobParameters are not available when the Job is created. Might change in 2.0 (probably will, see http://jira.springframework.org/browse/BATCH-282).
-
Jul 11th, 2008, 05:00 PM
#3
I understand. But why is this a problem at Job creation time? Shouldn't the resources be attempted to be loaded at Step execution time? In my use case, it's ok to have an empty list of resources. In this case, the job just has to exit gracefully as a successful job run.
-
Jul 12th, 2008, 01:07 AM
#4
OK, I get the point about job creation vs. step execution. So that's what the various proxy-style listeners do (like StepExecutionResourceProxy) - defer lookup of a resource until the step executes. But the JobParameters are actually known at the time the job is launched, which in turn is in most cases when the job is created, so a generic mechanism would be able to work at that point. That isn't available in 1.x.
Let me re-phrase the answer. In 1.x (and maybe even 2.x) the only way to do a lookup through the JobParameters at step execution time is through a StepExecutionListener. There are some that work off the shelf (as you have noticed). Others you will have to write yourself, or raise a JIRA issue and see if it can be done in the framework.
-
Jul 14th, 2008, 08:00 AM
#5
Thanks Dave. I'll try to write one myself and see how far I will go. I will also go ahead and raise a Jira issue.
-
Jul 14th, 2008, 09:59 AM
#6
I have opened JIRA issue #BATCH-726.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules