directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r161453 - in directory/network/trunk/src/java/org/apache/mina/protocol: DemuxingProtocolHandler.java codec/CumulativeProtocolDecoder.java
Date Fri, 15 Apr 2005 13:29:09 GMT
Author: trustin
Date: Fri Apr 15 06:29:08 2005
New Revision: 161453

URL: http://svn.apache.org/viewcvs?view=rev&rev=161453
Log:
Fixed: DemuxingProtocolHandler.getHandler() doesn't climb up class hierarchy well.
Added: Some precondition checks to CumulativeProtocolDecoder

Modified:
    directory/network/trunk/src/java/org/apache/mina/protocol/DemuxingProtocolHandler.java
    directory/network/trunk/src/java/org/apache/mina/protocol/codec/CumulativeProtocolDecoder.java

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/DemuxingProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/DemuxingProtocolHandler.java?view=diff&r1=161452&r2=161453
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/DemuxingProtocolHandler.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/DemuxingProtocolHandler.java
Fri Apr 15 06:29:08 2005
@@ -60,7 +60,7 @@
      */
     public void messageReceived( ProtocolSession session, Object message )
     {
-        MessageHandler handler = getHandler( message.getClass() );
+        MessageHandler handler = findHandler( message.getClass() );
         if( handler != null )
         {
             handler.messageReceived( session, message );
@@ -72,37 +72,36 @@
         }
     }
 
-    private MessageHandler getHandler( Class type )
+    private MessageHandler findHandler( Class type )
     {
         MessageHandler handler = ( MessageHandler ) type2handler.get( type );
         if( handler == null )
         {
-            handler = getHandler( type, new HashSet() );
+            handler = findHandler( type, new HashSet() );
         }
 
         return handler;
     }
 
-    private MessageHandler getHandler( Class type, Set triedClassNames )
+    private MessageHandler findHandler( Class type, Set triedClasses )
     {
         MessageHandler handler;
 
-        String typeName = type.getName();
-        if( triedClassNames.contains( typeName ) )
+        if( triedClasses.contains( type ) )
             return null;
-        triedClassNames.add( typeName );
+        triedClasses.add( type );
 
-        handler = ( MessageHandler ) type2handler.get( typeName );
+        handler = ( MessageHandler ) type2handler.get( type );
         if( handler == null )
         {
-            handler = getHandler( type, triedClassNames );
+            handler = findHandler( type, triedClasses );
             if( handler != null )
                 return handler;
 
             Class[] interfaces = type.getInterfaces();
             for( int i = 0; i < interfaces.length; i ++ )
             {
-                handler = getHandler( interfaces[ i ], triedClassNames );
+                handler = findHandler( interfaces[ i ], triedClasses );
                 if( handler != null )
                     return handler;
             }

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/codec/CumulativeProtocolDecoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/codec/CumulativeProtocolDecoder.java?view=diff&r1=161452&r2=161453
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/codec/CumulativeProtocolDecoder.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/codec/CumulativeProtocolDecoder.java
Fri Apr 15 06:29:08 2005
@@ -85,6 +85,12 @@
     public void decode( ProtocolSession session, ByteBuffer in,
                         ProtocolDecoderOutput out ) throws ProtocolViolationException
     {
+        if( session.getTransportType().isStateless() )
+        {
+            throw new IllegalStateException(
+                    "This decoder doesn't work for stateless transport types." );
+        }
+
         put( in );
         
         ByteBuffer buf = this.buf;



Mime
View raw message