james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [17/20] james-project git commit: JAMES-2327 Use a single HashedWheelTimer in the whole application as recommended by its documentation
Date Thu, 01 Feb 2018 10:44:50 GMT
JAMES-2327 Use a single HashedWheelTimer in the whole application as recommended by its documentation


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/73a320b0
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/73a320b0
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/73a320b0

Branch: refs/heads/master
Commit: 73a320b04f43c04e911a79d4b6f1e603eb4230e8
Parents: 379d1eb
Author: Matthieu Baechler <matthieu@apache.org>
Authored: Tue Jan 30 10:24:51 2018 +0100
Committer: benwa <btellier@linagora.com>
Committed: Thu Feb 1 17:42:29 2018 +0700

----------------------------------------------------------------------
 pom.xml                                         |  5 ++
 .../lmtp/netty/NettyLMTPSServerTest.java        | 17 +++++-
 .../lmtp/netty/NettyLMTPServerTest.java         | 17 +++++-
 .../netty/AbstractChannelPipelineFactory.java   | 27 ++++-----
 .../AbstractSSLAwareChannelPipelineFactory.java | 11 ++--
 .../james/protocols/netty/NettyServer.java      | 39 ++++++++----
 .../james/protocols/netty/NettyServerTest.java  | 24 ++++++--
 .../pop3/netty/NettyPOP3SServerTest.java        | 17 +++++-
 .../pop3/netty/NettyPOP3ServerTest.java         | 18 +++++-
 .../pop3/netty/NettyStartTlsPOP3ServerTest.java | 18 +++++-
 .../smtp/netty/NettySMTPSServerTest.java        | 17 +++++-
 .../smtp/netty/NettySMTPServerTest.java         | 18 +++++-
 .../smtp/netty/NettyStartTlsSMTPServerTest.java | 12 +++-
 server/container/guice/guice-common/pom.xml     |  4 ++
 .../protocols/ProtocolHandlerModule.java        |  1 +
 server/container/guice/pom.xml                  |  1 +
 server/container/guice/protocols/netty/pom.xml  | 63 ++++++++++++++++++++
 .../modules/protocols/NettyServerModule.java    | 45 ++++++++++++++
 .../META-INF/org/apache/james/spring-server.xml |  2 +
 .../imapserver/netty/IMAPServerFactory.java     |  7 ++-
 .../imapserver/netty/OioIMAPServerFactory.java  |  6 +-
 .../netty/AbstractConfigurableAsyncServer.java  | 10 +++-
 ...ractExecutorAwareChannelPipelineFactory.java | 15 +++--
 .../lmtpserver/netty/LMTPServerFactory.java     |  7 ++-
 .../lmtpserver/netty/OioLMTPServerFactory.java  |  6 +-
 .../netty/ManageSieveServerFactory.java         |  9 +++
 .../pop3server/netty/POP3ServerFactory.java     | 10 +++-
 .../apache/james/pop3server/POP3ServerTest.java |  5 ++
 .../smtpserver/netty/OioSMTPServerFactory.java  |  6 +-
 .../smtpserver/netty/SMTPServerFactory.java     |  7 ++-
 .../apache/james/smtpserver/SMTPServerTest.java |  7 ++-
 .../james/smtpserver/ValidRcptMXTest.java       |  2 +-
 32 files changed, 388 insertions(+), 65 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 797c3e1..b3ec971 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1171,6 +1171,11 @@
             </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
+                <artifactId>james-server-guice-netty</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>${project.groupId}</groupId>
                 <artifactId>james-server-jetty</artifactId>
                 <version>${project.version}</version>
             </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/netty/NettyLMTPSServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/netty/NettyLMTPSServerTest.java b/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/netty/NettyLMTPSServerTest.java
index 529bf08..5fbf322 100644
--- a/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/netty/NettyLMTPSServerTest.java
+++ b/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/netty/NettyLMTPSServerTest.java
@@ -8,15 +8,30 @@ import org.apache.james.protocols.api.ProtocolServer;
 import org.apache.james.protocols.api.utils.BogusSslContextFactory;
 import org.apache.james.protocols.lmtp.AbstractLMTPSServerTest;
 import org.apache.james.protocols.netty.NettyServer;
