Package wt.jmx.core
Class BackgroundTaskSupport
java.lang.Object
wt.jmx.core.BackgroundTaskSupport
- Direct Known Subclasses:
PeriodicTaskSupport
Common, abstract base class for providing background task support.
Supported API: true
Extendable: true
Supported API: true
Extendable: true
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor
Supported API: trueBackgroundTaskSupport(boolean daemon) Constructor; arguments set corresponding properties
Supported API: trueBackgroundTaskSupport(String timerThreadNamePrefix) Constructor; arguments set corresponding properties
Supported API: trueBackgroundTaskSupport(String timerThreadNamePrefix, boolean daemon) Constructor; arguments set corresponding properties
Supported API: true -
Method Summary
Modifier and TypeMethodDescriptionprotected ScheduledExecutorServicecreateExecutor(String timerThreadNamePrefix, boolean daemon) Provides ScheduledExecutorService instance used for execution.protected abstract RunnableThis 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.booleanisDaemon()Whether the daemon or non-daemon threads should be used.booleanReturns whether this instance is currently running, i.e start() has been called more recently than stop().abstract booleanWhether the task itself is currently started.protected voidshutdownExecutor(ScheduledExecutorService executor) Shutdown the ScheduledExecutorService instance (that produced by createExecutor()) via executor.shutdown().voidstart()Start background execution of task.abstract voidStarts the task itself.voidstop()Stop background execution of task.abstract voidstopTask()Stops the task itself.
-
Constructor Details
-
BackgroundTaskSupport
public BackgroundTaskSupport()Default constructor
Supported API: true -
BackgroundTaskSupport
Constructor; arguments set corresponding properties
Supported API: true -
BackgroundTaskSupport
public BackgroundTaskSupport(boolean daemon) Constructor; arguments set corresponding properties
Supported API: true -
BackgroundTaskSupport
Constructor; arguments set corresponding properties
Supported API: true
-
-
Method Details
-
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
The prefix name given to all threads associated with the underlying time. This prefix is used with an underlyingSharedScheduledExecutorto 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 inSharedScheduledExecutor.
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
Provides ScheduledExecutorService instance used for execution. This implementation returns aSharedScheduledExecutorand should almost always suffice as is.
Supported API: true -
shutdownExecutor
Shutdown the ScheduledExecutorService instance (that produced by createExecutor()) via executor.shutdown(). This implementation returns aSharedScheduledExecutorand should almost always suffice as is.
Supported API: true
-