org.apache.mina.common
Class ExecutorThreadModel

java.lang.Object
  extended by org.apache.mina.common.ExecutorThreadModel
All Implemented Interfaces:
IoFilterChainBuilder, ThreadModel

public class ExecutorThreadModel
extends Object
implements ThreadModel

A ThreadModel which represents a thread model with an Executor per service. The default underlying Executor is ThreadPoolExecutor, so you can safely downcast the returned Executor of getExecutor() to ThreadPoolExecutor by default.

Version:
$Rev: 588150 $, $Date: 2007-10-25 08:20:04 +0200 (Thu, 25 Oct 2007) $
Author:
The Apache Directory Project (mina-dev@directory.apache.org)

Field Summary
 
Fields inherited from interface org.apache.mina.common.ThreadModel
MANUAL
 
Fields inherited from interface org.apache.mina.common.IoFilterChainBuilder
NOOP
 
Method Summary
 void buildFilterChain(IoFilterChain chain)
          Modifies the specified chain.
 Executor getExecutor()
          Returns the underlying Executor of this model.
static ExecutorThreadModel getInstance(String serviceName)
          Returns a ExecutorThreadModel instance for the specified serviceName.
 void setExecutor(Executor executor)
          Changes the underlying Executor of this model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ExecutorThreadModel getInstance(String serviceName)
Returns a ExecutorThreadModel 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 Executor getExecutor()
Returns the underlying Executor of this model. You can change various properties such as the number of threads by calling methods of the Executor implementation.


setExecutor

public void setExecutor(Executor executor)
Changes the underlying Executor of this model. Previous settings such as the number of threads should be configured again. Only newly created IoSessions will be affected.

Parameters:
executor - null to revert to the default setting

buildFilterChain

public void buildFilterChain(IoFilterChain chain)
                      throws Exception
Description copied from interface: IoFilterChainBuilder
Modifies the specified chain.

Specified by:
buildFilterChain in interface IoFilterChainBuilder
Throws:
Exception


Copyright © 2004-2010 Apache MINA Project. All Rights Reserved.