org.springframework.batch.core.jsr

## Class JsrJobParametersConverter

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

- All Implemented Interfaces:
    JobParametersConverter, org.springframework.beans.factory.InitializingBean

      public class JsrJobParametersConverter
      extends java.lang.Object
      implements JobParametersConverter, org.springframework.beans.factory.InitializingBean

  Provides default conversion methodology for JSR-352's implementation. Since Spring Batch uses job parameters as a way of identifying a job instance, this converter will add an additional identifying parameter if it does not exist already in the list. The id for the identifying parameter will come from the JOB_SEQ sequence as used to generate the unique ids for BATCH_JOB_INSTANCE records.
  Since:
    3.0
  Author:
    Michael Minella, Mahmoud Ben Hassine

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `javax.sql.DataSource` | `dataSource`
    `org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer` | `incrementer`
    `static java.lang.String` | `JOB_RUN_ID`
    `java.lang.String` | `tablePrefix`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JsrJobParametersConverter(javax.sql.DataSource dataSource)` Main constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()`
    `JobParameters` | `getJobParameters(java.util.Properties properties)` Get a new `JobParameters` instance.
    `java.util.Properties` | `getProperties(JobParameters params)` The inverse operation: get a `Properties` instance.
    `void` | `setTablePrefix(java.lang.String tablePrefix)` The table prefix used in the current `JobRepository`

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

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

- - ### Field Detail

    - #### JOB_RUN_ID

          public static final java.lang.String JOB_RUN_ID

      See Also:
        Constant Field Values

    - #### incrementer

          public org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer incrementer

    - #### tablePrefix

          public java.lang.String tablePrefix

    - #### dataSource

          public javax.sql.DataSource dataSource

  - ### Constructor Detail

    - #### JsrJobParametersConverter

          public JsrJobParametersConverter(javax.sql.DataSource dataSource)

      Main constructor.
      Parameters:
        `dataSource` - used to gain access to the database to get unique ids.

  - ### Method Detail

    - #### setTablePrefix

          public void setTablePrefix(java.lang.String tablePrefix)

      The table prefix used in the current `JobRepository`
      Parameters:
        `tablePrefix` - the table prefix used for the job repository tables

    - #### afterPropertiesSet

          public void afterPropertiesSet()
                                  throws java.lang.Exception

      Specified by:
        `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
      Throws:
        `java.lang.Exception`

    - #### getJobParameters

          public JobParameters getJobParameters(@Nullable
                                                java.util.Properties properties)

      Description copied from interface: `JobParametersConverter`
      Get a new `JobParameters` instance. If given null, or an empty properties, an empty JobParameters will be returned.
      Specified by:
        `getJobParameters` in interface `JobParametersConverter`
      Parameters:
        `properties` - the runtime parameters in the form of String literals.
      Returns:
        a `JobParameters` properties converted to the correct types.

    - #### getProperties

          public java.util.Properties getProperties(@Nullable
                                                    JobParameters params)

      Description copied from interface: `JobParametersConverter`
      The inverse operation: get a `Properties` instance. If given null or empty JobParameters, an empty Properties should be returned.
      Specified by:
        `getProperties` in interface `JobParametersConverter`
      Parameters:
        `params` - the `JobParameters` instance to be converted.
      Returns:
        a representation of the parameters as properties