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
AThreadModel
which represents a thread model with anExecutor
per service. The default underlyingExecutor
isThreadPoolExecutor
, so you can safely downcast the returnedExecutor
ofgetExecutor()
toThreadPoolExecutor
by 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 void
buildFilterChain(IoFilterChain chain)
Modifies the specified chain.java.util.concurrent.Executor
getExecutor()
Returns the underlyingExecutor
of this model.static ExecutorThreadModel
getInstance(java.lang.String serviceName)
Returns aExecutorThreadModel
instance for the specified serviceName.void
setExecutor(java.util.concurrent.Executor executor)
Changes the underlyingExecutor
of this model.
-
-
-
Method Detail
-
getInstance
public static ExecutorThreadModel getInstance(java.lang.String serviceName)
Returns aExecutorThreadModel
instance 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 underlyingExecutor
of this model. You can change various properties such as the number of threads by calling methods of theExecutor
implementation.
-
setExecutor
public void setExecutor(java.util.concurrent.Executor executor)
Changes the underlyingExecutor
of this model. Previous settings such as the number of threads should be configured again. Only newly createdIoSession
s 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:IoFilterChainBuilder
Modifies the specified chain.- Specified by:
buildFilterChain
in interfaceIoFilterChainBuilder
- Throws:
java.lang.Exception
-
-