Announcement Announcement Module
Collapse
No announcement yet.
How to pass custom objects from controller to steps? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to pass custom objects from controller to steps?

    Hi all,

    I am new to Spring batch.
    My scenario is I just want to pass some objects from controller to steps. For that I am using JobParameter.
    But the problem is there are no constructor available for passing Objects.
    The only construcors available are :

    JobParameter(Date parameter)
    JobParameter(String parameter)
    JobParameter(Long parameter)
    JobParameter(Double parameter)

    What if I have to pass complete object.
    Also is there any other way to pass arguments to steps except JobParameters.
    I somewhere read that JobParameters are used to validate uniqueness. But what if I need to check uniqueness against few parameters only and rest are passed to be used in subsequent steps.

    Thanks in advance.

  • #2
    1. We don't currently support the passing of complex objects as parameters. What is the source of the object you want to pass in?
    2. JobParameters can be used at any level. Once the job has begun, you can pass values from step to step via the Job's ExecutionContext.
    3. Previous versions of Spring Batch used all parameters to identify a JobInstance. However, as of the upcoming 2.2, this restriction will be removed and we will be supporting both identifying and non-identifying parameters. You should be able to take a look at that functionality in the current snapshot build.

    Comment


    • #3
      Thanks for the reply...

      Source of the object :
      There are some details which are being set while logging in to the application.
      Instead of passing them one by one I am having a custom object which I want to pass as JobParameter.

      Comment


      • #4
        Currently Spring Batch doesn't support complex objects as parameters. We will be updating that in the future to support JSR-352. In the mean time, I'd imagine you could use a factory bean approach to injecting the object into the artifacts that need it.

        Comment

        Working...
        X