Announcement Announcement Module
No announcement yet.
Extending Jobs Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extending Jobs


    I am wondering if it is advisable to extend Job. I'd like to use spring batch for a number of jobs. However, I need a way to determine which job gets executed at runtime based on the value of a given domain object's attributes.

    I was hoping to add a "supports" method to each Job instance to determine if the domain object meets a job's criteria by rolling over each job in the job registry. If the job does meet criteria, launch the job, else visit the next configured job and perform the same check.

    I am struggling with the notion of having criteria checking wired into the job itself. In some respect, it seems like the proper place. However, it feels like something that should live at a higher level.

    I'd be open to any suggestions.



  • #2
    To me this looks like a registry concern, not a Job concern, so I wouldn't be extending Job (or even composing, which is usually preferable). The inevitable outcome would be a load of "instanceof" checks in all the clients of the new object. Isn't it better to just create a map from Entity name to Job, and consult that in your JobLauncher client?