Results 1 to 5 of 5

Thread: Understanding step scope

  1. #1

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Quote 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

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5

    Default

    Ok Marten, that clears it up for me.

    Thanks again for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •