Announcement Announcement Module
Collapse
No announcement yet.
Understanding step scope Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Understanding step scope

    Hi,

    I am having trouble understanding step scope, for example in the documenation they have the following..

    Code:
    <bean id="step1" parent="simpleStep">
      <property name="itemReader">
        <bean class="org.springframework.batch.item.file.FlatFileItemReader" scope="step">
            <property value="#{jobParameters[inputFile]}" />
            ...
        </bean>
      </property>
      ...
    </bean>
    Now what does this mean in terms of how the Spring container manages this bean. Is it still a Singleton like all Sprinng beans are or is it created and destroyed only for the step of the job in which it is used?

    Thanks,
    Jahan

  • #2
    I suggest a read of the Spring reference guide which explains how scopes work.

    Is it still a Singleton like all Sprinng beans are or is it created and destroyed only for the step of the job in which it is used?
    Singleton is another scope so step isn't a singleton there is an instance per step.

    Comment


    • #3
      Originally posted by Marten Deinum View Post
      I suggest a read of the Spring reference guide which explains how scopes work.


      Singleton is another scope so step isn't a singleton there is an instance per step.
      Hi Martin,

      I looked in section 4.5 of the reference guide on "Bean Scopes" and I did not see anything specifically about the Step scope (it was mostly speaking about web). So can you please clarify, I think what you said above is that a separate instance of the bean is created for each step, is this right? That seems to me a costly exercise, do you know what are the benefits of doing this?

      Thanks,
      Jehan

      Comment


      • #4
        It isn't specifically about step scope it is about scopes in general and gives and idea how it works, step isn't different from that (it basically is the same as request but instead of being bound to the lifecycle of the request is is bound to the lifecycle of the step).\

        For the benefits I suggest the Spring Batch Reference Guide, one of the things is that you can use expressions to do late binding.

        Comment


        • #5
          Ok Marten, that clears it up for me.

          Thanks again for your help.

          Comment

          Working...
          X