Announcement Announcement Module
Collapse
No announcement yet.
JobParametersValidator validate after the job was launched Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JobParametersValidator validate after the job was launched

    Hi,

    It seems that the JobParametersValidator it is possible to specify for each job is executed only into the execute method of AbstractJob. This has for consequence that it not possible to be informed if the validation fail, except by looking at the status of the job. Plus, as far as I've seen, it is not possible to get a reference to that JobParametersValidator instance.

    I can understand why the job validate itself when it is launched, but the bad point is that, in most use cases I can imagine, I want to validate those parameters before the job is launched.

    For example, if we have a generic web interface to launch any type of jobs and specify parameters. If we put wrong parameters for a job we would like to get an error message right now, not think that the job launched correctly and see later in the logs that it failed just because the parameters were wrong.

    Another example, but here we want to validate the parameters without launching the job at all: we use a quartz scheduler and we have a web interface that allow us to specify scheduling and parameters for a job, it would be cool to have the parameters validated when we schedule a job and not when it is effectively launched.

    To make those examples possible using the JobParametersValidator mechanism already implemented, don't you think it would be a good idea to put the JobParametersValidator instance already in AbstractJob accessible from the Job interface?

  • #2
    Agreed, but we didn't want to do that in a point release. In Batch 3.0 the Job interface might change, but not in 2.1.

    You can always inject the same validator into a Job and into another component that is used before the launch.

    Comment


    • #3
      Originally posted by Dave Syer View Post
      Agreed, but we didn't want to do that in a point release. In Batch 3.0 the Job interface might change, but not in 2.1.

      You can always inject the same validator into a Job and into another component that is used before the launch.
      Fair enough.

      Let me give you a bit of background. We are implementing a thin layer on top of the Job launcher that adds added value to the default behavior of a batch launch. Ideally, we want to reuse what batch developers (not us!) have configured on their job.

      In this particular case, we would like to simply reuse the validator that has been defined on the job without requiring our "users" to define it twice. We're good with some kind of home-made repository that would scan the jobs and retrieve the validators but right now, casting is the only solution. It's not a big deal but a cleaner solution is always better

      Thanks!

      Comment


      • #4
        Raise a JIRA so we don't forget to do it more cleanly in 3.0.

        Comment


        • #5
          okay so can you make sure we can retrieve the JobParamatersValidator in some form? AbstractJob has no public getter for it.

          Comment


          • #6
            We can do that in 2.1 (please raise a separate JIRA).

            Comment


            • #7
              The two tickets were created:

              http://jira.springframework.org/browse/BATCH-1483
              http://jira.springframework.org/browse/BATCH-1484

              Comment

              Working...
              X