Class DefaultJobManager

  • All Implemented Interfaces:
    JobManager

    public class DefaultJobManager
    extends java.lang.Object
    implements JobManager
    Default implementation of JobManager.

    Tracks jobs using an internal list and notifies registered listeners on status changes.

    Since:
    4.0
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultJobManager()
      Creates a new DefaultJobManager.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addJobListener​(JobListener listener)
      Adds a job listener.
      void completeJob​(DefaultJob job)
      Marks a job as done and fires listeners.
      DefaultJob createJob​(java.lang.String command, java.lang.Thread thread)
      Creates a new foreground job for the given command and thread.
      Job foregroundJob()
      Returns the current foreground job, or null if no job is in the foreground.
      Job get​(long id)
      Returns the job with the specified id, or null if not found.
      java.util.List<Job> jobs()
      Returns all tracked jobs.
      void removeJob​(Job job)
      Removes a job from the managed list.
      void removeJobListener​(JobListener listener)
      Removes a job listener.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultJobManager

        public DefaultJobManager()
        Creates a new DefaultJobManager.
    • Method Detail

      • foregroundJob

        public Job foregroundJob()
        Description copied from interface: JobManager
        Returns the current foreground job, or null if no job is in the foreground.
        Specified by:
        foregroundJob in interface JobManager
        Returns:
        the foreground job, or null
      • jobs

        public java.util.List<Job> jobs()
        Description copied from interface: JobManager
        Returns all tracked jobs.
        Specified by:
        jobs in interface JobManager
        Returns:
        list of all jobs
      • get

        public Job get​(long id)
        Description copied from interface: JobManager
        Returns the job with the specified id, or null if not found.
        Specified by:
        get in interface JobManager
        Parameters:
        id - the job id
        Returns:
        the job, or null
      • addJobListener

        public void addJobListener​(JobListener listener)
        Description copied from interface: JobManager
        Adds a job listener.
        Specified by:
        addJobListener in interface JobManager
        Parameters:
        listener - the listener to add
      • removeJobListener

        public void removeJobListener​(JobListener listener)
        Description copied from interface: JobManager
        Removes a job listener.
        Specified by:
        removeJobListener in interface JobManager
        Parameters:
        listener - the listener to remove
      • createJob

        public DefaultJob createJob​(java.lang.String command,
                                    java.lang.Thread thread)
        Creates a new foreground job for the given command and thread.
        Parameters:
        command - the command string
        thread - the thread executing the command
        Returns:
        the new job
      • completeJob

        public void completeJob​(DefaultJob job)
        Marks a job as done and fires listeners.
        Parameters:
        job - the job to complete
      • removeJob

        public void removeJob​(Job job)
        Removes a job from the managed list.
        Parameters:
        job - the job to remove