Author: norman
Date: Mon Nov 21 10:19:49 2011
New Revision: 1204430

URL: http://svn.apache.org/viewvc?rev=1204430&view=rev
Log:
Add HandlerConstants which holds the keys under which the ChannelHandlers get 
added to the ChannelPipeline

Added:
    
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/HandlerConstants.java
Modified:
    
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractChannelPipelineFactory.java
    
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractSSLAwareChannelPipelineFactory.java
    
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/NettyProtocolTransport.java

Modified: 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractChannelPipelineFactory.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractChannelPipelineFactory.java?rev=1204430&r1=1204429&r2=1204430&view=diff
==============================================================================
--- 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractChannelPipelineFactory.java
 (original)
+++ 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractChannelPipelineFactory.java
 Mon Nov 21 10:19:49 2011
@@ -42,17 +42,17 @@ public abstract class AbstractChannelPip
     private final ConnectionLimitUpstreamHandler connectionLimitHandler;
     private final ConnectionPerIpLimitUpstreamHandler 
connectionPerIpLimitHandler;
     private final HashedWheelTimer timer = new HashedWheelTimer();
-    private ChannelGroupHandler groupHandler;
-       private int timeout;
-    private ExecutionHandler eHandler;
+    private final ChannelGroupHandler groupHandler;
+       private final int timeout;
+    private final ExecutionHandler eHandler;
     public AbstractChannelPipelineFactory(int timeout, int maxConnections, int 
maxConnectsPerIp, ChannelGroup channels) {
         this(timeout, maxConnections, maxConnectsPerIp, channels, null);
     }
     
     public AbstractChannelPipelineFactory(int timeout, int maxConnections, int 
maxConnectsPerIp, ChannelGroup channels, ExecutionHandler eHandler) {
-        connectionLimitHandler = new 
ConnectionLimitUpstreamHandler(maxConnections);
-        connectionPerIpLimitHandler = new 
ConnectionPerIpLimitUpstreamHandler(maxConnectsPerIp);
-        groupHandler = new ChannelGroupHandler(channels);
+        this.connectionLimitHandler = new 
ConnectionLimitUpstreamHandler(maxConnections);
+        this.connectionPerIpLimitHandler = new 
ConnectionPerIpLimitUpstreamHandler(maxConnectsPerIp);
+        this.groupHandler = new ChannelGroupHandler(channels);
         this.timeout = timeout;
         this.eHandler = eHandler;
     }
@@ -66,25 +66,25 @@ public abstract class AbstractChannelPip
     public ChannelPipeline getPipeline() throws Exception {
         // Create a default pipeline implementation.
         ChannelPipeline pipeline = pipeline();
-        pipeline.addLast("groupHandler", groupHandler);
+        pipeline.addLast(HandlerConstants.GROUP_HANDLER, groupHandler);
 
-        pipeline.addLast("connectionLimit", connectionLimitHandler);
+        pipeline.addLast(HandlerConstants.CONNECTION_LIMIT_HANDLER, 
connectionLimitHandler);
 
-        pipeline.addLast("connectionPerIpLimit", connectionPerIpLimitHandler);
+        pipeline.addLast(HandlerConstants.CONNECTION_PER_IP_LIMIT_HANDLER, 
connectionPerIpLimitHandler);
 
         
         // Add the text line decoder which limit the max line length, don't 
strip the delimiter and use CRLF as delimiter
-        pipeline.addLast("framer", new 
DelimiterBasedFrameDecoder(MAX_LINE_LENGTH, false, Delimiters.lineDelimiter()));
+        pipeline.addLast(HandlerConstants.FRAMER, new 
DelimiterBasedFrameDecoder(MAX_LINE_LENGTH, false, Delimiters.lineDelimiter()));
        
         // Add the ChunkedWriteHandler to be able to write ChunkInput
-        pipeline.addLast("streamer", new ChunkedWriteHandler());
-        pipeline.addLast("timeoutHandler", new TimeoutHandler(timer, timeout));
+        pipeline.addLast(HandlerConstants.CHUNK_HANDLER, new 
ChunkedWriteHandler());
+        pipeline.addLast(HandlerConstants.TIMEOUT_HANDLER, new 
TimeoutHandler(timer, timeout));
 
         if (eHandler != null) {
-            pipeline.addLast("executionHandler", eHandler);
+            pipeline.addLast(HandlerConstants.EXECUTION_HANDLER, eHandler);
         }
         
-        pipeline.addLast("coreHandler", createHandler());
+        pipeline.addLast(HandlerConstants.CORE_HANDLER, createHandler());
 
 
         return pipeline;
@@ -100,11 +100,9 @@ public abstract class AbstractChannelPip
      */
     protected abstract ChannelUpstreamHandler createHandler();
 
+    
     @Override
     public void releaseExternalResources() {
         timer.stop();
     }
-    
-
-
 }

