Package org.apache.mina.common
Class ExecutorThreadModel
- java.lang.Object
-
- org.apache.mina.common.ExecutorThreadModel
-
- All Implemented Interfaces:
IoFilterChainBuilder,ThreadModel
public class ExecutorThreadModel extends java.lang.Object implements ThreadModel
AThreadModelwhich represents a thread model with anExecutorper service. The default underlyingExecutorisThreadPoolExecutor, so you can safely downcast the returnedExecutorofgetExecutor()toThreadPoolExecutorby default.
-
-
Field Summary
-
Fields inherited from interface org.apache.mina.common.IoFilterChainBuilder
NOOP
-
Fields inherited from interface org.apache.mina.common.ThreadModel
MANUAL
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbuildFilterChain(IoFilterChain chain)Modifies the specified chain.java.util.concurrent.ExecutorgetExecutor()Returns the underlyingExecutorof this model.static ExecutorThreadModelgetInstance(java.lang.String serviceName)Returns aExecutorThreadModelinstance for the specified serviceName.voidsetExecutor(java.util.concurrent.Executor executor)Changes the underlyingExecutorof this model.
-
-
-
Method Detail
-
getInstance
public static ExecutorThreadModel getInstance(java.lang.String serviceName)
Returns aExecutorThreadModelinstance for the specified serviceName. Please note that all returned instances will be managed globally; the same instance will be returned if you specified the same service name. Please try to specify different names for different services.- Parameters:
serviceName- the name of the service that needs thread pooling
-
getExecutor
public java.util.concurrent.Executor getExecutor()
Returns the underlyingExecutorof this model. You can change various properties such as the number of threads by calling methods of theExecutorimplementation.
-
setExecutor
public void setExecutor(java.util.concurrent.Executor executor)
Changes the underlyingExecutorof this model. Previous settings such as the number of threads should be configured again. Only newly createdIoSessions will be affected.- Parameters:
executor- null to revert to the default setting
-
buildFilterChain
public void buildFilterChain(IoFilterChain chain) throws java.lang.Exception
Description copied from interface:IoFilterChainBuilderModifies the specified chain.- Specified by:
buildFilterChainin interfaceIoFilterChainBuilder- Throws:
java.lang.Exception
-
-