de.esprit.netsuite.rtask

## Class AbstractClientEDT<C extends ClientContext>

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.appsuite.launch.AbstractApplicationObject<C>
    - - de.esprit.appsuite.task.AbstractAsyncExecutable<C>
      - - de.esprit.appsuite.task.AbstractAsyncTask<C>
        - - de.esprit.netsuite.rtask.AbstractClientTask<C>
          - - de.esprit.netsuite.rtask.AbstractClientEDT<C>

- All Implemented Interfaces:
    ApplicationObject<C>, AsyncExecutable<C>, AsyncTask<C>, CancellableTask, LocalCancellableTask, TaskMonitorSupport, TaskIdHolder, SimpleLogSupport, Dumpable, Executable, ClientObject<C>, RemoteTaskEventReceiver<C>, java.lang.Runnable
  Direct Known Subclasses:
    RemoteArchiveExtractEDT, RemoteArchiveListEDT

      public abstract class AbstractClientEDT<C extends ClientContext>
      extends AbstractClientTask<C>
      implements RemoteTaskEventReceiver<C>

  This is a local event-driven-task (EDT) which has a remote counterpart task running on the sever. The local task is bound to the remote task in a way that it iterates through the `RemoteTaskEvent`s received from there. It finishes, when the remote task has finished. If this task is cancelled, then in fact the remote counterpart task is cancelled first.
  Author:
    Rainer Buesch