Modified: 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractSSLAwareChannelPipelineFactory.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractSSLAwareChannelPipelineFactory.java?rev=1204430&r1=1204429&r2=1204430&view=diff
==============================================================================
--- 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractSSLAwareChannelPipelineFactory.java
 (original)
+++ 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/AbstractSSLAwareChannelPipelineFactory.java
 Mon Nov 21 10:19:49 2011
@@ -68,7 +68,7 @@ public abstract class AbstractSSLAwareCh
             if (enabledCipherSuites != null && enabledCipherSuites.length > 0) 
{
                 engine.setEnabledCipherSuites(enabledCipherSuites);
             }
-            pipeline.addFirst("sslHandler", new SslHandler(engine));
+            pipeline.addFirst(HandlerConstants.SSL_HANDLER, new 
SslHandler(engine));
         }
         return pipeline;
     }

Added: 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/HandlerConstants.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/HandlerConstants.java?rev=1204430&view=auto
==============================================================================
--- 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/HandlerConstants.java
 (added)
+++ 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/HandlerConstants.java
 Mon Nov 21 10:19:49 2011
@@ -0,0 +1,50 @@
+/****************************************************************
+ * 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.protocols.impl;
+
+import org.jboss.netty.channel.ChannelHandler;
+import org.jboss.netty.channel.ChannelPipeline;
+
+/**
+ * Provide the keys under which the {@link ChannelHandler}'s are stored in the 
{@link ChannelPipeline}
+ * 
+ *
+ */
+public interface HandlerConstants {
+
+       public static final String SSL_HANDLER = "sslHandler";
+       
+       public static final String GROUP_HANDLER ="groupHandler";
+       
+       public static final String CONNECTION_LIMIT_HANDLER =" connectionLimit";
+       
+       public static final String CONNECTION_PER_IP_LIMIT_HANDLER 
="connectionPerIpLimit";
+       
+       public static final String FRAMER = "framer";
+       
+       public static final String EXECUTION_HANDLER = "executionHandler";
+       
+       public static final String TIMEOUT_HANDLER = "timeoutHandler";
+       
+       public static final String CORE_HANDLER = "coreHandler";
+
+       public static final String CHUNK_HANDLER = "chunkHandler";
+
+
+}

Modified: 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/NettyProtocolTransport.java
URL: 
http://svn.apache.org/viewvc/james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/NettyProtocolTransport.java?rev=1204430&r1=1204429&r2=1204430&view=diff
==============================================================================
--- 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/NettyProtocolTransport.java
 (original)
+++ 
james/protocols/trunk/impl/src/main/java/org/apache/james/protocols/impl/NettyProtocolTransport.java
 Mon Nov 21 10:19:49 2011
@@ -65,7 +65,7 @@ public class NettyProtocolTransport exte
      * @see org.apache.james.protocols.api.ProtocolTransport#isTLSStarted()
      */
     public boolean isTLSStarted() {
-        return channel.getPipeline().get("sslHandler") != null;
+        return channel.getPipeline().get(SslHandler.class) != null;
     }
 
     /**
@@ -113,7 +113,7 @@ public class NettyProtocolTransport exte
         channel.setReadable(false);
         SslHandler filter = new SslHandler(engine);
         filter.getEngine().setUseClientMode(false);
-        channel.getPipeline().addFirst("sslHandler", filter);
+        channel.getPipeline().addFirst(HandlerConstants.SSL_HANDLER, filter);
         channel.setReadable(true);        
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to