Author: norman
Date: Thu Sep 15 10:49:30 2011
New Revision: 1171048

URL: http://svn.apache.org/viewvc?rev=1171048&view=rev
Log:
Move to latest PROTOCOLS snapshot and adjust code to use it

Modified:
    
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
    
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapIdleStateHandler.java
    
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapLineHandlerAdapter.java
    
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
    
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NettyConstants.java
    
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java

Modified: 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java?rev=1171048&r1=1171047&r2=1171048&view=diff
==============================================================================
--- 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
 (original)
+++ 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapChannelUpstreamHandler.java
 Thu Sep 15 10:49:30 2011
@@ -32,7 +32,6 @@ import org.apache.james.imap.encode.Imap
 import org.apache.james.imap.encode.ImapResponseComposer;
 import org.apache.james.imap.encode.base.ImapResponseComposerImpl;
 import org.apache.james.imap.main.ResponseEncoder;
-import org.apache.james.protocols.impl.ChannelAttributeSupport;
 import org.apache.james.protocols.impl.SessionLog;
 import org.jboss.netty.buffer.ChannelBuffers;
 import org.jboss.netty.channel.Channel;
@@ -49,7 +48,7 @@ import org.slf4j.Logger;
 /**
  * {@link SimpleChannelUpstreamHandler} which handles IMAP
  */
