de.esprit.appsuite.task.taskmgr

## Class TaskRegistry<C extends ApplicationContext>

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.appsuite.launch.AbstractApplicationObject<C>
    - - de.esprit.appsuite.task.taskmgr.TaskRegistry<C>

- All Implemented Interfaces:
    ApplicationObject<C>, TaskRegistrationEvent.Source, SimpleLogSupport, Dumpable

      public class TaskRegistry<C extends ApplicationContext>
      extends AbstractApplicationObject<C>
      implements TaskRegistrationEvent.Source

  This class maintains a Map with references to all running cancellable `AsyncTask`s in order to be able to access them by `TaskId` and cancel them at any time. It provides a means for detecting `TaskRegistrationEvent`s in order to reflect the running tasks in GUI ListModels.
  Author:
    Rainer Buesch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TaskRegistry(C ctx)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addTaskRegistrationListener(TaskRegistrationEvent.Listener l)` Register as a listener for this event type.
    `boolean` | `cancelTask(TaskId taskId)` Cancels the running task by `TaskId`.
    `void` | `deregisterTask(AsyncTask task)` De-registers the given task from the `TaskManager`.
    `protected java.util.List<TaskId>` | `findAllCancellableTaskIds()` Returns a List of all `TaskId`s that are registered for cancellation.
    `java.util.List<TaskId>` | `findAllNonCancellableTaskIds()` Returns a List of all `TaskId`s that are registered but uncancellable.
    `AsyncTask` | `findTask(TaskId taskId)`
    `AsyncTask` | `findTaskByName(java.lang.String taskName)`
    `int` | `getTaskCount()`
    `void` | `registerTask(AsyncTask task)` Registers the given task within the `TaskManager`.
    `void` | `registerTaskStateChange(RunStateFlag stateFlag)` This call causes a `TaskRegistrationEvent` of type `ChangeType.UPDATE` to be fired.
    `void` | `removeTaskRegistrationListener(TaskRegistrationEvent.Listener l)` Deregister the listener.

    - ### Methods inherited from class de.esprit.appsuite.launch.AbstractApplicationObject

      `getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TaskRegistry

          public TaskRegistry(C ctx)

  - ### Method Detail

    - #### cancelTask

          public boolean cancelTask(TaskId taskId)

      Cancels the running task by `TaskId`.
      Returns:
        true if the task was found and cancelled, false if the task was not found

    - #### findTask

          public final AsyncTask findTask(TaskId taskId)

    - #### findTaskByName

          public final AsyncTask findTaskByName(java.lang.String taskName)

    - #### getTaskCount

          public int getTaskCount()

    - #### findAllCancellableTaskIds

          protected java.util.List<TaskId> findAllCancellableTaskIds()

      Returns a List of all `TaskId`s that are registered for cancellation.

    - #### findAllNonCancellableTaskIds

          public java.util.List<TaskId> findAllNonCancellableTaskIds()

      Returns a List of all `TaskId`s that are registered but uncancellable.

    - #### registerTask

          public void registerTask(AsyncTask task)

      Registers the given task within the `TaskManager`. This call causes a `TaskRegistrationEvent` of type `ChangeType.CREATE` to be fired.

    - #### deregisterTask

          public void deregisterTask(AsyncTask task)

      De-registers the given task from the `TaskManager`. This call causes a `TaskRegistrationEvent` of type `ChangeType.DELETE` to be fired.

    - #### registerTaskStateChange

          public void registerTaskStateChange(RunStateFlag stateFlag)

      This call causes a `TaskRegistrationEvent` of type `ChangeType.UPDATE` to be fired.

    - #### addTaskRegistrationListener

          public void addTaskRegistrationListener(TaskRegistrationEvent.Listener l)

      Description copied from interface: `TaskRegistrationEvent.Source`
      Register as a listener for this event type.
      Specified by:
        `addTaskRegistrationListener` in interface `TaskRegistrationEvent.Source`

    - #### removeTaskRegistrationListener

          public void removeTaskRegistrationListener(TaskRegistrationEvent.Listener l)

      Description copied from interface: `TaskRegistrationEvent.Source`
      Deregister the listener.
      Specified by:
        `removeTaskRegistrationListener` in interface `TaskRegistrationEvent.Source`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.