- - ### Field Summary

    - ### Fields inherited from class de.esprit.appsuite.task.AbstractAsyncExecutable

      `childTaskRef, isTestMode, monitorController, resultRef, stateFlag`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractClientEDT(C ctx)`
    `AbstractClientEDT(C ctx, LogChannel logCh)`
    `AbstractClientEDT(C ctx, LogChannel logCh, java.lang.String taskName, TaskType taskType)`
    `AbstractClientEDT(C ctx, java.lang.String taskName)`
    `AbstractClientEDT(C ctx, java.lang.String taskName, TaskType taskType)`
    `AbstractClientEDT(C ctx, TaskType taskType)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cancel()` Cancels the remote counterpart task running on the server using a `RemoteTaskCancelAgent`.
    `void` | `executeAsync()` Must be overridden to perform the async part.
    `RemoteTaskEventForwarder` | `getEventForwarder()`
    `RemoteRunStateFlag` | `getLastReceivedRemoteRunStateFlag()`
    `SessionId` | `getOwnerSessionId()` Returns the originator sessionId or the connection sessionId if owner is not set
    `protected abstract RemoteTaskCreator` | `getRemoteTaskCreator()` Creates the agent that is responsible for starting the remote task.
    `RemoteTaskId` | `getRemoteTaskId()` Returns the `RemoteTaskId` of the remotely running task as received within the `RemoteTaskStartAgent` .
    `boolean` | `isForwardingEvents()`
    `void` | `receivedTaskEvent(RemoteTaskEvent event)` Is called whenever this task has received a `RemoteTaskEvent` from the remotely running task.
    `void` | `setEventForwarder(RemoteTaskEventForwarder eventForwarder)` Sets the forwarder for `RemoteTaskEvent`s
    `void` | `setOwnerSessionId(SessionId ownerSessId)` Sets the originator sessionId

    - ### Methods inherited from class de.esprit.netsuite.rtask.AbstractClientTask

      `executeSubTask, getClientContext, getSessionId`

    - ### Methods inherited from class de.esprit.appsuite.task.AbstractAsyncTask

      `awaitFinished, awaitFinished, awaitStarted, createTaskId, deregisterTask, doOnFinish, doOnStart, doOnSuccess, executeChildTask, executeChildTask, getCurrentFuture, getMaxChildTasks, getPriority, getProcessingDuration, getStartTime, getStopWatch, handleFinish, handleStart, handleSuccess, isRegisterForCancel, isRunning, notifyProceeded, registerTask, releaseStart, run, setCurrentFuture, setMaxChildTasks, setPriority, setRegisterForCancel, setReleaseTimeout, submit, submit, submitInternal, toString, wasSucceeded`

    - ### Methods inherited from class de.esprit.appsuite.task.AbstractAsyncExecutable

      `addMonitor, checkCancelled, checkForErrorAndRethrow, clearMonitors, createRunStateFlag, doOnCancel, doOnFailure, execute, executeSubTask, getError, getMaxProgressSteps, getMonitorCount, getMonitors, getName, getProgressStepCount, getResult, getRunStateFlag, getTaskId, getType, handleCancellation, handleFailure, hasError, hasMonitor, isCancellable, registerTaskStateChange, removeMonitor, resetProgress, setCancellable, setLogLevel, setMaxProgressSteps, setMonitor, setName, setName, setResult, setRunStateFlag, setTaskId, setType, shouldFireMonitor, sleepChecked, wasCancelled`

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

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

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

    - ### Methods inherited from interface de.esprit.appsuite.task.AsyncTask

      `awaitFinished, awaitFinished, awaitStarted, executeChildTask, executeChildTask, getError, getProcessingDuration, hasError, isRegisterForCancel, isRunning, releaseStart, setName, setReleaseTimeout, submit, submit`

    - ### Methods inherited from interface de.esprit.appsuite.task.AsyncExecutable

      `checkCancelled, checkForErrorAndRethrow, executeSubTask, getName, getResult, getRunStateFlag, getTaskId, getType, handleCancellation, handleFailure, isCancellable, notifyProceeded, setCancellable, setName, setResult, setRunStateFlag, sleepChecked`

    - ### Methods inherited from interface de.esprit.appsuite.launch.ApplicationObject

      `getApplicationContext`

    - ### Methods inherited from interface de.esprit.common.type.Executable

      `execute`

    - ### Methods inherited from interface de.esprit.appsuite.task.monitor.TaskMonitorSupport

      `addMonitor, clearMonitors, getMonitorCount, getMonitors, hasMonitor, removeMonitor`

    - ### Methods inherited from interface de.esprit.common.log.SimpleLogSupport

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

    - ### Methods inherited from interface java.lang.Runnable

      `run`

    - ### Methods inherited from interface de.esprit.appsuite.task.CancellableTask

      `wasCancelled`

    - ### Methods inherited from interface de.esprit.appsuite.task.TaskIdHolder

      `getTaskId`

    - ### Methods inherited from interface de.esprit.common.type.Dumpable

      `toDumpString, toDumpString, toString, toString`

    - ### Methods inherited from interface de.esprit.netsuite.client.ClientObject

      `getClientContext`

- - ### Constructor Detail

    - #### AbstractClientEDT

          public AbstractClientEDT(C ctx)

    - #### AbstractClientEDT

          public AbstractClientEDT(C ctx,
                           TaskType taskType)

    - #### AbstractClientEDT

          public AbstractClientEDT(C ctx,
                           java.lang.String taskName)

    - #### AbstractClientEDT

          public AbstractClientEDT(C ctx,
                           LogChannel logCh)

    - #### AbstractClientEDT

          public AbstractClientEDT(C ctx,
                           java.lang.String taskName,
                           TaskType taskType)

    - #### AbstractClientEDT

          public AbstractClientEDT(C ctx,
                           LogChannel logCh,
                           java.lang.String taskName,
                           TaskType taskType)

  - ### Method Detail

    - #### setEventForwarder

          public void setEventForwarder(RemoteTaskEventForwarder eventForwarder)

      Sets the forwarder for `RemoteTaskEvent`s

    - #### getEventForwarder

          public RemoteTaskEventForwarder getEventForwarder()

    - #### isForwardingEvents

          public boolean isForwardingEvents()

    - #### executeAsync

          public final void executeAsync()
                                  throws java.lang.Exception

      Description copied from class: `AbstractAsyncTask`
      Must be overridden to perform the async part. From within this method you may directly call `AbstractAsyncTask.notifyProceeded(Object, int, int, String)` in order to notify about task progress. Note: the running task should periodically call `AbstractAsyncExecutable.checkCancelled()` in order to detect cancellation.
      Specified by:
        `executeAsync` in interface `AsyncExecutable<C extends ClientContext>`
      Specified by:
        `executeAsync` in class `AbstractAsyncTask<C extends ClientContext>`
      Throws:
        `java.lang.Exception`
      See Also:
        `for synchronous execution`

    - #### setOwnerSessionId

          public void setOwnerSessionId(SessionId ownerSessId)

      Sets the originator sessionId

    - #### getOwnerSessionId

          public SessionId getOwnerSessionId()

      Returns the originator sessionId or the connection sessionId if owner is not set

    - #### getRemoteTaskId

          public RemoteTaskId getRemoteTaskId()

      Returns the `RemoteTaskId` of the remotely running task as received within the `RemoteTaskStartAgent` .

    - #### cancel

          public void cancel()

      Cancels the remote counterpart task running on the server using a `RemoteTaskCancelAgent`.
      Specified by:
        `cancel` in interface `LocalCancellableTask`
      Overrides:
        `cancel` in class `AbstractAsyncTask<C extends ClientContext>`

    - #### getRemoteTaskCreator

          protected abstract RemoteTaskCreator getRemoteTaskCreator()

      Creates the agent that is responsible for starting the remote task.

    - #### receivedTaskEvent

          public void receivedTaskEvent(RemoteTaskEvent event)

      Is called whenever this task has received a `RemoteTaskEvent` from the remotely running task. Within this method we may investigate the event type and perform an appropriate reaction. Note that any RuntimeException thrown here will not break the event iteration.
      Specified by:
        `receivedTaskEvent` in interface `RemoteTaskEventReceiver<C extends ClientContext>`

    - #### getLastReceivedRemoteRunStateFlag

          public RemoteRunStateFlag getLastReceivedRemoteRunStateFlag()

Copyright © 2014 EsprIT-Systems. All Rights Reserved.