What are the Spring Batch “default” Context Variables?

后端 未结 3 929
轮回少年
轮回少年 2021-01-05 04:41

In the Spring Batch step-scope documentation, there are three unexplained spring-batch context maps: jobParameters, jobExecutionContext, and

相关标签:
3条回答
  • 2021-01-05 04:43

    There aren't any default values. Think of jobParameters, jobExecutionContext, and stepExecutionContext as glorified Maps with helper methods for different primitive data types, e.g. getInt(). They're typically accessed from the StepExecution and JobExecution objects passed to *ExecutionListeners, or injecting using value injection, e.g. @Value("#{jobParameters['foo']}").

    In this case, input.file.name is just a name chosen by the developer, e.g. maybe corresponding to a command line job parameter specified to the CommandLineJobRunner.

    0 讨论(0)
  • 2021-01-05 05:06

    #{jobParameters}, #{jobExecutionContext} and #{stepExecutionContext} are the spEL (Spring Expression Language) counterpart of JobParameters, JobExecution and StepExecution objects available in late-binding to allow non-static access to this objects values from step scoped object.

    They support access as Maps so you can access the ExecutionContext associated to JobExecution and StepExecution and values stored in JobParameters.

    Also check StepScope documentation for more information.

    0 讨论(0)
  • 2021-01-05 05:09

    See the documentation

    JobParameters are parameters passed in when starting the job

    The execution contexts are for your use to store whatever you want. Typically, the step execution context will contain information to allow the step to restart (for restartable jobs).

    Elements in the step execution context can be promoted to the job execution context if you want to communicate information between steps.

    0 讨论(0)
提交回复
热议问题