Package org.springframework.batch.core.scope

# Class JobScope

java.lang.Object
org.springframework.batch.core.scope.BatchScopeSupport
org.springframework.batch.core.scope.JobScope

All Implemented Interfaces:
  `org.springframework.beans.factory.config.BeanFactoryPostProcessor`, `org.springframework.beans.factory.config.Scope`, `org.springframework.core.Ordered`

public class JobScope extends BatchScopeSupport
Scope for job context. Objects in this scope use the Spring container as an object factory, so there is only one instance of such a bean per executing job. All objects in this scope are <aop:scoped-proxy/> (no need to decorate the bean definitions).
In addition, support is provided for late binding of references accessible from the `JobContext` using #{..} placeholders. Using this feature, bean properties can be pulled from the job or job execution context and the job parameters. E.g.

     <bean id="..." class="..." scope="job">
            <property name="name" value="#{jobParameters[input]}" />
     </bean>

     <bean id="..." class="..." scope="job">
            <property name="name" value="#{jobExecutionContext['input.stem']}.txt" />
     </bean>

The `JobContext` is referenced using standard bean property paths (as per `BeanWrapper`). The examples above all show the use of the Map accessors provided as a convenience for job attributes.

Since:
  3.0
Author:
  Dave Syer, Jimmy Praet (create JobScope based on `StepScope`), Michael Minella

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.springframework.batch.core.scope.BatchScopeSupport

  `BatchScopeSupport.Scopifier`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `ID_KEY`
  Context key for clients to use for conversation identifier.

  ### Fields inherited from interface org.springframework.core.Ordered

  `HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JobScope()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Object`
  `get(String name, org.springframework.beans.factory.ObjectFactory<?> objectFactory)`
  `String`
  `getConversationId()`
  `String`
  `getTargetNamePrefix()`
  `void`
  `registerDestructionCallback(String name, Runnable callback)`
  `Object`
  `remove(String name)`
  `Object`
  `resolveContextualObject(String key)`
  This will be used to resolve expressions in job-scoped beans.

  ### Methods inherited from class org.springframework.batch.core.scope.BatchScopeSupport

  `createScopedProxy, getName, getOrder, postProcessBeanFactory, setAutoProxy, setName, setOrder, setProxyTargetClass`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### ID_KEY

    public static final String ID_KEY
    Context key for clients to use for conversation identifier.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### JobScope

    public JobScope()

- ## Method Details

  - ### resolveContextualObject

    public Object resolveContextualObject(String key)
    This will be used to resolve expressions in job-scoped beans.

  - ### get

    public Object get(String name, org.springframework.beans.factory.ObjectFactory<?> objectFactory)
    See Also:
      - `Scope.get(String, ObjectFactory)`

  - ### getConversationId

    public String getConversationId()
    See Also:
      - `Scope.getConversationId()`

  - ### registerDestructionCallback

    public void registerDestructionCallback(String name, Runnable callback)
    See Also:
      - `Scope.registerDestructionCallback(String, Runnable)`

  - ### remove

    public Object remove(String name)
    See Also:
      - `Scope.remove(String)`

  - ### getTargetNamePrefix

    public String getTargetNamePrefix()
    Specified by:
      `getTargetNamePrefix` in class `BatchScopeSupport`