public abstract class AbstractRemoteTask<S extends ServerContext> extends AbstractServerTask<S> implements RemoteTask<S>
AsyncTask
which runs on server side and is owned by a user session.
You may attach a RemoteTaskMonitor
if it should send RemoteTaskEvent
s
to the client for synchronization purposes. By default no monitor is attached.childTaskRef, isTestMode, monitorController, resultRef, stateFlag
Constructor and Description |
---|
AbstractRemoteTask(S serverCtx,
LogChannel logCh,
RemoteTaskType taskType,
SessionId sessionId) |
AbstractRemoteTask(S serverCtx,
LogChannel logCh,
java.lang.String taskName,
RemoteTaskType taskType,
SessionId sessionId) |
AbstractRemoteTask(S serverCtx,
RemoteTaskType taskType,
SessionId sessionId) |
AbstractRemoteTask(S serverCtx,
SessionId sessionId) |
AbstractRemoteTask(S serverCtx,
java.lang.String taskName,
RemoteTaskType taskType,
SessionId sessionId) |
Modifier and Type | Method and Description |
---|---|
void |
addMonitor(TaskMonitor monitor)
Adds a
TaskMonitor which is notified about RunStateFlag changes |
void |
cancel(SessionId killerSessId)
Cancels the running task and stores the
SessionId of the killer. |
protected RunStateFlag |
createRunStateFlag()
Creates the
RunStateFlag instance of this task. |
protected RemoteTaskId |
createTaskId()
Is called at submit time.
|
protected TaskMonitor |
createTaskMonitor() |
SessionId |
getKillerSessionId()
Returns the
SessionId of the one who cancelled this task |
SessionId |
getOwnerSessionId()
Returns the
SessionId of the session that owns this task. |
RemoteRunStateFlag |
getRunStateFlag()
Returns the current
RunStateFlag . |
SessionId |
getSessionId()
Returns the
SessionId of the Session that submitted this task |
RemoteTaskId |
getTaskId()
Returns an identifier object for this task.
|
void |
setSessionId(SessionId sessionId)
Allows subtasks to set the sessionId explicitly.
|
RemoteTaskId |
submit()
Submits this task for execution to the default application thread pool
|
RemoteTaskId |
submit(java.util.concurrent.ExecutorService pool)
Submits this task for execution to the given thread pool
|
executeSubTask, getServerContext
awaitFinished, awaitFinished, awaitStarted, cancel, deregisterTask, doOnFinish, doOnStart, doOnSuccess, executeAsync, executeChildTask, executeChildTask, getCurrentFuture, getMaxChildTasks, getPriority, getProcessingDuration, getStartTime, getStopWatch, handleFinish, handleStart, handleSuccess, isRegisterForCancel, isRunning, notifyProceeded, registerTask, releaseStart, run, setCurrentFuture, setMaxChildTasks, setPriority, setRegisterForCancel, setReleaseTimeout, submitInternal, toString, wasSucceeded
checkCancelled, checkForErrorAndRethrow, clearMonitors, doOnCancel, doOnFailure, execute, executeSubTask, getError, getMaxProgressSteps, getMonitorCount, getMonitors, getName, getProgressStepCount, getResult, getType, handleCancellation, handleFailure, hasError, hasMonitor, isCancellable, registerTaskStateChange, removeMonitor, resetProgress, setCancellable, setLogLevel, setMaxProgressSteps, setMonitor, setName, setName, setResult, setRunStateFlag, setTaskId, setType, shouldFireMonitor, sleepChecked, wasCancelled
getApplicationContext, getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toDumpString, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
awaitFinished, awaitFinished, awaitStarted, executeChildTask, executeChildTask, getError, getProcessingDuration, hasError, isRegisterForCancel, isRunning, releaseStart, setName, setReleaseTimeout
checkCancelled, checkForErrorAndRethrow, executeAsync, executeSubTask, getName, getResult, getType, handleCancellation, handleFailure, isCancellable, notifyProceeded, setCancellable, setName, setResult, setRunStateFlag, sleepChecked
getApplicationContext
execute
clearMonitors, getMonitorCount, getMonitors, hasMonitor, removeMonitor
getLogChannel, isLogDebug, isLogVerbose, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, setLogChannel
cancel
wasCancelled
toDumpString, toDumpString, toString, toString
getServerContext
public AbstractRemoteTask(S serverCtx, RemoteTaskType taskType, SessionId sessionId)
public AbstractRemoteTask(S serverCtx, LogChannel logCh, RemoteTaskType taskType, SessionId sessionId)
public AbstractRemoteTask(S serverCtx, java.lang.String taskName, RemoteTaskType taskType, SessionId sessionId)
public AbstractRemoteTask(S serverCtx, LogChannel logCh, java.lang.String taskName, RemoteTaskType taskType, SessionId sessionId)
public final void addMonitor(TaskMonitor monitor)
TaskMonitorSupport
TaskMonitor
which is notified about RunStateFlag
changesaddMonitor
in interface TaskMonitorSupport
addMonitor
in class AbstractAsyncExecutable<S extends ServerContext>
protected TaskMonitor createTaskMonitor()
public void cancel(SessionId killerSessId)
RemoteCancellableTask
SessionId
of the killer. Note that this call puts the
task in a CANCEL_REQUESTED state. The task itself needs to detect this and perform any action
needed for canceling itself - after all it puts itself in the cancelled state and
terminates. The method CancellableTask.wasCancelled()
returns true once a cancel was requested.cancel
in interface RemoteCancellableTask
protected RemoteTaskId createTaskId()
AbstractAsyncTask
TaskId
which
is added to the RunStateFlag
.createTaskId
in class AbstractAsyncTask<S extends ServerContext>
public RemoteTaskId submit() throws java.lang.Exception
AsyncTask
submit
in interface AsyncTask<S extends ServerContext>
submit
in interface RemoteTask<S extends ServerContext>
submit
in class AbstractAsyncTask<S extends ServerContext>
java.lang.Exception
- if the pool is busypublic RemoteTaskId submit(java.util.concurrent.ExecutorService pool) throws java.lang.Exception
AsyncTask
submit
in interface AsyncTask<S extends ServerContext>
submit
in interface RemoteTask<S extends ServerContext>
submit
in class AbstractAsyncTask<S extends ServerContext>
java.lang.Exception
- if the pool is busyprotected final RunStateFlag createRunStateFlag()
AbstractAsyncExecutable
RunStateFlag
instance of this task.
Is only called once at construction time.createRunStateFlag
in class AbstractAsyncExecutable<S extends ServerContext>
public RemoteRunStateFlag getRunStateFlag()
AsyncExecutable
RunStateFlag
. Note that there is exactly one
RunStateFlag
per running task. Child-tasks as well as sub-tasks share it with their
parents.getRunStateFlag
in interface AsyncExecutable<S extends ServerContext>
getRunStateFlag
in interface RemoteTask<S extends ServerContext>
getRunStateFlag
in class AbstractAsyncExecutable<S extends ServerContext>
public void setSessionId(SessionId sessionId)
public SessionId getOwnerSessionId()
RemoteTask
SessionId
of the session that owns this task.
Note the difference to RemoteTask.getSessionId()
. A task that runs i.e. in a CoClientContext
might have the SessionId
of that context. But the real owner-id of the task is the SessionId
of the user that is logged in on the server!getOwnerSessionId
in interface RemoteTask<S extends ServerContext>
RemoteTask.getSessionId()
public SessionId getSessionId()
RemoteTask
SessionId
of the Session that submitted this taskgetSessionId
in interface RemoteTask<S extends ServerContext>
RemoteTask.getOwnerSessionId()
public SessionId getKillerSessionId()
RemoteCancellableTask
SessionId
of the one who cancelled this taskgetKillerSessionId
in interface RemoteCancellableTask
public RemoteTaskId getTaskId()
AsyncExecutable
TaskId
is used to model the task-hierarchy in a RunStateFlag
.
For AsyncExecutable
s it's always an instance of PseudoTaskId
.getTaskId
in interface AsyncExecutable<S extends ServerContext>
getTaskId
in interface TaskIdHolder
getTaskId
in interface RemoteTask<S extends ServerContext>
getTaskId
in class AbstractAsyncExecutable<S extends ServerContext>
Copyright © 2014 EsprIT-Systems. All Rights Reserved.