-public class ImapChannelUpstreamHandler extends SimpleChannelUpstreamHandler 
implements ChannelAttributeSupport {
+public class ImapChannelUpstreamHandler extends SimpleChannelUpstreamHandler 
implements NettyConstants{
 
     private final Logger logger;
 
@@ -91,7 +90,7 @@ public class ImapChannelUpstreamHandler 
     @Override
     public void channelBound(final ChannelHandlerContext ctx, 
ChannelStateEvent e) throws Exception {
 
-        ImapSession imapsession = new NettyImapSession(ctx, logger, context, 
enabledCipherSuites, compress, plainAuthDisallowed);
+        ImapSession imapsession = new NettyImapSession(ctx.getChannel(), 
logger, context, enabledCipherSuites, compress, plainAuthDisallowed);
         attributes.set(ctx.getChannel(), imapsession);
         super.channelBound(ctx, e);
     }

Modified: 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapIdleStateHandler.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapIdleStateHandler.java?rev=1171048&r1=1171047&r2=1171048&view=diff
==============================================================================
--- 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapIdleStateHandler.java
 (original)
+++ 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapIdleStateHandler.java
 Thu Sep 15 10:49:30 2011
@@ -21,7 +21,6 @@ package org.apache.james.imapserver.nett
 import java.net.InetSocketAddress;
 
 import org.apache.james.imap.api.process.ImapSession;
-import org.apache.james.protocols.impl.ChannelAttributeSupport;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.handler.timeout.IdleState;
 import org.jboss.netty.handler.timeout.IdleStateAwareChannelHandler;
@@ -31,7 +30,7 @@ import org.jboss.netty.handler.timeout.I
  * {@link IdleStateAwareChannelHandler} which will call {@link 
ImapSession#logout()} if the
  * connected client did not receive or send any traffic in a given timeframe
  */
-public class ImapIdleStateHandler extends IdleStateAwareChannelHandler 
implements ChannelAttributeSupport {
+public class ImapIdleStateHandler extends IdleStateAwareChannelHandler 
implements NettyConstants {
 
     @Override
     public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e) 
throws Exception {

Modified: 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapLineHandlerAdapter.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapLineHandlerAdapter.java?rev=1171048&r1=1171047&r2=1171048&view=diff
==============================================================================
--- 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapLineHandlerAdapter.java
 (original)
+++ 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapLineHandlerAdapter.java
 Thu Sep 15 10:49:30 2011
@@ -20,7 +20,6 @@ package org.apache.james.imapserver.nett
 
 import org.apache.james.imap.api.process.ImapLineHandler;
 import org.apache.james.imap.api.process.ImapSession;
-import org.apache.james.protocols.impl.ChannelAttributeSupport;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.channel.MessageEvent;
@@ -32,12 +31,14 @@ import org.jboss.netty.channel.SimpleCha
  * {@link #messageReceived(ChannelHandlerContext, MessageEvent)} to a
  * {@link ImapLineHandler#onLine(ImapSession, byte[])}
  */
-public class ImapLineHandlerAdapter extends SimpleChannelUpstreamHandler 
implements ChannelAttributeSupport {
+public class ImapLineHandlerAdapter extends SimpleChannelUpstreamHandler {
 
-    private ImapLineHandler lineHandler;
+    private final ImapLineHandler lineHandler;
+    private final ImapSession session;
 
-    public ImapLineHandlerAdapter(ImapLineHandler lineHandler) {
+    public ImapLineHandlerAdapter(ImapSession session, ImapLineHandler 
lineHandler) {
         this.lineHandler = lineHandler;
+        this.session = session;
     }
 
     @Override
@@ -50,7 +51,7 @@ public class ImapLineHandlerAdapter exte
             data = new byte[buf.readableBytes()];
             buf.readBytes(data);
         }
-        lineHandler.onLine((ImapSession) attributes.get(ctx.getChannel()), 
data);
+        lineHandler.onLine(session, data);
     }
 
 }

Modified: 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java?rev=1171048&r1=1171047&r2=1171048&view=diff
==============================================================================
--- 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
 (original)
+++ 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/ImapRequestFrameDecoder.java
 Thu Sep 15 10:49:30 2011
@@ -33,7 +33,6 @@ import org.apache.james.imap.api.ImapMes
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.decode.ImapDecoder;
 import org.apache.james.imap.decode.ImapRequestLineReader;
-import org.apache.james.protocols.impl.ChannelAttributeSupport;
 import org.jboss.netty.buffer.ChannelBuffer;
 import org.jboss.netty.buffer.ChannelBufferInputStream;
 import org.jboss.netty.buffer.ChannelBuffers;
@@ -46,7 +45,7 @@ import org.jboss.netty.handler.codec.fra
 /**
  * {@link FrameDecoder} which will decode via and {@link ImapDecoder} instance
  */
-public class ImapRequestFrameDecoder extends FrameDecoder implements 
ChannelAttributeSupport {
+public class ImapRequestFrameDecoder extends FrameDecoder implements 
NettyConstants {
 
     private final ImapDecoder decoder;
     private final int inMemorySizeLimit;

Modified: 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NettyConstants.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NettyConstants.java?rev=1171048&r1=1171047&r2=1171048&view=diff
==============================================================================
--- 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NettyConstants.java
 (original)
+++ 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NettyConstants.java
 Thu Sep 15 10:49:30 2011
@@ -18,6 +18,8 @@
  ****************************************************************/
 package org.apache.james.imapserver.netty;
 
+import org.jboss.netty.channel.ChannelLocal;
+
 /**
  * Just some constants which are used with the Netty implementation
  */
@@ -37,4 +39,5 @@ public interface NettyConstants {
     final static String EXECUTION_HANDLER = "executionHandler";
     final static String HEARTBEAT_HANDLER = "heartbeatHandler";
 
+    final static ChannelLocal<Object> attributes = new ChannelLocal<Object>();
 }

Modified: 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java?rev=1171048&r1=1171047&r2=1171048&view=diff
==============================================================================
--- 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java
 (original)
+++ 
james/server/trunk/imapserver/src/main/java/org/apache/james/imapserver/netty/NettyImapSession.java
 Thu Sep 15 10:49:30 2011
@@ -29,7 +29,6 @@ import org.apache.james.imap.api.process
 import org.apache.james.imap.api.process.SelectedMailbox;
 import org.apache.james.protocols.impl.SessionLog;
 import org.jboss.netty.channel.Channel;
-import org.jboss.netty.channel.ChannelHandlerContext;
 import org.jboss.netty.handler.codec.compression.ZlibDecoder;
 import org.jboss.netty.handler.codec.compression.ZlibEncoder;
 import org.jboss.netty.handler.codec.compression.ZlibWrapper;
@@ -45,13 +44,13 @@ public class NettyImapSession implements
     private String[] enabledCipherSuites;
     private boolean compress;
     private SessionLog log;
-    private ChannelHandlerContext context;
+    private Channel channel;
     private int handlerCount;
     private boolean plainAuthDisallowed;
 
-    public NettyImapSession(ChannelHandlerContext context, Logger log, 
SSLContext sslContext, String[] enabledCipherSuites, boolean compress, boolean 
plainAuthDisallowed) {
-        this.context = context;
-        this.log = new SessionLog(context.getChannel().getId() + "", log);
+    public NettyImapSession(Channel channel, Logger log, SSLContext 
sslContext, String[] enabledCipherSuites, boolean compress, boolean 
plainAuthDisallowed) {
+        this.channel = channel;
+        this.log = new SessionLog(channel.getId() + "", log);
         this.sslContext = sslContext;
         this.enabledCipherSuites = enabledCipherSuites;
         this.compress = compress;
@@ -65,7 +64,7 @@ public class NettyImapSession implements
      * @return channel
      */
     public Channel getChannel() {
-        return context.getChannel();
+        return channel;
     }
 
     /*
@@ -170,16 +169,16 @@ public class NettyImapSession implements
     public boolean startTLS() {
         if (supportStartTLS() == false)
             return false;
-        context.getChannel().setReadable(false);
+        channel.setReadable(false);
 
         SslHandler filter = new SslHandler(sslContext.createSSLEngine(), 
false);
         filter.getEngine().setUseClientMode(false);
         if (enabledCipherSuites != null && enabledCipherSuites.length > 0) {
             filter.getEngine().setEnabledCipherSuites(enabledCipherSuites);
         }
-        context.getPipeline().addFirst(SSL_HANDLER, filter);
+        channel.getPipeline().addFirst(SSL_HANDLER, filter);
 
-        context.getChannel().setReadable(true);
+        channel.setReadable(true);
 
         return true;
     }
@@ -212,7 +211,7 @@ public class NettyImapSession implements
         if (isCompressionSupported() == false)
             return false;
 
-        context.getChannel().setReadable(false);
+        channel.setReadable(false);
         ZlibDecoder decoder = new ZlibDecoder(ZlibWrapper.NONE);
         ZlibEncoder encoder = new ZlibEncoder(ZlibWrapper.NONE, 5);
 
@@ -220,15 +219,15 @@ public class NettyImapSession implements
         // if so we need to move the compress encoder and decoder
         // behind it in the chain
         // See JAMES-1186
-        if (context.getPipeline().get(SSL_HANDLER) == null) {
-            context.getPipeline().addFirst(ZLIB_DECODER, decoder);
-            context.getPipeline().addFirst(ZLIB_ENCODER, encoder);
+        if (channel.getPipeline().get(SSL_HANDLER) == null) {
+            channel.getPipeline().addFirst(ZLIB_DECODER, decoder);
+            channel.getPipeline().addFirst(ZLIB_ENCODER, encoder);
         } else {
-            context.getPipeline().addAfter(SSL_HANDLER, ZLIB_DECODER, decoder);
-            context.getPipeline().addAfter(SSL_HANDLER, ZLIB_ENCODER, encoder);
+            channel.getPipeline().addAfter(SSL_HANDLER, ZLIB_DECODER, decoder);
+            channel.getPipeline().addAfter(SSL_HANDLER, ZLIB_ENCODER, encoder);
         }
 
-        context.getChannel().setReadable(true);
+        channel.setReadable(true);
 
         return true;
     }
@@ -241,9 +240,9 @@ public class NettyImapSession implements
      * .james.imap.api.process.ImapLineHandler)
      */
     public void pushLineHandler(ImapLineHandler lineHandler) {
-        context.getChannel().setReadable(false);
-        context.getPipeline().addBefore(REQUEST_DECODER, "lineHandler" + 
handlerCount++, new ImapLineHandlerAdapter(lineHandler));
-        context.getChannel().setReadable(true);
+        channel.setReadable(false);
+        channel.getPipeline().addBefore(REQUEST_DECODER, "lineHandler" + 
handlerCount++, new ImapLineHandlerAdapter(this, lineHandler));
+        channel.setReadable(true);
     }
 
     /*
@@ -252,9 +251,9 @@ public class NettyImapSession implements
      * @see org.apache.james.imap.api.process.ImapSession#popLineHandler()
      */
     public void popLineHandler() {
-        context.getChannel().setReadable(false);
-        context.getPipeline().remove("lineHandler" + --handlerCount);
-        context.getChannel().setReadable(true);
+        channel.setReadable(false);
+        channel.getPipeline().remove("lineHandler" + --handlerCount);
+        channel.setReadable(true);
     }
 
     /*
@@ -279,7 +278,7 @@ public class NettyImapSession implements
      * @see org.apache.james.imap.api.process.ImapSession#isTLSActive()
      */
     public boolean isTLSActive() {
-        return context.getPipeline().get(SSL_HANDLER) != null;
+        return channel.getPipeline().get(SSL_HANDLER) != null;
     }
 
     /*
@@ -295,7 +294,7 @@ public class NettyImapSession implements
      * @see org.apache.james.imap.api.process.ImapSession#isCompressionActive()
      */
     public boolean isCompressionActive() {
-        return context.getPipeline().get(ZLIB_DECODER) != null;
+        return channel.getPipeline().get(ZLIB_DECODER) != null;
     }
 
 }



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

Reply via email to