org.springframework.batch.core.jsr

## Class JsrJobContextFactoryBean

- java.lang.Object
- - org.springframework.batch.core.jsr.JsrJobContextFactoryBean

- All Implemented Interfaces:
    org.springframework.beans.factory.FactoryBean<javax.batch.runtime.context.JobContext>

      public class JsrJobContextFactoryBean
      extends java.lang.Object
      implements org.springframework.beans.factory.FactoryBean<javax.batch.runtime.context.JobContext>

  Provides a single `JobContext` for each thread in a running job. Subsequent calls to `FactoryBean.getObject()` on the same thread will return the same instance. The `JobContext` wraps a `JobExecution` which is obtained in one of two ways:
  - The current step scope (getting it from the current `StepExecution`
  - The provided `JobExecution` via the `setJobExecution(JobExecution)`
  Since:
    3.0
  Author:
    Michael Minella

- - ### Field Summary

    - ### Fields inherited from interface org.springframework.beans.factory.FactoryBean

      `OBJECT_TYPE_ATTRIBUTE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JsrJobContextFactoryBean()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Used to remove the `JobContext` for the current thread.
    `javax.batch.runtime.context.JobContext` | `getObject()`
    `java.lang.Class<?>` | `getObjectType()`
    `boolean` | `isSingleton()`
    `void` | `setBatchPropertyContext(BatchPropertyContext propertyContext)`
    `void` | `setJobExecution(JobExecution jobExecution)` Used to provide `JobContext` instances to batch artifacts that are not within the scope of a given step.

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

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

- - ### Constructor Detail

    - #### JsrJobContextFactoryBean

          public JsrJobContextFactoryBean()

  - ### Method Detail

    - #### getObject

          public javax.batch.runtime.context.JobContext getObject()
                                                           throws java.lang.Exception

      Specified by:
        `getObject` in interface `org.springframework.beans.factory.FactoryBean<javax.batch.runtime.context.JobContext>`
      Throws:
        `java.lang.Exception`

    - #### getObjectType

          public java.lang.Class<?> getObjectType()

      Specified by:
        `getObjectType` in interface `org.springframework.beans.factory.FactoryBean<javax.batch.runtime.context.JobContext>`

    - #### isSingleton

          public boolean isSingleton()

      Specified by:
        `isSingleton` in interface `org.springframework.beans.factory.FactoryBean<javax.batch.runtime.context.JobContext>`

    - #### setJobExecution

          public void setJobExecution(JobExecution jobExecution)

      Used to provide `JobContext` instances to batch artifacts that are not within the scope of a given step.
      Parameters:
        `jobExecution` - set the current `JobExecution`

    - #### setBatchPropertyContext

          public void setBatchPropertyContext(BatchPropertyContext propertyContext)

      Parameters:
        `propertyContext` - the `BatchPropertyContext` to obtain job properties from

    - #### close

          public void close()

      Used to remove the `JobContext` for the current thread. Not used via normal processing but useful for testing.