public class DefaultSessionTaskDispatcher extends DefaultTaskDispatcher implements SessionTaskDispatcher
Thread.State, Thread.UncaughtExceptionHandlerINSTANCE_COUNTERMAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
DefaultSessionTaskDispatcher(String name)
Creates a dispatcher to be configured later.
|
DefaultSessionTaskDispatcher(String name,
Session session,
boolean useMutexLocking,
long keepAliveMillis,
long deadInterval)
Creates an execution thread for a given session.
The session must not be used by any other thread! |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addTask(Task task)
Adds a task to the queue.
|
protected void |
cleanup() |
protected SessionTaskDispatcherLock |
createLock(Object key) |
Session |
getSession()
Gets the session.
|
boolean |
isSessionClosedOnTermination()
Returns whether the session should be closed on termination.
|
boolean |
isSessionKeptAlive()
Gets the keepalive flag.
|
void |
run() |
void |
setSession(Session session)
Sets the session.
|
void |
setSessionClosedOnTermination(boolean closeSessionOnTermination)
Sets whether the session should be closed on termination.
|
void |
setSessionKeptAlive(boolean sessionKeptAlive)
Sets the keepalive flag.
If set, setAlive() will be invoked periodically to keep the session alive. |
protected void |
unlockInternal(long sleepMs) |
addTaskAndWait, addTaskListener, assertAlive, assertIntervalsInRange, assertNotAlive, assertNotKilled, executeTask, fireCompleted, fireStarted, getAllTasks, getDeadInterval, getQueueSize, getShutdownIdleTimeout, getSleepInterval, getTask, getTerminationCause, interrupt, isDead, isInstanceOfTaskPending, isKilled, isQueueEmpty, isTaskDispatcherThread, isTaskPending, isTerminationRequested, isUsingMutexLocking, kill, lock, lockInternal, nextTask, removeTask, removeTaskListener, requestTermination, setDead, setDeadInterval, setShutdownIdleTimeout, setSleepInterval, setUsingMutexLocking, sleepForInterval, startedAt, terminate, terminatedAt, toDiagnosticString, unlock, waitForTaskactiveCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddTaskAndWait, addTaskListener, getAllTasks, getDeadInterval, getQueueSize, getShutdownIdleTimeout, getSleepInterval, getTask, isAlive, isInstanceOfTaskPending, isQueueEmpty, isTaskPending, isUsingMutexLocking, lock, removeTask, removeTaskListener, setDeadInterval, setShutdownIdleTimeout, setSleepInterval, setUsingMutexLocking, start, toDiagnosticString, unlock, waitForTaskisTerminationRequested, requestTermination, terminategetNamepublic DefaultSessionTaskDispatcher(String name, Session session, boolean useMutexLocking, long keepAliveMillis, long deadInterval)
name - the dispatcher's namesession - the open sessionuseMutexLocking - true use a mutex for locking, else just a counterkeepAliveMillis - keep alive in millisecondsdeadInterval - interval in milliseconds to detect a dead dispatcher, 0 to disable detectionpublic DefaultSessionTaskDispatcher(String name)
name - the dispatcher's namepublic void setSessionKeptAlive(boolean sessionKeptAlive)
SessionTaskDispatchersetSessionKeptAlive in interface SessionTaskDispatchersessionKeptAlive - true if ping enabledpublic boolean isSessionKeptAlive()
SessionTaskDispatcherisSessionKeptAlive in interface SessionTaskDispatcherpublic Session getSession()
SessionTaskDispatchergetSession in interface SessionTaskDispatcherpublic void setSession(Session session)
SessionTaskDispatchersetSession in interface SessionTaskDispatchersession - the sessionpublic boolean isSessionClosedOnTermination()
SessionTaskDispatcherisSessionClosedOnTermination in interface SessionTaskDispatcherpublic void setSessionClosedOnTermination(boolean closeSessionOnTermination)
SessionTaskDispatchersetSessionClosedOnTermination in interface SessionTaskDispatchercloseSessionOnTermination - true if should be closed, false if remains openprotected SessionTaskDispatcherLock createLock(Object key)
createLock in class DefaultTaskDispatcherpublic boolean addTask(Task task)
addTask in interface TaskDispatcheraddTask in class DefaultTaskDispatchertask - the task to addprotected void unlockInternal(long sleepMs)
Overridden to run Session.setAlive(boolean) when sleeping for a while.
unlockInternal in class DefaultTaskDispatcherpublic void run()
Overridden to set the thread-local session.
run in interface Runnablerun in class DefaultTaskDispatcherprotected void cleanup()
Overridden to close the session.
cleanup in class DefaultTaskDispatcherTentackle - distributed, domain- and model-driven