spring-projects / spring-batch

Spring Batch is a framework for writing batch applications using Java and Spring
http://projects.spring.io/spring-batch/
Apache License 2.0
2.71k stars 2.35k forks source link

Support static job metadata attributes [BATCH-2286] #1319

Open spring-projects-issues opened 10 years ago

spring-projects-issues commented 10 years ago

Erwin Vervaet opened BATCH-2286 and commented

Spring Web Flow allows you to annotate a flow definition with static metadata attributes (http://www.springframework.org/schema/webflow/spring-webflow-2.4.xsd). For instance:

<flow>
  <attribute name="foo" value="bar"/>
</flow>

A similar feature would also be useful for a Spring Batch job.

I ran into a use-case for this just yesterday. I have a JobExecutionListener that I want to apply to all batch jobs in my application. Consequently I created a parent job definition referencing the listener and had all my actual batch job definitions extend that. However, the configuration of the listener differs slightly for some of the batch jobs. Using a job metadata attribute I would have been able to annotate the job definition and the listener could have picked up the annotation. Since that is currently not possible I ended up adding a non-identifying job parameter that the listener can inspect.


No further details from BATCH-2286

spring-projects-issues commented 5 years ago

Mahmoud Ben Hassine commented

I created a parent job definition referencing the listener and had all my actual batch job definitions extend that. However, the configuration of the listener differs slightly for some of the batch jobs

Defining an abstract parent job definition is the way to go. However, why would we need a job meta data attribute instead of overriding the listener definition for jobs that slightly differ from the abstract one?