org.openprivacy.reptile.tasks
Class TaskManager

java.lang.Object
  |
  +--org.openprivacy.reptile.tasks.TaskManager

public class TaskManager
extends java.lang.Object

Generic interface for running tasks in the background. These are basically just Threads.

Version:
$Id: TaskManager.java,v 1.15 2002/07/03 22:23:36 burton Exp $
Author:
burtonator

Constructor Summary
TaskManager()
           
 
Method Summary
 boolean anyTasksRunning()
          Return true if ANY tasks are currently running.
static boolean checkTaskSystemDisabled()
          If the Task system is enabled, return true.
 boolean contains(java.lang.String identifier)
          Return true if this Task manager contains the given task.
 void destroy()
          Destroy the tasks system.
static TaskManager getInstance()
          Get an instance of the TaskManager.
 Task getTask(java.lang.String identifier)
          Get a task from the TaskManager.
 int getTaskCount()
          Return the total number of tasks.
 java.util.Enumeration getTasks()
          Get all known tasks.
 void register(java.lang.Class clazz)
          Start a specific task.
 void register(Task task)
          Register the given task for further processing.
static void runTask(Task task)
          Run a specific task, catching all exceptions and logging them correctly.
 void unregister(java.lang.String identifier)
          Unregister the given task so that it doesn't process any more.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaskManager

public TaskManager()
Method Detail

getInstance

public static TaskManager getInstance()
Get an instance of the TaskManager.


contains

public boolean contains(java.lang.String identifier)
Return true if this Task manager contains the given task.


getTasks

public java.util.Enumeration getTasks()
Get all known tasks.


register

public void register(java.lang.Class clazz)
              throws java.lang.Exception
Start a specific task.

java.lang.Exception

register

public void register(Task task)
              throws java.lang.Exception
Register the given task for further processing.

java.lang.Exception

unregister

public void unregister(java.lang.String identifier)
                throws java.lang.Exception
Unregister the given task so that it doesn't process any more.

java.lang.Exception

checkTaskSystemDisabled

public static boolean checkTaskSystemDisabled()
If the Task system is enabled, return true.


getTask

public Task getTask(java.lang.String identifier)
             throws java.lang.Exception
Get a task from the TaskManager.

java.lang.Exception

getTaskCount

public int getTaskCount()
Return the total number of tasks.


anyTasksRunning

public boolean anyTasksRunning()
Return true if ANY tasks are currently running.


destroy

public void destroy()
Destroy the tasks system. Basically this sets the tasks systems to disabled (so that nothing else starts up again) and then waits until all tasks are not running.


runTask

public static void runTask(Task task)
Run a specific task, catching all exceptions and logging them correctly.

This is the best way to run a task. Do not call run() directly.