Results 1 to 6 of 6

Thread: How to pass resource pattern to MultiResourceItemReader

  1. #1
    Join Date
    Apr 2008
    Posts
    29

    Default 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?

  2. #2
    Join Date
    Jun 2005
    Posts
    4,231

    Default

    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).

  3. #3
    Join Date
    Apr 2008
    Posts
    29

    Default

    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.

  4. #4
    Join Date
    Jun 2005
    Posts
    4,231

    Default

    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.

  5. #5
    Join Date
    Apr 2008
    Posts
    29

    Default

    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.

  6. #6
    Join Date
    Apr 2008
    Posts
    29

    Default

    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
  •