Task.Manager
Class TaskManager

java.lang.Object
  extended by Task.Support.EnhancedListeners.EnhancedListenerManager<TaskListChangeListener>
      extended by Task.Manager.TaskManager

public class TaskManager
extends EnhancedListenerManager<TaskListChangeListener>

TaskManager is a class that makes it easier for tasks to be created and a history of running and dead tasks maintained in an application.

All the tasks stopped and purged, as is determined by their AutoShutdownSignals policy (that's defined in the task itself). You have to call autoShutdownOn(AutoShutdownSignals) and pass it the appropriate AutoShutdownSignals enumeration to perform this auto shutdown... you can extend the enumeration to add different signals that are more appropriate to your application. If you want to kill all running tasks then issue a shutdownAll().

Tasks are not automatically started. This has to be done explicitly by you/your app.

Regardless of whether a task has been auto stopped (by a call to autoShutdownOn(AutoShutdownSignals) or manually stopped, the list of tasks is pruned by this manager, it's checked for tasks that have not been stopped, and these are NOT removed!

When the task list changes, TaskListChangeEvents are fired to any registered TaskListChangeListeners. If you register a soft-listener, then it will be pruned/purged when a shutdownAll() is invoked.

Since:
Jun 29, 2007, 1:00:34 PM
Version:
1.0
Author:
Nazmul Idris

Field Summary
 
Fields inherited from class Task.Support.EnhancedListeners.EnhancedListenerManager
_listeners
 
Constructor Summary
TaskManager()
          default constructor
 
Method Summary
 void autoShutdownOn(AutoShutdownSignals stopOnThis)
          stops any registered tasks that have an AutoShutdownSignals policy that matches what's in shutdown.
 java.util.List<AbstractTask> getCopyOfList()
          returns a copy of the task list
 boolean isOnline()
           
 void offline()
           
 void online()
           
 void registerTask(AbstractTask task)
          Registers the given task with the container.
 void shutdownAll()
          stops ALL tasks that are registered with this manager. this includes AutoShutdownSignals.Daemon tasks as well.
 void unregisterTask(AbstractTask task)
          Unregisters the task, whether it's a daemon task or not.
 void writeExceptionToLog(java.util.logging.Level warning, java.lang.String s, TaskException e)
           
 
Methods inherited from class Task.Support.EnhancedListeners.EnhancedListenerManager
addListener, fireUpdatesToListeners, fireUpdateToListeners, pruneSoftListeners, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaskManager

public TaskManager()
default constructor

Method Detail

offline

public void offline()

online

public void online()

isOnline

public boolean isOnline()

shutdownAll

public void shutdownAll()
stops ALL tasks that are registered with this manager. this includes AutoShutdownSignals.Daemon tasks as well.


autoShutdownOn

public void autoShutdownOn(AutoShutdownSignals stopOnThis)
stops any registered tasks that have an AutoShutdownSignals policy that matches what's in shutdown.

Parameters:
stopOnThis - match all the registered tasks's autostop policy with this

registerTask

public void registerTask(AbstractTask task)
                  throws java.lang.IllegalArgumentException
Registers the given task with the container.

Parameters:
task - task to register with the container
Throws:
java.lang.IllegalArgumentException

unregisterTask

public void unregisterTask(AbstractTask task)
                    throws java.lang.IllegalArgumentException
Unregisters the task, whether it's a daemon task or not.

Throws:
java.lang.IllegalArgumentException

getCopyOfList

public java.util.List<AbstractTask> getCopyOfList()
returns a copy of the task list


writeExceptionToLog

public void writeExceptionToLog(java.util.logging.Level warning,
                                java.lang.String s,
                                TaskException e)


Copyright © 2011. All Rights Reserved.