de.esprit.appsuite.task.taskmgr

## Class TaskManager<C extends ApplicationContext>

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

- All Implemented Interfaces:
    ApplicationObject<C>, CloseableComponent, SimpleLogSupport, Dumpable, java.lang.AutoCloseable
  Direct Known Subclasses:
    ClientTaskManager, ServerTaskManager

      public class TaskManager<C extends ApplicationContext>
      extends AbstractApplicationObject<C>
      implements CloseableComponent

  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 also maintains a `ActiveTasksListModel` which keeps references to the `RunStateFlag` of the currently running tasks. This ListModel is linked to the taskMap for canceling tasks.
  Author:
    Rainer Buesch

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TaskManager(C ctx)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `cancelAll()`
    `boolean` | `cancelTask(TaskId taskId)` Cancels the running task by `TaskId`.
    `protected void` | `checkForActivity(java.util.Map<java.lang.String,java.lang.Integer> activityMap, ActivityListModel listModel)` Adds the count of active async components to the activityMap
    `void` | `close()`
    `void` | `deregisterTask(AsyncTask task)`
    `void` | `fillCurrentActivity(java.util.Map<java.lang.String,java.lang.Integer> activityMap)` Stores the current item-count in the given activityMap.
    `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)`
    `ActiveOsProcessesListModel` | `getActiveOsProcessesListModel()`
    `ActiveTasksListModel` | `getActiveTasksListModel()`
    `ActiveWorkflowsListModel` | `getActiveWorkflowsListModel()`
    `java.util.concurrent.ThreadPoolExecutor` | `getAsyncExecutor()`
    `int` | `getTaskCount()`
    `void` | `registerTask(AsyncTask task)`
    `void` | `registerTaskStateChange(RunStateFlag stateFlag)`

    - ### 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

    - #### TaskManager

          public TaskManager(C ctx)

  - ### Method Detail

    - #### getAsyncExecutor

          public java.util.concurrent.ThreadPoolExecutor getAsyncExecutor()

    - #### getActiveTasksListModel

          public ActiveTasksListModel getActiveTasksListModel()

    - #### getActiveWorkflowsListModel

          public ActiveWorkflowsListModel getActiveWorkflowsListModel()

    - #### getActiveOsProcessesListModel

          public ActiveOsProcessesListModel getActiveOsProcessesListModel()

    - #### cancelAll

          public int cancelAll()

    - #### close

          public void close()

      Specified by:
        `close` in interface `java.lang.AutoCloseable`

    - #### 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 AsyncTask findTaskByName(java.lang.String taskName)

    - #### registerTask

          public void registerTask(AsyncTask task)

    - #### deregisterTask

          public void deregisterTask(AsyncTask task)

    - #### getTaskCount

          public int getTaskCount()

    - #### findAllCancellableTaskIds

          public final 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.

    - #### fillCurrentActivity

          public void fillCurrentActivity(java.util.Map<java.lang.String,java.lang.Integer> activityMap)

      Stores the current item-count in the given activityMap. This is just a snapshot - you should not rely on the counts to be valid over time.

    - #### checkForActivity

          protected final void checkForActivity(java.util.Map<java.lang.String,java.lang.Integer> activityMap,
                              ActivityListModel listModel)

      Adds the count of active async components to the activityMap

    - #### registerTaskStateChange

          public void registerTaskStateChange(RunStateFlag stateFlag)

Copyright © 2014 EsprIT-Systems. All Rights Reserved.