org.springframework.batch.core.configuration.support

## Class DefaultJobLoader

- java.lang.Object
- - org.springframework.batch.core.configuration.support.DefaultJobLoader

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

      public class DefaultJobLoader
      extends java.lang.Object
      implements JobLoader, org.springframework.beans.factory.InitializingBean

  Default implementation of `JobLoader`. Uses a `JobRegistry` to manage a population of loaded jobs and clears them up when asked. An optional `StepRegistry` might also be set to register the step(s) available for each registered job.
  Author:
    Dave Syer, Stephane Nicoll, Mahmoud Ben Hassine

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultJobLoader()` Default constructor useful for declarative configuration.
    `DefaultJobLoader(JobRegistry jobRegistry)` Creates a job loader with the job registry provided.
    `DefaultJobLoader(JobRegistry jobRegistry, StepRegistry stepRegistry)` Creates a job loader with the job and step registries provided.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterPropertiesSet()`
    `void` | `clear()` Unregister all the jobs and close all the contexts created by this loader.
    `java.util.Collection<Job>` | `load(ApplicationContextFactory factory)` Load an application context and register all the jobs.
    `java.util.Collection<Job>` | `reload(ApplicationContextFactory factory)` Load an application context and register all the jobs, having first unregistered them if already registered.
    `void` | `setJobRegistry(JobRegistry jobRegistry)` The `JobRegistry` to use for jobs created.
    `void` | `setStepRegistry(StepRegistry stepRegistry)` The `StepRegistry` to use for the steps of created jobs.

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

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

- - ### Constructor Detail

    - #### DefaultJobLoader

          public DefaultJobLoader()

      Default constructor useful for declarative configuration.

    - #### DefaultJobLoader

          public DefaultJobLoader(JobRegistry jobRegistry)

      Creates a job loader with the job registry provided.
      Parameters:
        `jobRegistry` - a `JobRegistry`

    - #### DefaultJobLoader

          public DefaultJobLoader(JobRegistry jobRegistry,
                                  @Nullable
                                  StepRegistry stepRegistry)

      Creates a job loader with the job and step registries provided.
      Parameters:
        `jobRegistry` - a `JobRegistry`
        `stepRegistry` - a `StepRegistry` (can be `null`)

  - ### Method Detail

    - #### setJobRegistry

          public void setJobRegistry(JobRegistry jobRegistry)

      The `JobRegistry` to use for jobs created.
      Parameters:
        `jobRegistry` - the job registry

    - #### setStepRegistry

          public void setStepRegistry(StepRegistry stepRegistry)

      The `StepRegistry` to use for the steps of created jobs.
      Parameters:
        `stepRegistry` - the step registry

    - #### clear

          public void clear()

      Unregister all the jobs and close all the contexts created by this loader.
      Specified by:
        `clear` in interface `JobLoader`
      See Also:
        `JobLoader.clear()`

    - #### reload

          public java.util.Collection<Job> reload(ApplicationContextFactory factory)

      Description copied from interface: `JobLoader`
      Load an application context and register all the jobs, having first unregistered them if already registered. Implementations should also take care to close and clean up the application context previously created if possible (either from this factory or from one with the same jobs).
      Specified by:
        `reload` in interface `JobLoader`
      Parameters:
        `factory` - a factory for an application context (containing jobs)
      Returns:
        a collection of the jobs created

    - #### load

          public java.util.Collection<Job> load(ApplicationContextFactory factory)
                                         throws DuplicateJobException

      Description copied from interface: `JobLoader`
      Load an application context and register all the jobs.
      Specified by:
        `load` in interface `JobLoader`
      Parameters:
        `factory` - a factory for an application context (containing jobs)
      Returns:
        a collection of the jobs created
      Throws:
        `DuplicateJobException` - if a job with the same name was already registered

    - #### afterPropertiesSet

          public void afterPropertiesSet()

      Specified by:
        `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`