Class ServletContextTrackingExecutor
- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- java.util.concurrent.ThreadPoolExecutor
-
- pl.morgwai.base.utils.concurrent.TaskTrackingThreadPoolExecutor
-
- pl.morgwai.base.servlet.guice.scopes.ServletContextTrackingExecutor
-
- All Implemented Interfaces:
Executor
,ExecutorService
,TaskTrackingExecutor
,TaskTrackingExecutor.TaskTrackingExecutorDecorator.HookableExecutor
public class ServletContextTrackingExecutor extends TaskTrackingThreadPoolExecutor
TaskTrackingThreadPoolExecutor
that automatically transferContexts
to workerThreads
usingContextBinder
.Instances should usually be created using
ServletModule.newContextTrackingExecutor(...)
helper methods family, so that they are automatically terminated at the app shutdown.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy
-
Nested classes/interfaces inherited from interface pl.morgwai.base.utils.concurrent.TaskTrackingExecutor
TaskTrackingExecutor.TaskTrackingExecutorDecorator
-
-
Constructor Summary
Constructors Constructor Description ServletContextTrackingExecutor(String name, ContextBinder ctxBinder, int poolSize)
ServletContextTrackingExecutor(String name, ContextBinder ctxBinder, int poolSize, int queueSize)
ServletContextTrackingExecutor(String name, ContextBinder ctxBinder, int corePoolSize, int maxPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
ServletContextTrackingExecutor(String name, ContextBinder ctxBinder, int corePoolSize, int maxPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
execute(HttpServletResponse response, Runnable task)
Callsexecute(task)
and if it's rejected, sendsHttpServletResponse.SC_SERVICE_UNAVAILABLE
toresponse
.void
execute(Session connection, Runnable task)
Callsexecute(task)
and if it's rejected, closesconnection
withCloseReason.CloseCodes.TRY_AGAIN_LATER
.void
execute(Runnable task)
String
getName()
String
toString()
-
Methods inherited from class pl.morgwai.base.utils.concurrent.TaskTrackingThreadPoolExecutor
addAfterExecuteHook, addBeforeExecuteHook, afterExecute, beforeExecute, getRunningTasks
-
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated
-
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit
-
Methods inherited from interface pl.morgwai.base.utils.concurrent.TaskTrackingExecutor
awaitTermination, toAwaitableOfEnforcedTermination, toAwaitableOfTermination
-
-
-
-
Constructor Detail
-
ServletContextTrackingExecutor
public ServletContextTrackingExecutor(String name, ContextBinder ctxBinder, int poolSize)
-
ServletContextTrackingExecutor
public ServletContextTrackingExecutor(String name, ContextBinder ctxBinder, int corePoolSize, int maxPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory, RejectedExecutionHandler handler)
-
ServletContextTrackingExecutor
public ServletContextTrackingExecutor(String name, ContextBinder ctxBinder, int corePoolSize, int maxPoolSize, long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue, ThreadFactory threadFactory)
-
ServletContextTrackingExecutor
public ServletContextTrackingExecutor(String name, ContextBinder ctxBinder, int poolSize, int queueSize)
-
-
Method Detail
-
getName
public String getName()
-
execute
public void execute(Runnable task)
- Specified by:
execute
in interfaceExecutor
- Overrides:
execute
in classThreadPoolExecutor
-
execute
public void execute(HttpServletResponse response, Runnable task)
Callsexecute(task)
and if it's rejected, sendsHttpServletResponse.SC_SERVICE_UNAVAILABLE
toresponse
.
-
execute
public void execute(Session connection, Runnable task)
Callsexecute(task)
and if it's rejected, closesconnection
withCloseReason.CloseCodes.TRY_AGAIN_LATER
.
-
toString
public String toString()
- Overrides:
toString
in classThreadPoolExecutor
-
-