Package wt.jmx.core

Class BackgroundTaskSupport

java.lang.Object
wt.jmx.core.BackgroundTaskSupport
Direct Known Subclasses:
PeriodicTaskSupport

public abstract class BackgroundTaskSupport extends Object
Common, abstract base class for providing background task support.

Supported API: true

Extendable: true
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor

    Supported API: true
    BackgroundTaskSupport(boolean daemon)
    Constructor; arguments set corresponding properties

    Supported API: true
    BackgroundTaskSupport(String timerThreadNamePrefix)
    Constructor; arguments set corresponding properties

    Supported API: true
    BackgroundTaskSupport(String timerThreadNamePrefix, boolean daemon)
    Constructor; arguments set corresponding properties

    Supported API: true
  • Method Summary

    Modifier and Type
    Method
    Description
    createExecutor(String timerThreadNamePrefix, boolean daemon)
    Provides ScheduledExecutorService instance used for execution.
    protected abstract Runnable
    This method must be overridden to return the Runnable task for execution by this class.
    The prefix name given to all threads associated with the underlying time.
    boolean
    Whether the daemon or non-daemon threads should be used.
    boolean
    Returns whether this instance is currently running, i.e start() has been called more recently than stop().
    abstract boolean
    Whether the task itself is currently started.
    protected void
    Shutdown the ScheduledExecutorService instance (that produced by createExecutor()) via executor.shutdown().
    void
    Start background execution of task.
    abstract void
    Starts the task itself.
    void
    Stop background execution of task.
    abstract void
    Stops the task itself.

    Methods inherited from class java.lang.Object

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

    • BackgroundTaskSupport

      public BackgroundTaskSupport()
      Default constructor

      Supported API: true
    • BackgroundTaskSupport

      public BackgroundTaskSupport(String timerThreadNamePrefix)
      Constructor; arguments set corresponding properties

      Supported API: true
    • BackgroundTaskSupport

      public BackgroundTaskSupport(boolean daemon)
      Constructor; arguments set corresponding properties

      Supported API: true
    • BackgroundTaskSupport

      public BackgroundTaskSupport(String timerThreadNamePrefix, boolean daemon)
      Constructor; arguments set corresponding properties

      Supported API: true
  • Method Details

    • createTask

      protected abstract Runnable createTask()
      This method must be overridden to return the Runnable task for execution by this class.

      Supported API: true
    • isStarted

      public boolean isStarted()
      Returns whether this instance is currently running, i.e start() has been called more recently than stop().

      Supported API: true
    • start

      public void start()
      Start background execution of task. When used from within an SelfAwareMBean this should generally be called within the MBean's start() method.

      Supported API: true
    • stop

      public void stop()
      Stop background execution of task. When used from within an SelfAwareMBean this should generally be called within the MBean's stop() method.

      Supported API: true
    • getTimerThreadNamePrefix

      public String getTimerThreadNamePrefix()
      The prefix name given to all threads associated with the underlying time. This prefix is used with an underlying SharedScheduledExecutor to share thread pools for all instances with the same prefix name and daemon flag. A value of null here implies that a default prefix will be used in SharedScheduledExecutor.

      Supported API: true
    • isDaemon

      public boolean isDaemon()
      Whether the daemon or non-daemon threads should be used.

      Supported API: true
    • isTaskStarted

      public abstract boolean isTaskStarted()
      Whether the task itself is currently started.

      Supported API: true
    • startTask

      public abstract void startTask()
      Starts the task itself. Called by start().

      Supported API: true
    • stopTask

      public abstract void stopTask()
      Stops the task itself. Called by stop().

      Supported API: true
    • createExecutor

      protected ScheduledExecutorService createExecutor(String timerThreadNamePrefix, boolean daemon)
      Provides ScheduledExecutorService instance used for execution. This implementation returns a SharedScheduledExecutor and should almost always suffice as is.

      Supported API: true
    • shutdownExecutor

      protected void shutdownExecutor(ScheduledExecutorService executor)
      Shutdown the ScheduledExecutorService instance (that produced by createExecutor()) via executor.shutdown(). This implementation returns a SharedScheduledExecutor and should almost always suffice as is.

      Supported API: true