You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/11/11 11:51:00 UTC
svn commit: r1033878 -
/james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractAsyncServer.java
Author: norman
Date: Thu Nov 11 10:50:59 2010
New Revision: 1033878
URL: http://svn.apache.org/viewvc?rev=1033878&view=rev
Log:
Allow to override the Executor implementation to use (PROTOCOLS-9)
Modified:
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractAsyncServer.java
Modified: james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractAsyncServer.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractAsyncServer.java?rev=1033878&r1=1033877&r2=1033878&view=diff
==============================================================================
--- james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractAsyncServer.java (original)
+++ james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractAsyncServer.java Thu Nov 11 10:50:59 2010
@@ -19,6 +19,7 @@
package org.apache.james.protocols.impl;
import java.net.InetSocketAddress;
+import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import org.jboss.netty.bootstrap.ServerBootstrap;
@@ -49,7 +50,6 @@ public abstract class AbstractAsyncServe
private ChannelGroup channels = new DefaultChannelGroup();
private int ioWorker = Runtime.getRuntime().availableProcessors() * 2;
-
/**
* Set the ip on which the Server should listen on
@@ -102,7 +102,7 @@ public abstract class AbstractAsyncServe
if (port < 1) throw new RuntimeException("Please specify a port to which the server should get bound!");
- bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(), Executors.newCachedThreadPool(), ioWorker));
+ bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(createBossExecutor(), createWorkerExecutor(), ioWorker));
ChannelPipelineFactory factory = createPipelineFactory(channels);
// Configure the pipeline factory.
@@ -200,5 +200,23 @@ public abstract class AbstractAsyncServe
public synchronized int getTimeout() {
return timeout;
}
+
+ /**
+ * Create a new {@link Executor} used for dispatch messages to the workers. One Thread will be used per port which is bound.
+ * This can get overridden if needed, by default it use a {@link Executors#newCachedThreadPool()}
+ *
+ * @return bossExecutor
+ */
+ protected Executor createBossExecutor() {
+ return Executors.newCachedThreadPool();
+ }
+ /**
+ * Create a new {@link Executor} used for workers. This can get overridden if needed, by default it use a {@link Executors#newCachedThreadPool()}
+ *
+ * @return workerExecutor
+ */
+ protected Executor createWorkerExecutor() {
+ return Executors.newCachedThreadPool();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org