+import org.jboss.netty.util.HashedWheelTimer;
+import org.junit.After;
+import org.junit.Before;
 
 public class NettyLMTPSServerTest extends AbstractLMTPSServerTest {
 
     private static final String LOCALHOST_IP = "127.0.0.1";
     private static final int RANDOM_PORT = 0;
 
+    private HashedWheelTimer hashedWheelTimer;
+
+    @Before
+    public void setup() {
+        hashedWheelTimer = new HashedWheelTimer();
+    }
+
+    @After
+    public void teardown() {
+        hashedWheelTimer.stop();
+    }
+
     @Override
     protected ProtocolServer createServer(Protocol protocol) {
-        NettyServer server =  NettyServer.builder()
+        NettyServer server = new NettyServer.Factory(hashedWheelTimer)
                 .protocol(protocol)
                 .secure(Encryption.createTls(BogusSslContextFactory.getServerContext()))
                 .build();

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/netty/NettyLMTPServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/netty/NettyLMTPServerTest.java b/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/netty/NettyLMTPServerTest.java
index b45c19e..30e7716 100644
--- a/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/netty/NettyLMTPServerTest.java
+++ b/protocols/lmtp/src/test/java/org/apache/james/protocols/lmtp/netty/NettyLMTPServerTest.java
@@ -24,15 +24,30 @@ import org.apache.james.protocols.api.Protocol;
 import org.apache.james.protocols.api.ProtocolServer;
 import org.apache.james.protocols.lmtp.AbstractLMTPServerTest;
 import org.apache.james.protocols.netty.NettyServer;
+import org.jboss.netty.util.HashedWheelTimer;
+import org.junit.After;
+import org.junit.Before;
 
 public class NettyLMTPServerTest extends AbstractLMTPServerTest {
 
     private static final String LOCALHOST_IP = "127.0.0.1";
     private static final int RANDOM_PORT = 0;
 
+    private HashedWheelTimer hashedWheelTimer;
+
+    @Before
+    public void setup() {
+        hashedWheelTimer = new HashedWheelTimer();
+    }
+
+    @After
+    public void teardown() {
+        hashedWheelTimer.stop();
+    }
+
     @Override
     protected ProtocolServer createServer(Protocol protocol) {
-        NettyServer server = NettyServer.builder()
+        NettyServer server = new NettyServer.Factory(hashedWheelTimer)
                 .protocol(protocol)
                 .build();
         server.setListenAddresses(new InetSocketAddress(LOCALHOST_IP, RANDOM_PORT));

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractChannelPipelineFactory.java
----------------------------------------------------------------------
diff --git a/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractChannelPipelineFactory.java b/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractChannelPipelineFactory.java
index f4452c3..4de5f3e 100644
--- a/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractChannelPipelineFactory.java
+++ b/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractChannelPipelineFactory.java
@@ -26,7 +26,6 @@ import org.jboss.netty.channel.ChannelUpstreamHandler;
 import org.jboss.netty.channel.group.ChannelGroup;
 import org.jboss.netty.handler.execution.ExecutionHandler;
 import org.jboss.netty.handler.stream.ChunkedWriteHandler;
-import org.jboss.netty.util.ExternalResourceReleasable;
 import org.jboss.netty.util.HashedWheelTimer;
 
 /**
@@ -34,29 +33,33 @@ import org.jboss.netty.util.HashedWheelTimer;
  * 
  *
  */
-public abstract class AbstractChannelPipelineFactory implements ChannelPipelineFactory, ExternalResourceReleasable {
+public abstract class AbstractChannelPipelineFactory implements ChannelPipelineFactory {
     public static final int MAX_LINE_LENGTH = 8192;
 
     protected final ConnectionLimitUpstreamHandler connectionLimitHandler;
     protected final ConnectionPerIpLimitUpstreamHandler connectionPerIpLimitHandler;
-    private final HashedWheelTimer timer = new HashedWheelTimer();
+    private final HashedWheelTimer timer;
     private final ChannelGroupHandler groupHandler;
     private final int timeout;
     private final ExecutionHandler eHandler;
     private final ChannelHandlerFactory frameHandlerFactory;
-    
-    public AbstractChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp, ChannelGroup channels) {
-        this(timeout, maxConnections, maxConnectsPerIp, channels, null, new LineDelimiterBasedChannelHandlerFactory(MAX_LINE_LENGTH));
+
+    public AbstractChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp, ChannelGroup channels,
+                                          HashedWheelTimer hashedWheelTimer) {
+        this(timeout, maxConnections, maxConnectsPerIp, channels, null,
+            new LineDelimiterBasedChannelHandlerFactory(MAX_LINE_LENGTH), hashedWheelTimer);
     }
     
-    public AbstractChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp, ChannelGroup channels, ExecutionHandler eHandler,
-            ChannelHandlerFactory frameHandlerFactory) {
+    public AbstractChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp, ChannelGroup channels,
+                                          ExecutionHandler eHandler, ChannelHandlerFactory frameHandlerFactory,
+                                          HashedWheelTimer hashedWheelTimer) {
         this.connectionLimitHandler = new ConnectionLimitUpstreamHandler(maxConnections);
         this.connectionPerIpLimitHandler = new ConnectionPerIpLimitUpstreamHandler(maxConnectsPerIp);
         this.groupHandler = new ChannelGroupHandler(channels);
         this.timeout = timeout;
         this.eHandler = eHandler;
         this.frameHandlerFactory = frameHandlerFactory;
+        this.timer = hashedWheelTimer;
     }
     
     
@@ -98,12 +101,4 @@ public abstract class AbstractChannelPipelineFactory implements ChannelPipelineF
      */
     protected abstract ChannelUpstreamHandler createHandler();
 
-    
-    /*
-     * (non-Javadoc)
-     * @see org.jboss.netty.util.ExternalResourceReleasable#releaseExternalResources()
-     */
-    public void releaseExternalResources() {
-        timer.stop();
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractSSLAwareChannelPipelineFactory.java
----------------------------------------------------------------------
diff --git a/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractSSLAwareChannelPipelineFactory.java b/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractSSLAwareChannelPipelineFactory.java
index bc8269a..8039dc7 100644
--- a/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractSSLAwareChannelPipelineFactory.java
+++ b/protocols/netty/src/main/java/org/apache/james/protocols/netty/AbstractSSLAwareChannelPipelineFactory.java
@@ -25,6 +25,7 @@ import org.jboss.netty.channel.ChannelPipeline;
 import org.jboss.netty.channel.group.ChannelGroup;
 import org.jboss.netty.handler.execution.ExecutionHandler;
 import org.jboss.netty.handler.ssl.SslHandler;
+import org.jboss.netty.util.HashedWheelTimer;
 
 /**
  * Abstract base class for {@link ChannelPipeline} implementations which use TLS 
@@ -37,15 +38,15 @@ public abstract class AbstractSSLAwareChannelPipelineFactory extends AbstractCha
     private String[] enabledCipherSuites = null;
 
     public AbstractSSLAwareChannelPipelineFactory(int timeout,
-            int maxConnections, int maxConnectsPerIp, ChannelGroup group, ExecutionHandler eHandler,
-            ChannelHandlerFactory frameHandlerFactory) {
-        super(timeout, maxConnections, maxConnectsPerIp, group, eHandler, frameHandlerFactory);
+                                                  int maxConnections, int maxConnectsPerIp, ChannelGroup group, ExecutionHandler eHandler,
+                                                  ChannelHandlerFactory frameHandlerFactory, HashedWheelTimer hashedWheelTimer) {
+        super(timeout, maxConnections, maxConnectsPerIp, group, eHandler, frameHandlerFactory, hashedWheelTimer);
     }
 
     public AbstractSSLAwareChannelPipelineFactory(int timeout,
             int maxConnections, int maxConnectsPerIp, ChannelGroup group, String[] enabledCipherSuites, ExecutionHandler eHandler,
-            ChannelHandlerFactory frameHandlerFactory) {
-        this(timeout, maxConnections, maxConnectsPerIp, group, eHandler, frameHandlerFactory);
+            ChannelHandlerFactory frameHandlerFactory, HashedWheelTimer hashedWheelTimer) {
+        this(timeout, maxConnections, maxConnectsPerIp, group, eHandler, frameHandlerFactory, hashedWheelTimer);
         
         // We need to copy the String array becuase of possible security issues.
         // See https://issues.apache.org/jira/browse/PROTOCOLS-18

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyServer.java
----------------------------------------------------------------------
diff --git a/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyServer.java b/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyServer.java
index faa4624..ed8dea6 100644
--- a/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyServer.java
+++ b/protocols/netty/src/main/java/org/apache/james/protocols/netty/NettyServer.java
@@ -20,6 +20,7 @@ package org.apache.james.protocols.netty;
 
 import java.util.Optional;
 
+import javax.inject.Inject;
 import javax.net.ssl.SSLContext;
 
 import org.apache.james.protocols.api.Encryption;
@@ -30,6 +31,7 @@ import org.jboss.netty.channel.ChannelUpstreamHandler;
 import org.jboss.netty.channel.group.ChannelGroup;
 import org.jboss.netty.handler.execution.ExecutionHandler;
 import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
+import org.jboss.netty.util.HashedWheelTimer;
 
 import com.google.common.base.Preconditions;
 
@@ -39,32 +41,33 @@ import com.google.common.base.Preconditions;
  */
 public class NettyServer extends AbstractAsyncServer {
 
-    public static Builder builder() {
-        return new Builder();
-    }
+    public static class Factory {
+
+        private final HashedWheelTimer hashedWheelTimer;
 
-    public static class Builder {
         private Protocol protocol;
         private Optional<Encryption> secure;
         private Optional<ChannelHandlerFactory> frameHandlerFactory;
 
-        private Builder() {
+        @Inject
+        public Factory(HashedWheelTimer hashedWheelTimer) {
+            this.hashedWheelTimer = hashedWheelTimer;
             secure = Optional.empty();
             frameHandlerFactory = Optional.empty();
         }
 
-        public Builder protocol(Protocol protocol) {
+        public Factory protocol(Protocol protocol) {
             Preconditions.checkNotNull(protocol, "'protocol' is mandatory");
             this.protocol = protocol;
             return this;
         }
 
-        public Builder secure(Encryption secure) {
+        public Factory secure(Encryption secure) {
             this.secure = Optional.ofNullable(secure);
             return this;
         }
 
-        public Builder frameHandlerFactory(ChannelHandlerFactory frameHandlerFactory) {
+        public Factory frameHandlerFactory(ChannelHandlerFactory frameHandlerFactory) {
             this.frameHandlerFactory = Optional.ofNullable(frameHandlerFactory);
             return this;
         }
@@ -73,14 +76,16 @@ public class NettyServer extends AbstractAsyncServer {
             Preconditions.checkState(protocol != null, "'protocol' is mandatory");
             return new NettyServer(protocol, 
                     secure.orElse(null),
-                    frameHandlerFactory.orElse(new LineDelimiterBasedChannelHandlerFactory(AbstractChannelPipelineFactory.MAX_LINE_LENGTH)));
+                    frameHandlerFactory.orElse(new LineDelimiterBasedChannelHandlerFactory(AbstractChannelPipelineFactory.MAX_LINE_LENGTH)),
+                    hashedWheelTimer);
         }
     }
 
-    protected final Protocol protocol;
     protected final Encryption secure;
+    protected final Protocol protocol;
     private final ChannelHandlerFactory frameHandlerFactory;
-    
+    private final HashedWheelTimer hashedWheelTimer;
+
     private ExecutionHandler eHandler;
     
     private ChannelUpstreamHandler coreHandler;
@@ -89,10 +94,11 @@ public class NettyServer extends AbstractAsyncServer {
 
     private int maxCurConnectionsPerIP;
    
-    private NettyServer(Protocol protocol, Encryption secure, ChannelHandlerFactory frameHandlerFactory) {
+    private NettyServer(Protocol protocol, Encryption secure, ChannelHandlerFactory frameHandlerFactory, HashedWheelTimer hashedWheelTimer) {
         this.protocol = protocol;
         this.secure = secure;
         this.frameHandlerFactory = frameHandlerFactory;
+        this.hashedWheelTimer = hashedWheelTimer;
     }
     
     protected ExecutionHandler createExecutionHandler(int size) {
@@ -151,7 +157,14 @@ public class NettyServer extends AbstractAsyncServer {
     @Override
     protected ChannelPipelineFactory createPipelineFactory(ChannelGroup group) {
 
-        return new AbstractSSLAwareChannelPipelineFactory(getTimeout(), maxCurConnections, maxCurConnectionsPerIP, group, eHandler, getFrameHandlerFactory()) {
+        return new AbstractSSLAwareChannelPipelineFactory(
+            getTimeout(),
+            maxCurConnections,
+            maxCurConnectionsPerIP,
+            group,
+            eHandler,
+            getFrameHandlerFactory(),
+            hashedWheelTimer) {
 
             @Override
             protected ChannelUpstreamHandler createHandler() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/protocols/netty/src/test/java/org/apache/james/protocols/netty/NettyServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/netty/src/test/java/org/apache/james/protocols/netty/NettyServerTest.java b/protocols/netty/src/test/java/org/apache/james/protocols/netty/NettyServerTest.java
index facb52f..2b1d9cd 100644
--- a/protocols/netty/src/test/java/org/apache/james/protocols/netty/NettyServerTest.java
+++ b/protocols/netty/src/test/java/org/apache/james/protocols/netty/NettyServerTest.java
@@ -25,6 +25,9 @@ import javax.net.ssl.SSLContext;
 
 import org.apache.james.protocols.api.Encryption;
 import org.apache.james.protocols.api.Protocol;
+import org.jboss.netty.util.HashedWheelTimer;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -34,24 +37,35 @@ public class NettyServerTest {
     @Rule
     public ExpectedException expectedException = ExpectedException.none();
 
+    private HashedWheelTimer hashedWheelTimer;
+
+    @Before
+    public void setup() {
+        hashedWheelTimer = new HashedWheelTimer();
+    }
+
+    @After
+    public void teardown() {
+        hashedWheelTimer.stop();
+    }
+
     @Test
     public void protocolShouldThrowWhenProtocolIsNull() {
         expectedException.expect(NullPointerException.class);
-        NettyServer.builder()
-            .protocol(null);
+        new NettyServer.Factory(hashedWheelTimer).protocol(null);
     }
 
     @Test
     public void buildShouldThrowWhenProtocolIsNotGiven() {
         expectedException.expect(IllegalStateException.class);
-        NettyServer.builder()
+        new NettyServer.Factory(hashedWheelTimer)
             .build();
     }
 
     @Test
     public void buildShouldWorkWhenProtocolIsGiven() {
         Protocol protocol = mock(Protocol.class);
-        NettyServer.builder()
+        new NettyServer.Factory(hashedWheelTimer)
             .protocol(protocol)
             .build();
     }
@@ -61,7 +75,7 @@ public class NettyServerTest {
         Protocol protocol = mock(Protocol.class);
         Encryption encryption = Encryption.createStartTls(SSLContext.getDefault());
         ChannelHandlerFactory channelHandlerFactory = mock(ChannelHandlerFactory.class);
-        NettyServer.builder()
+        new NettyServer.Factory(hashedWheelTimer)
             .protocol(protocol)
             .secure(encryption)
             .frameHandlerFactory(channelHandlerFactory)

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyPOP3SServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyPOP3SServerTest.java b/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyPOP3SServerTest.java
index b3bf155..3d85f27 100644
--- a/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyPOP3SServerTest.java
+++ b/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyPOP3SServerTest.java
@@ -25,15 +25,30 @@ import org.apache.james.protocols.api.Protocol;
 import org.apache.james.protocols.api.ProtocolServer;
 import org.apache.james.protocols.netty.NettyServer;
 import org.apache.james.protocols.pop3.AbstractPOP3SServerTest;
+import org.jboss.netty.util.HashedWheelTimer;
+import org.junit.After;
+import org.junit.Before;
 
 public class NettyPOP3SServerTest extends AbstractPOP3SServerTest {
 
     private static final String LOCALHOST_IP = "127.0.0.1";
     private static final int RANDOM_PORT = 0;
 
+    private HashedWheelTimer hashedWheelTimer;
+
+    @Before
+    public void setup() {
+        hashedWheelTimer = new HashedWheelTimer();
+    }
+
+    @After
+    public void teardown() {
+        hashedWheelTimer.stop();
+    }
+
     @Override
     protected ProtocolServer createEncryptedServer(Protocol protocol, Encryption enc) {
-        NettyServer server = NettyServer.builder()
+        NettyServer server = new NettyServer.Factory(hashedWheelTimer)
                 .protocol(protocol)
                 .secure(enc)
                 .build();

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyPOP3ServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyPOP3ServerTest.java b/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyPOP3ServerTest.java
index 9a49dd0..052214a 100644
--- a/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyPOP3ServerTest.java
+++ b/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyPOP3ServerTest.java
@@ -24,15 +24,31 @@ import org.apache.james.protocols.api.Protocol;
 import org.apache.james.protocols.api.ProtocolServer;
 import org.apache.james.protocols.netty.NettyServer;
 import org.apache.james.protocols.pop3.AbstractPOP3ServerTest;
+import org.jboss.netty.util.HashedWheelTimer;
+import org.junit.After;
+import org.junit.Before;
 
 public class NettyPOP3ServerTest extends AbstractPOP3ServerTest {
 
     private static final String LOCALHOST_IP = "127.0.0.1";
     private static final int RANDOM_PORT = 0;
 
+    private HashedWheelTimer hashedWheelTimer;
+
+    @Before
+    public void setup() {
+        hashedWheelTimer = new HashedWheelTimer();
+    }
+
+    @After
+    public void teardown() {
+        hashedWheelTimer.stop();
+    }
+
+
     @Override
     protected ProtocolServer createServer(Protocol protocol) {
-        NettyServer server =  NettyServer.builder()
+        NettyServer server =  new NettyServer.Factory(hashedWheelTimer)
                 .protocol(protocol)
                 .build();
         server.setListenAddresses(new InetSocketAddress(LOCALHOST_IP, RANDOM_PORT));

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyStartTlsPOP3ServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyStartTlsPOP3ServerTest.java b/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyStartTlsPOP3ServerTest.java
index b6ec5ca..934952d 100644
--- a/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyStartTlsPOP3ServerTest.java
+++ b/protocols/pop3/src/test/java/org/apache/james/protocols/pop3/netty/NettyStartTlsPOP3ServerTest.java
@@ -25,12 +25,28 @@ import org.apache.james.protocols.api.Protocol;
 import org.apache.james.protocols.api.ProtocolServer;
 import org.apache.james.protocols.netty.NettyServer;
 import org.apache.james.protocols.pop3.AbstractStartTlsPOP3ServerTest;
+import org.jboss.netty.util.HashedWheelTimer;
+import org.junit.After;
+import org.junit.Before;
 
 public class NettyStartTlsPOP3ServerTest extends AbstractStartTlsPOP3ServerTest {
 
+    private HashedWheelTimer hashedWheelTimer;
+
+    @Before
+    public void setup() {
+        hashedWheelTimer = new HashedWheelTimer();
+    }
+
+    @After
+    public void teardown() {
+        hashedWheelTimer.stop();
+    }
+
+
     @Override
     protected ProtocolServer createServer(Protocol protocol, InetSocketAddress address, Encryption enc) {
-        NettyServer server = NettyServer.builder()
+        NettyServer server = new NettyServer.Factory(hashedWheelTimer)
                 .protocol(protocol)
                 .secure(enc)
                 .build();

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettySMTPSServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettySMTPSServerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettySMTPSServerTest.java
index 2b90ec2..b14b568 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettySMTPSServerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettySMTPSServerTest.java
@@ -25,6 +25,9 @@ import org.apache.james.protocols.api.Protocol;
 import org.apache.james.protocols.api.ProtocolServer;
 import org.apache.james.protocols.netty.NettyServer;
 import org.apache.james.protocols.smtp.AbstractSMTPSServerTest;
+import org.jboss.netty.util.HashedWheelTimer;
+import org.junit.After;
+import org.junit.Before;
 
 /**
  * Integration tests which use netty implementation
@@ -36,9 +39,21 @@ public class NettySMTPSServerTest extends AbstractSMTPSServerTest {
     private static final String LOCALHOST_IP = "127.0.0.1";
     private static final int RANDOM_PORT = 0;
 
+    private HashedWheelTimer hashedWheelTimer;
+
+    @Before
+    public void setup() {
+        hashedWheelTimer = new HashedWheelTimer();
+    }
+
+    @After
+    public void teardown() {
+        hashedWheelTimer.stop();
+    }
+
     @Override
     protected ProtocolServer createEncryptedServer(Protocol protocol, Encryption enc) {
-        NettyServer server = NettyServer.builder()
+        NettyServer server = new NettyServer.Factory(hashedWheelTimer)
                 .protocol(protocol)
                 .secure(enc)
                 .build();

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettySMTPServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettySMTPServerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettySMTPServerTest.java
index 8ae4b0a..3adeb44 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettySMTPServerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettySMTPServerTest.java
@@ -24,6 +24,9 @@ import org.apache.james.protocols.api.Protocol;
 import org.apache.james.protocols.api.ProtocolServer;
 import org.apache.james.protocols.netty.NettyServer;
 import org.apache.james.protocols.smtp.AbstractSMTPServerTest;
+import org.jboss.netty.util.HashedWheelTimer;
+import org.junit.After;
+import org.junit.Before;
 
 /**
  * Integration tests which use netty implementation
@@ -35,9 +38,22 @@ public class NettySMTPServerTest extends AbstractSMTPServerTest {
     private static final String LOCALHOST_IP = "127.0.0.1";
     private static final int RANDOM_PORT = 0;
 
+    private HashedWheelTimer hashedWheelTimer;
+
+    @Before
+    public void setup() {
+        hashedWheelTimer = new HashedWheelTimer();
+    }
+
+    @After
+    public void teardown() {
+        hashedWheelTimer.stop();
+    }
+
+
     @Override
     protected ProtocolServer createServer(Protocol protocol) {
-        NettyServer server = NettyServer.builder()
+        NettyServer server = new NettyServer.Factory(hashedWheelTimer)
                 .protocol(protocol)
                 .build();
         server.setListenAddresses(new InetSocketAddress(LOCALHOST_IP, RANDOM_PORT));

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettyStartTlsSMTPServerTest.java
----------------------------------------------------------------------
diff --git a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettyStartTlsSMTPServerTest.java b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettyStartTlsSMTPServerTest.java
index 996f69b..8ef21c1 100644
--- a/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettyStartTlsSMTPServerTest.java
+++ b/protocols/smtp/src/test/java/org/apache/james/protocols/smtp/netty/NettyStartTlsSMTPServerTest.java
@@ -52,7 +52,9 @@ import org.apache.james.protocols.smtp.SMTPProtocol;
 import org.apache.james.protocols.smtp.SMTPProtocolHandlerChain;
 import org.apache.james.protocols.smtp.utils.TestMessageHook;
 import org.assertj.core.api.AssertDelegateTarget;
+import org.jboss.netty.util.HashedWheelTimer;
 import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 
 import com.sun.mail.smtp.SMTPTransport;
@@ -64,6 +66,12 @@ public class NettyStartTlsSMTPServerTest {
 
     private SMTPSClient smtpsClient = null;
     private ProtocolServer server = null;
+    private HashedWheelTimer hashedWheelTimer;
+
+    @Before
+    public void setup() {
+        hashedWheelTimer = new HashedWheelTimer();
+    }
 
     @After
     public void tearDown() throws Exception {
@@ -73,11 +81,11 @@ public class NettyStartTlsSMTPServerTest {
         if (server != null) {
             server.unbind();
         }
+        hashedWheelTimer.stop();
     }
 
-
     private ProtocolServer createServer(Protocol protocol, Encryption enc) {
-        NettyServer server = NettyServer.builder()
+        NettyServer server = new NettyServer.Factory(hashedWheelTimer)
                 .protocol(protocol)
                 .secure(enc)
                 .frameHandlerFactory(new AllButStartTlsLineChannelHandlerFactory(AbstractChannelPipelineFactory.MAX_LINE_LENGTH))

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/container/guice/guice-common/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/pom.xml b/server/container/guice/guice-common/pom.xml
index 45f6696..d36ffdc 100644
--- a/server/container/guice/guice-common/pom.xml
+++ b/server/container/guice/guice-common/pom.xml
@@ -90,6 +90,10 @@
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-netty</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>james-server-guice-pop</artifactId>
             <scope>test</scope>
         </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
index 10d20d2..51f5bf9 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
@@ -28,6 +28,7 @@ public class ProtocolHandlerModule extends AbstractModule {
 
     @Override
     protected void configure() {
+        install(new NettyServerModule());
         bind(ProtocolHandlerLoader.class).to(GuiceProtocolHandlerLoader.class);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/container/guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/pom.xml b/server/container/guice/pom.xml
index 61efd7b..4b1dda7 100644
--- a/server/container/guice/pom.xml
+++ b/server/container/guice/pom.xml
@@ -51,6 +51,7 @@
         <module>protocols/jmap</module>
         <module>protocols/lmtp</module>
         <module>protocols/managedsieve</module>
+        <module>protocols/netty</module>
         <module>protocols/pop</module>
         <module>protocols/smtp</module>
         <module>protocols/webadmin</module>

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/container/guice/protocols/netty/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/netty/pom.xml b/server/container/guice/protocols/netty/pom.xml
new file mode 100644
index 0000000..ceea4b1
--- /dev/null
+++ b/server/container/guice/protocols/netty/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements. See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership. The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied. See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.james</groupId>
+        <artifactId>james-server-guice</artifactId>
+        <version>3.1.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>james-server-guice-netty</artifactId>
+
+    <name>Apache James :: Server :: Guice :: Netty</name>
+    <description>Netty modules for Guice implementation of James server</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-configuration</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}.protocols</groupId>
+            <artifactId>protocols-netty</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.inject</groupId>
+            <artifactId>guice</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.inject.extensions</groupId>
+            <artifactId>guice-multibindings</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/container/guice/protocols/netty/src/main/java/org/apache/james/modules/protocols/NettyServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/netty/src/main/java/org/apache/james/modules/protocols/NettyServerModule.java b/server/container/guice/protocols/netty/src/main/java/org/apache/james/modules/protocols/NettyServerModule.java
new file mode 100644
index 0000000..92a12e9
--- /dev/null
+++ b/server/container/guice/protocols/netty/src/main/java/org/apache/james/modules/protocols/NettyServerModule.java
@@ -0,0 +1,45 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.protocols;
+
+import javax.annotation.PreDestroy;
+
+import org.jboss.netty.util.HashedWheelTimer;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Singleton;
+
+public class NettyServerModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        bind(HashedWheelTimer.class).to(DisposableHashedWheelTimer.class);
+    }
+
+    @Singleton
+    static class DisposableHashedWheelTimer extends HashedWheelTimer {
+
+        @PreDestroy
+        public void dispose() {
+            stop();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
----------------------------------------------------------------------
diff --git a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
index 322c4c6..f98eae7 100644
--- a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
+++ b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml
@@ -98,6 +98,8 @@
     ===========================================================================
     -->
 
+    <bean class="org.jboss.netty.util.HashedWheelTimer"/>
+
     <!-- SMTP Server -->
     <import resource="classpath:META-INF/spring/smtpserver-context.xml"/>
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServerFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServerFactory.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServerFactory.java
index 01bf9d8..d96a213 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServerFactory.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/IMAPServerFactory.java
@@ -31,6 +31,7 @@ import org.apache.james.imap.encode.ImapEncoder;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.protocols.lib.netty.AbstractConfigurableAsyncServer;
 import org.apache.james.protocols.lib.netty.AbstractServerFactory;
+import org.jboss.netty.util.HashedWheelTimer;
 
 public class IMAPServerFactory extends AbstractServerFactory {
 
@@ -39,14 +40,17 @@ public class IMAPServerFactory extends AbstractServerFactory {
     protected final ImapEncoder encoder;
     protected final ImapProcessor processor;
     protected final ImapMetrics imapMetrics;
+    private final HashedWheelTimer hashedWheelTimer;
 
     @Inject
-    public IMAPServerFactory(FileSystem fileSystem, ImapDecoder decoder, ImapEncoder encoder, ImapProcessor processor, MetricFactory metricFactory) {
+    public IMAPServerFactory(FileSystem fileSystem, ImapDecoder decoder, ImapEncoder encoder, ImapProcessor processor,
+                             MetricFactory metricFactory, HashedWheelTimer hashedWheelTimer) {
         this.fileSystem = fileSystem;
         this.decoder = decoder;
         this.encoder = encoder;
         this.processor = processor;
         this.imapMetrics = new ImapMetrics(metricFactory);
+        this.hashedWheelTimer = hashedWheelTimer;
     }
 
     protected IMAPServer createServer() {
@@ -62,6 +66,7 @@ public class IMAPServerFactory extends AbstractServerFactory {
         for (HierarchicalConfiguration serverConfig: configs) {
             IMAPServer server = createServer();
             server.setFileSystem(fileSystem);
+            server.setHashWheelTimer(hashedWheelTimer);
             server.configure(serverConfig);
             servers.add(server);
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/OioIMAPServerFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/OioIMAPServerFactory.java b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/OioIMAPServerFactory.java
index 5b6a12a..32893fc 100644
--- a/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/OioIMAPServerFactory.java
+++ b/server/protocols/protocols-imap4/src/main/java/org/apache/james/imapserver/netty/OioIMAPServerFactory.java
@@ -25,12 +25,14 @@ import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.decode.ImapDecoder;
 import org.apache.james.imap.encode.ImapEncoder;
 import org.apache.james.metrics.api.MetricFactory;
+import org.jboss.netty.util.HashedWheelTimer;
 
 public class OioIMAPServerFactory extends IMAPServerFactory {
 
     @Inject
-    public OioIMAPServerFactory(FileSystem fileSystem, ImapDecoder decoder, ImapEncoder encoder, ImapProcessor processor, MetricFactory metricFactory) {
-        super(fileSystem, decoder, encoder, processor, metricFactory);
+    public OioIMAPServerFactory(FileSystem fileSystem, ImapDecoder decoder, ImapEncoder encoder, ImapProcessor processor,
+                                MetricFactory metricFactory, HashedWheelTimer hashedWheelTimer) {
+        super(fileSystem, decoder, encoder, processor, metricFactory, hashedWheelTimer);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-library/src/main/java/org/apache/james/protocols/lib/netty/AbstractConfigurableAsyncServer.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-library/src/main/java/org/apache/james/protocols/lib/netty/AbstractConfigurableAsyncServer.java b/server/protocols/protocols-library/src/main/java/org/apache/james/protocols/lib/netty/AbstractConfigurableAsyncServer.java
index 3599526..5eed459 100644
--- a/server/protocols/protocols-library/src/main/java/org/apache/james/protocols/lib/netty/AbstractConfigurableAsyncServer.java
+++ b/server/protocols/protocols-library/src/main/java/org/apache/james/protocols/lib/netty/AbstractConfigurableAsyncServer.java
@@ -51,6 +51,7 @@ import org.jboss.netty.channel.ChannelPipelineFactory;
 import org.jboss.netty.channel.ChannelUpstreamHandler;
 import org.jboss.netty.channel.group.ChannelGroup;
 import org.jboss.netty.handler.execution.ExecutionHandler;
+import org.jboss.netty.util.HashedWheelTimer;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -86,6 +87,7 @@ public abstract class AbstractConfigurableAsyncServer extends AbstractAsyncServe
     private String x509Algorithm = defaultX509algorithm;
 
     private FileSystem fileSystem;
+    private HashedWheelTimer timer;
 
     private boolean enabled;
 
@@ -123,6 +125,11 @@ public abstract class AbstractConfigurableAsyncServer extends AbstractAsyncServe
         this.fileSystem = filesystem;
     }
 
+    @Inject
+    public void setHashWheelTimer(HashedWheelTimer timer) {
+        this.timer = timer;
+    }
+
     protected void registerMBean() {
 
         try {
@@ -563,7 +570,8 @@ public abstract class AbstractConfigurableAsyncServer extends AbstractAsyncServe
     
     @Override
     protected ChannelPipelineFactory createPipelineFactory(ChannelGroup group) {
-        return new AbstractExecutorAwareChannelPipelineFactory(getTimeout(), connectionLimit, connPerIP, group, enabledCipherSuites, getExecutionHandler(), getFrameHandlerFactory()) {
+        return new AbstractExecutorAwareChannelPipelineFactory(getTimeout(), connectionLimit, connPerIP, group,
+            enabledCipherSuites, getExecutionHandler(), getFrameHandlerFactory(), timer) {
             @Override
             protected SSLContext getSSLContext() {
                 if (encryption == null) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-library/src/main/java/org/apache/james/protocols/lib/netty/AbstractExecutorAwareChannelPipelineFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-library/src/main/java/org/apache/james/protocols/lib/netty/AbstractExecutorAwareChannelPipelineFactory.java b/server/protocols/protocols-library/src/main/java/org/apache/james/protocols/lib/netty/AbstractExecutorAwareChannelPipelineFactory.java
index 4fb1541..2bf9d51 100644
--- a/server/protocols/protocols-library/src/main/java/org/apache/james/protocols/lib/netty/AbstractExecutorAwareChannelPipelineFactory.java
+++ b/server/protocols/protocols-library/src/main/java/org/apache/james/protocols/lib/netty/AbstractExecutorAwareChannelPipelineFactory.java
@@ -24,6 +24,7 @@ import org.apache.james.protocols.netty.HandlerConstants;
 import org.jboss.netty.channel.ChannelPipeline;
 import org.jboss.netty.channel.group.ChannelGroup;
 import org.jboss.netty.handler.execution.ExecutionHandler;
+import org.jboss.netty.util.HashedWheelTimer;
 
 /**
  * Abstract base class which should get used if you MAY need an {@link ExecutionHandler}
@@ -32,12 +33,18 @@ import org.jboss.netty.handler.execution.ExecutionHandler;
  */
 public abstract class AbstractExecutorAwareChannelPipelineFactory extends AbstractSSLAwareChannelPipelineFactory {
 
-    public AbstractExecutorAwareChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp, ChannelGroup group, ExecutionHandler eHandler, ChannelHandlerFactory frameHandlerFactory) {
-        super(timeout, maxConnections, maxConnectsPerIp, group, eHandler, frameHandlerFactory);
+    public AbstractExecutorAwareChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp,
+                                                       ChannelGroup group, ExecutionHandler eHandler,
+                                                       ChannelHandlerFactory frameHandlerFactory,
+                                                       HashedWheelTimer hashedWheelTimer) {
+        super(timeout, maxConnections, maxConnectsPerIp, group, eHandler, frameHandlerFactory, hashedWheelTimer);
     }
 
-    public AbstractExecutorAwareChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp, ChannelGroup group, String[] enabledCipherSuites, ExecutionHandler eHandler, ChannelHandlerFactory frameHandlerFactory) {
-        super(timeout, maxConnections, maxConnectsPerIp, group, enabledCipherSuites, eHandler, frameHandlerFactory);
+    public AbstractExecutorAwareChannelPipelineFactory(int timeout, int maxConnections, int maxConnectsPerIp,
+                                                       ChannelGroup group, String[] enabledCipherSuites,
+                                                       ExecutionHandler eHandler, ChannelHandlerFactory frameHandlerFactory,
+                                                       HashedWheelTimer hashedWheelTimer) {
+        super(timeout, maxConnections, maxConnectsPerIp, group, enabledCipherSuites, eHandler, frameHandlerFactory, hashedWheelTimer);
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/netty/LMTPServerFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/netty/LMTPServerFactory.java b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/netty/LMTPServerFactory.java
index 9d1ec1b..ecf4040 100644
--- a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/netty/LMTPServerFactory.java
+++ b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/netty/LMTPServerFactory.java
@@ -29,18 +29,22 @@ import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.protocols.lib.handler.ProtocolHandlerLoader;
 import org.apache.james.protocols.lib.netty.AbstractConfigurableAsyncServer;
 import org.apache.james.protocols.lib.netty.AbstractServerFactory;
+import org.jboss.netty.util.HashedWheelTimer;
 
 public class LMTPServerFactory extends AbstractServerFactory {
 
     private final ProtocolHandlerLoader loader;
     private final FileSystem fileSystem;
     protected final LMTPMetricsImpl lmtpMetrics;
+    private final HashedWheelTimer hashedWheelTimer;
 
     @Inject
-    public LMTPServerFactory(ProtocolHandlerLoader loader, FileSystem fileSystem, MetricFactory metricFactory) {
+    public LMTPServerFactory(ProtocolHandlerLoader loader, FileSystem fileSystem, MetricFactory metricFactory,
+                             HashedWheelTimer hashedWheelTimer) {
         this.loader = loader;
         this.fileSystem = fileSystem;
         this.lmtpMetrics = new LMTPMetricsImpl(metricFactory);
+        this.hashedWheelTimer = hashedWheelTimer;
     }
 
     protected LMTPServer createServer() {
@@ -55,6 +59,7 @@ public class LMTPServerFactory extends AbstractServerFactory {
         for (HierarchicalConfiguration serverConfig: configs) {
             LMTPServer server = createServer();
             server.setFileSystem(fileSystem);
+            server.setHashWheelTimer(hashedWheelTimer);
             server.setProtocolHandlerLoader(loader);
             server.configure(serverConfig);
             servers.add(server);

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/netty/OioLMTPServerFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/netty/OioLMTPServerFactory.java b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/netty/OioLMTPServerFactory.java
index 605b9ec..7775024 100644
--- a/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/netty/OioLMTPServerFactory.java
+++ b/server/protocols/protocols-lmtp/src/main/java/org/apache/james/lmtpserver/netty/OioLMTPServerFactory.java
@@ -21,11 +21,13 @@ package org.apache.james.lmtpserver.netty;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.protocols.lib.handler.ProtocolHandlerLoader;
+import org.jboss.netty.util.HashedWheelTimer;
 
 public class OioLMTPServerFactory extends LMTPServerFactory {
 
-    public OioLMTPServerFactory(ProtocolHandlerLoader loader, FileSystem fileSystem, MetricFactory metricFactory) {
-        super(loader, fileSystem, metricFactory);
+    public OioLMTPServerFactory(ProtocolHandlerLoader loader, FileSystem fileSystem, MetricFactory metricFactory,
+                                HashedWheelTimer hashedWheelTimer) {
+        super(loader, fileSystem, metricFactory, hashedWheelTimer);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-managesieve/src/main/java/org/apache/james/managesieveserver/netty/ManageSieveServerFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-managesieve/src/main/java/org/apache/james/managesieveserver/netty/ManageSieveServerFactory.java b/server/protocols/protocols-managesieve/src/main/java/org/apache/james/managesieveserver/netty/ManageSieveServerFactory.java
index fd6e9f7..f77934f 100644
--- a/server/protocols/protocols-managesieve/src/main/java/org/apache/james/managesieveserver/netty/ManageSieveServerFactory.java
+++ b/server/protocols/protocols-managesieve/src/main/java/org/apache/james/managesieveserver/netty/ManageSieveServerFactory.java
@@ -35,6 +35,7 @@ import org.apache.james.protocols.lib.netty.AbstractConfigurableAsyncServer;
 import org.apache.james.protocols.lib.netty.AbstractServerFactory;
 import org.apache.james.sieverepository.api.SieveRepository;
 import org.apache.james.user.api.UsersRepository;
+import org.jboss.netty.util.HashedWheelTimer;
 
 public class ManageSieveServerFactory extends AbstractServerFactory {
 
@@ -43,6 +44,7 @@ public class ManageSieveServerFactory extends AbstractServerFactory {
     private SieveRepository sieveRepository;
     private UsersRepository usersRepository;
     private Parser sieveParser;
+    private HashedWheelTimer hashedWheelTimer;
 
     @Inject
     public void setFileSystem(FileSystem fileSystem) {
@@ -64,6 +66,12 @@ public class ManageSieveServerFactory extends AbstractServerFactory {
         this.sieveParser = sieveParser;
     }
 
+    @Inject
+    public void setHashedWheelTimer(HashedWheelTimer hashedWheelTimer) {
+        this.hashedWheelTimer = hashedWheelTimer;
+    }
+
+
     @PostConstruct
     public void init() throws Exception {
         manageSieveProcessor = new ManageSieveProcessor(new ArgumentParser(new CoreProcessor(sieveRepository, usersRepository, sieveParser)));
@@ -78,6 +86,7 @@ public class ManageSieveServerFactory extends AbstractServerFactory {
         for (HierarchicalConfiguration serverConfig: configs) {
             ManageSieveServer server = new ManageSieveServer(8000, manageSieveProcessor);
             server.setFileSystem(fileSystem);
+            server.setHashWheelTimer(hashedWheelTimer);
             server.configure(serverConfig);
             servers.add(server);
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/netty/POP3ServerFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/netty/POP3ServerFactory.java b/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/netty/POP3ServerFactory.java
index b03718f..92e66dd 100644
--- a/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/netty/POP3ServerFactory.java
+++ b/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/netty/POP3ServerFactory.java
@@ -10,12 +10,14 @@ import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.protocols.lib.handler.ProtocolHandlerLoader;
 import org.apache.james.protocols.lib.netty.AbstractConfigurableAsyncServer;
 import org.apache.james.protocols.lib.netty.AbstractServerFactory;
+import org.jboss.netty.util.HashedWheelTimer;
 
 public class POP3ServerFactory extends AbstractServerFactory {
 
     private ProtocolHandlerLoader loader;
     private FileSystem fileSystem;
-    
+    private HashedWheelTimer hashedWheelTimer;
+
     @Inject
     public void setProtocolHandlerLoader(ProtocolHandlerLoader loader) {
         this.loader = loader;
@@ -26,6 +28,11 @@ public class POP3ServerFactory extends AbstractServerFactory {
         this.fileSystem = filesystem;
     }
 
+    @Inject
+    public void setHashedWheelTimer(HashedWheelTimer hashedWheelTimer) {
+        this.hashedWheelTimer = hashedWheelTimer;
+    }
+
     protected POP3Server createServer() {
        return new POP3Server();
     }
@@ -40,6 +47,7 @@ public class POP3ServerFactory extends AbstractServerFactory {
             POP3Server server = createServer();
             server.setProtocolHandlerLoader(loader);
             server.setFileSystem(fileSystem);
+            server.setHashWheelTimer(hashedWheelTimer);
             server.configure(serverConfig);
             servers.add(server);
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java b/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
index 780286d..19993d5 100644
--- a/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
+++ b/server/protocols/protocols-pop3/src/test/java/org/apache/james/pop3server/POP3ServerTest.java
@@ -55,6 +55,7 @@ import org.apache.james.protocols.lib.mock.MockProtocolHandlerLoader;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.james.user.memory.MemoryUsersRepository;
+import org.jboss.netty.util.HashedWheelTimer;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -73,9 +74,11 @@ public class POP3ServerTest {
             + "Subject: test\r\n\r\n"
             + "Body Text POP3ServerTest.setupTestMails\r\n").getBytes();
     private POP3Server pop3Server;
+    private HashedWheelTimer hashedWheelTimer;
 
     @Before
     public void setUp() throws Exception {
+        hashedWheelTimer = new HashedWheelTimer();
         setUpServiceManager();
         setUpPOP3Server();
         pop3Configuration = new POP3TestConfiguration();
@@ -95,6 +98,7 @@ public class POP3ServerTest {
         }
         protocolHandlerChain.dispose();
         pop3Server.destroy();
+        hashedWheelTimer.stop();
     }
 
     @Test
@@ -699,6 +703,7 @@ public class POP3ServerTest {
     protected void setUpPOP3Server() {
         pop3Server = createPOP3Server();
         pop3Server.setFileSystem(fileSystem);
+        pop3Server.setHashWheelTimer(hashedWheelTimer);
         pop3Server.setProtocolHandlerLoader(protocolHandlerChain);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/OioSMTPServerFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/OioSMTPServerFactory.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/OioSMTPServerFactory.java
index 5ad90de..44d8b80 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/OioSMTPServerFactory.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/OioSMTPServerFactory.java
@@ -23,11 +23,13 @@ import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.protocols.lib.handler.ProtocolHandlerLoader;
+import org.jboss.netty.util.HashedWheelTimer;
 
 public class OioSMTPServerFactory extends SMTPServerFactory {
 
-    public OioSMTPServerFactory(DNSService dns, ProtocolHandlerLoader loader, FileSystem fileSystem, MetricFactory metricFactory) {
-        super(dns, loader, fileSystem, metricFactory);
+    public OioSMTPServerFactory(DNSService dns, ProtocolHandlerLoader loader, FileSystem fileSystem,
+                                MetricFactory metricFactory, HashedWheelTimer hashedWheelTimer) {
+        super(dns, loader, fileSystem, metricFactory, hashedWheelTimer);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/SMTPServerFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/SMTPServerFactory.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/SMTPServerFactory.java
index 5a07b21..35fc881 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/SMTPServerFactory.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/netty/SMTPServerFactory.java
@@ -31,6 +31,7 @@ import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.protocols.lib.handler.ProtocolHandlerLoader;
 import org.apache.james.protocols.lib.netty.AbstractConfigurableAsyncServer;
 import org.apache.james.protocols.lib.netty.AbstractServerFactory;
+import org.jboss.netty.util.HashedWheelTimer;
 
 public class SMTPServerFactory extends AbstractServerFactory {
 
@@ -38,13 +39,16 @@ public class SMTPServerFactory extends AbstractServerFactory {
     protected final ProtocolHandlerLoader loader;
     protected final FileSystem fileSystem;
     protected final SmtpMetricsImpl smtpMetrics;
+    private final HashedWheelTimer hashedWheelTimer;
 
     @Inject
-    public SMTPServerFactory(DNSService dns, ProtocolHandlerLoader loader, FileSystem fileSystem, MetricFactory metricFactory) {
+    public SMTPServerFactory(DNSService dns, ProtocolHandlerLoader loader, FileSystem fileSystem,
+                             MetricFactory metricFactory, HashedWheelTimer hashedWheelTimer) {
         this.dns = dns;
         this.loader = loader;
         this.fileSystem = fileSystem;
         this.smtpMetrics = new SmtpMetricsImpl(metricFactory);
+        this.hashedWheelTimer = hashedWheelTimer;
     }
 
     protected SMTPServer createServer() {
@@ -62,6 +66,7 @@ public class SMTPServerFactory extends AbstractServerFactory {
             server.setDnsService(dns);
             server.setProtocolHandlerLoader(loader);
             server.setFileSystem(fileSystem);
+            server.setHashWheelTimer(hashedWheelTimer);
             server.configure(serverConfig);
             servers.add(server);
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
index 35a5ebf..366ac25 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/SMTPServerTest.java
@@ -65,6 +65,7 @@ import org.apache.james.smtpserver.netty.SmtpMetricsImpl;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.memory.MemoryUsersRepository;
 import org.apache.mailet.Mail;
+import org.jboss.netty.util.HashedWheelTimer;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -162,6 +163,7 @@ public class SMTPServerTest {
     private static final Logger LOGGER = LoggerFactory.getLogger(SMTPServerTest.class);
 
     protected SMTPTestConfiguration smtpConfiguration;
+    protected HashedWheelTimer hashedWheelTimer;
     protected final MemoryUsersRepository usersRepository = MemoryUsersRepository.withoutVirtualHosting();
     protected AlterableDNSServer dnsServer;
     protected MockMailRepositoryStore store;
@@ -179,6 +181,7 @@ public class SMTPServerTest {
         // slf4j can't set programmatically any log level. It's just a facade
         // log.setLevel(SimpleLog.LOG_LEVEL_ALL);
         smtpConfiguration = new SMTPTestConfiguration();
+        hashedWheelTimer = new HashedWheelTimer();
         setUpSMTPServer();
     }
 
@@ -193,6 +196,7 @@ public class SMTPServerTest {
         smtpServer = createSMTPServer(smtpMetrics);
         smtpServer.setDnsService(dnsServer);
         smtpServer.setFileSystem(fileSystem);
+        smtpServer.setHashWheelTimer(hashedWheelTimer);
         smtpServer.setProtocolHandlerLoader(chain);
     }
 
@@ -224,7 +228,7 @@ public class SMTPServerTest {
 
         MemoryRecipientRewriteTable rewriteTable = new MemoryRecipientRewriteTable();
         chain.put("recipientrewritetable", RecipientRewriteTable.class, rewriteTable);
-    
+
         queueFactory = new MemoryMailQueueFactory(new RawMailQueueItemDecoratorFactory());
         queue = queueFactory.createQueue(MailQueueFactory.SPOOL);
         chain.put("mailqueuefactory", MailQueueFactory.class, queueFactory);
@@ -307,6 +311,7 @@ public class SMTPServerTest {
     @After
     public void tearDown() throws Exception {
         smtpServer.destroy();
+        hashedWheelTimer.stop();
     }
 
     public void verifyLastMail(String sender, String recipient, MimeMessage msg) throws Exception {

http://git-wip-us.apache.org/repos/asf/james-project/blob/73a320b0/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java
index 3d4eea9..0db323d 100644
--- a/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java
+++ b/server/protocols/protocols-smtp/src/test/java/org/apache/james/smtpserver/ValidRcptMXTest.java
@@ -81,7 +81,7 @@ public class ValidRcptMXTest {
 
         ValidRcptMX handler = new ValidRcptMX();
         handler.setDNSService(dns);
-        handler.setBannedNetworks(ImmutableList.of(bannedAddress ), dns);
+        handler.setBannedNetworks(ImmutableList.of(bannedAddress), dns);
         int rCode = handler.doRcpt(session, null, mailAddress).getResult();
 
         assertEquals("Reject", rCode, HookReturnCode.DENY);


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message