org.crosswire.common.progress

## Class JobManager

- java.lang.Object
- - org.crosswire.common.progress.JobManager

-     public final class JobManager
      extends Object

  JobManager is responsible for creating jobs and informing listeners about the progress they make to completion.

  Example code:

       final Thread worker = new Thread("DisplayPreLoader")
       {
           public void run()
           {
               URL predictURI = Project.instance().getWritablePropertiesURI("save-name");
               Progress job = JobManager.createJob("Job Title", predictURI, this, true);
               try
               {
                   job.setProgress("Step 1");
                   ...
                   job.setProgress("Step 2");
                   ...
               }
               catch (Exception ex)
               {
                   ...
                   job.ignoreTimings();
               }
               finally
               {
                   job.done();
               }
           }
       };
       worker.setPriority(Thread.MIN_PRIORITY);
       worker.start();

  Author:
    Joe Walker
  See Also:
    `The GNU Lesser General Public License for details.`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private static Set<Progress>` | `jobs` List of current jobs
    `private static List<WorkListener>` | `listeners` List of listeners using thread safe list
    `private static org.slf4j.Logger` | `log` The log stream

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `private` | `JobManager()` Prevent instantiation

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `addWorkListener(WorkListener li)` Add a listener to the list
    `static Progress` | `createJob(String jobName)` Create a new Job that cannot be canceled.
    `static Progress` | `createJob(String jobID, String jobName, Thread workerThread)` Create a new Job that can be canceled.
    `protected static void` | `fireWorkProgressed(Progress job)` Inform the listeners that a title has changed.
    `static int` | `getJobCount()`
    `static Iterator<Progress>` | `iterator()` Accessor for the currently known jobs
    `static void` | `removeWorkListener(WorkListener li)` Remove a listener from the list

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

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

- - ### Field Detail

    - #### listeners

          private static List<WorkListener> listeners

      List of listeners using thread safe list

    - #### jobs

          private static Set<Progress> jobs

      List of current jobs

    - #### log

          private static final org.slf4j.Logger log

      The log stream

  - ### Constructor Detail

    - #### JobManager

          private JobManager()

      Prevent instantiation

  - ### Method Detail

    - #### createJob

          public static Progress createJob(String jobName)

      Create a new Job that cannot be canceled.
      Parameters:
        `jobName` - the name of the Job
      Returns:
        the job

    - #### createJob

          public static Progress createJob(String jobID,
                           String jobName,
                           Thread workerThread)

      Create a new Job that can be canceled.
      Parameters:
        `jobID` - a unique identifier for the job
        `jobName` - the name of the Job
        `workerThread` - the thread on which this job runs
      Returns:
        the job

    - #### addWorkListener

          public static void addWorkListener(WorkListener li)

      Add a listener to the list
      Parameters:
        `li` - the interested listener

    - #### removeWorkListener

          public static void removeWorkListener(WorkListener li)

      Remove a listener from the list
      Parameters:
        `li` - the disinterested listener

    - #### iterator

          public static Iterator<Progress> iterator()

      Accessor for the currently known jobs
      Returns:
        an iterator over the jobs

    - #### getJobCount

          public static int getJobCount()

      Returns:
        the number of current jobs

    - #### fireWorkProgressed

          protected static void fireWorkProgressed(Progress job)

      Inform the listeners that a title has changed.
      Parameters:
        `job` - the job that has made progress