directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r169265 - in /directory/network/branches/api_integration/src: examples/org/apache/mina/examples/reverser/Main.java examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
Date Mon, 09 May 2005 10:02:40 GMT
Author: trustin
Date: Mon May  9 03:02:38 2005
New Revision: 169265

URL: http://svn.apache.org/viewcvs?rev=169265&view=rev
Log:
Fixed: ProtocolCodecFilter FIXMEs

Modified:
    directory/network/branches/api_integration/src/examples/org/apache/mina/examples/reverser/Main.java
    directory/network/branches/api_integration/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java
    directory/network/branches/api_integration/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java

Modified: directory/network/branches/api_integration/src/examples/org/apache/mina/examples/reverser/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/examples/org/apache/mina/examples/reverser/Main.java?rev=169265&r1=169264&r2=169265&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/examples/org/apache/mina/examples/reverser/Main.java
(original)
+++ directory/network/branches/api_integration/src/examples/org/apache/mina/examples/reverser/Main.java
Mon May  9 03:02:38 2005
@@ -18,9 +18,7 @@
  */
 package org.apache.mina.examples.reverser;
 
-import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.TransportType;
-import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.registry.Service;
 import org.apache.mina.registry.ServiceRegistry;
 import org.apache.mina.registry.SimpleServiceRegistry;
@@ -40,18 +38,10 @@
     {
         ServiceRegistry registry = new SimpleServiceRegistry();
 
-        addLogger( registry );
         // Bind
         Service service = new Service( "reverse", TransportType.SOCKET, PORT );
         registry.bind( service, new ReverseProtocolHandler() );
 
         System.out.println( "Listening on port " + PORT );
-    }
-
-    private static void addLogger( ServiceRegistry registry )
-    {
-        IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
-        acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
-        System.out.println( "Logging ON" );
     }
 }

Modified: directory/network/branches/api_integration/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java?rev=169265&r1=169264&r2=169265&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java
(original)
+++ directory/network/branches/api_integration/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java
Mon May  9 03:02:38 2005
@@ -18,9 +18,11 @@
  */
 package org.apache.mina.examples.reverser;
 
+import org.apache.mina.common.IoFilter;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoHandlerAdapter;
 import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.LoggingFilter;
 import org.apache.mina.filter.codec.ProtocolCodecFactory;
 import org.apache.mina.filter.codec.ProtocolCodecFilter;
 import org.apache.mina.filter.codec.ProtocolDecoder;
@@ -34,6 +36,8 @@
  */
 public class ReverseProtocolHandler extends IoHandlerAdapter
 {
+    private static IoFilter LOGGING_FILTER = new LoggingFilter();
+    
     private static ProtocolCodecFactory CODEC_FACTORY = new ProtocolCodecFactory()
     {
         public ProtocolEncoder newEncoder()
@@ -49,10 +53,12 @@
         }
     };
 
+    private static IoFilter CODEC_FILTER = new ProtocolCodecFilter( CODEC_FACTORY );
+
     public void sessionCreated( IoSession session )
     {
-        session.getFilterChain().addFirst(
-                "codec", new ProtocolCodecFilter( CODEC_FACTORY ) );
+        session.getFilterChain().addLast( "codec", CODEC_FILTER );
+        session.getFilterChain().addLast( "logger", LOGGING_FILTER );
     }
 
     public void exceptionCaught( IoSession session, Throwable cause )

Modified: directory/network/branches/api_integration/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/api_integration/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java?rev=169265&r1=169264&r2=169265&view=diff
==============================================================================
--- directory/network/branches/api_integration/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
(original)
+++ directory/network/branches/api_integration/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
Mon May  9 03:02:38 2005
@@ -1,6 +1,7 @@
 package org.apache.mina.filter.codec;
 
 import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.ByteBufferProxy;
 import org.apache.mina.common.IoFilterAdapter;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.util.Queue;
@@ -58,8 +59,8 @@
 
     public void messageSent( NextFilter nextFilter, IoSession session, Object message ) throws
Exception
     {
-        // FIXME message is a bytebuffer here
-        super.messageSent(nextFilter, session, message);
+        MessageByteBuffer buf = ( MessageByteBuffer ) message;
+        nextFilter.messageSent( session, buf.message );
     }
     
     public void filterWrite( NextFilter nextFilter, IoSession session, Object message ) throws
Exception
@@ -78,8 +79,8 @@
             ByteBuffer buf = ( ByteBuffer ) queue.pop();
             if( buf == null )
                 break;
-            // FIXME messageSent issues
-            nextFilter.filterWrite( session, buf );
+            
+            nextFilter.filterWrite( session, new MessageByteBuffer( buf, message ) );
         }
     }
     
@@ -125,5 +126,17 @@
             session.setAttribute( DECODER_OUT, out );
         }
         return out;
+    }
+    
+    private static class MessageByteBuffer extends ByteBufferProxy
+    {
+        private final Object message;
+        
+        private MessageByteBuffer( ByteBuffer buf, Object message )
+        {
+            super( buf );
+            this.message = message;
+        }
+        
     }
 }



Mime
View raw message