directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r325865 - in /directory/network/trunk/src: examples/org/apache/mina/examples/reverser/ examples/org/apache/mina/examples/sumup/codec/ java/org/apache/mina/filter/codec/ test/org/apache/mina/filter/codec/
Date Mon, 17 Oct 2005 09:08:25 GMT
Author: trustin
Date: Mon Oct 17 02:08:04 2005
New Revision: 325865

URL: http://svn.apache.org/viewcvs?rev=325865&view=rev
Log:
* Added dispose() method to:
** ProtocolEncoder
** ProtocolDecoder
** MessageEncoder
** MessageDecoder

* Renamed ProtocolViolationException to ProtocolDecoderException
* Now all encoders and decoders can throw any exceptions

Added:
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderException.java
      - copied, changed from r325858, directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolViolationException.java
Removed:
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolViolationException.java
Modified:
    directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java
    directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineEncoder.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageDecoder.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageEncoder.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AddMessageDecoder.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AddMessageEncoder.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageDecoder.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageEncoder.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/DemuxingProtocolCodecFactory.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/MessageDecoder.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoder.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoder.java
    directory/network/trunk/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java
(original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java
Mon Oct 17 02:08:04 2005
@@ -21,8 +21,8 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolDecoderException;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
-import org.apache.mina.filter.codec.ProtocolViolationException;
 
 /**
  * Decodes a text line into a string.
@@ -37,7 +37,7 @@
 
     public void decode( IoSession session, ByteBuffer in,
                         ProtocolDecoderOutput out )
-            throws ProtocolViolationException
+            throws Exception
     {
         do
         {
@@ -59,9 +59,13 @@
             if( decodeBuf.length() > 256 )
             {
                 decodeBuf.delete( 0, decodeBuf.length() );
-                throw new ProtocolViolationException( "The line is too long." );
+                throw new ProtocolDecoderException( "The line is too long." );
             }
         }
         while( in.hasRemaining() );
+    }
+
+    public void dispose() throws Exception
+    {
     }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineEncoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineEncoder.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineEncoder.java
(original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineEncoder.java
Mon Oct 17 02:08:04 2005
@@ -22,7 +22,6 @@
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.codec.ProtocolEncoder;
 import org.apache.mina.filter.codec.ProtocolEncoderOutput;
-import org.apache.mina.filter.codec.ProtocolViolationException;
 
 /**
  * Encodes a string into a text line which ends with <code>"\r\n"</code>.
@@ -35,15 +34,14 @@
 
     public void encode( IoSession session, Object message,
                         ProtocolEncoderOutput out )
-            throws ProtocolViolationException
+            throws Exception
     {
 
         String val = message.toString();
         // Don't accept too long strings.
         if( val.length() > 256 )
         {
-            throw new ProtocolViolationException(
-                                                  "Cannot encode too long string." );
+            throw new IllegalArgumentException( "Cannot encode too long string." );
         }
 
         val += "\r\n";
@@ -56,5 +54,9 @@
 
         buf.flip();
         out.write( buf );
+    }
+
+    public void dispose() throws Exception
+    {
     }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageDecoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageDecoder.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageDecoder.java
(original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageDecoder.java
Mon Oct 17 02:08:04 2005
@@ -24,7 +24,6 @@
 import org.apache.mina.filter.codec.MessageDecoder;
 import org.apache.mina.filter.codec.MessageDecoderResult;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
-import org.apache.mina.filter.codec.ProtocolViolationException;
 
 /**
  * A {@link MessageDecoder} that decodes message header and forwards
@@ -63,7 +62,7 @@
         return MessageDecoderResult.NOT_OK;
     }
 
-    public MessageDecoderResult decode( IoSession session, ByteBuffer in, ProtocolDecoderOutput
out ) throws ProtocolViolationException
+    public MessageDecoderResult decode( IoSession session, ByteBuffer in, ProtocolDecoderOutput
out ) throws Exception
     {
         // Try to skip header if not read.
         if( !readHeader )

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageEncoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageEncoder.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageEncoder.java
(original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AbstractMessageEncoder.java
Mon Oct 17 02:08:04 2005
@@ -23,7 +23,6 @@
 import org.apache.mina.examples.sumup.message.AbstractMessage;
 import org.apache.mina.filter.codec.MessageEncoder;
 import org.apache.mina.filter.codec.ProtocolEncoderOutput;
-import org.apache.mina.filter.codec.ProtocolViolationException;
 
 /**
  * A {@link MessageEncoder} that encodes message header and forwards
@@ -41,7 +40,7 @@
         this.type = type;
     }
 
-    public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws
ProtocolViolationException
+    public void encode( IoSession session, Object message, ProtocolEncoderOutput out ) throws
Exception
     {
         AbstractMessage m = ( AbstractMessage ) message ;
         ByteBuffer buf = ByteBuffer.allocate( 16 );

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AddMessageDecoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AddMessageDecoder.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AddMessageDecoder.java
(original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AddMessageDecoder.java
Mon Oct 17 02:08:04 2005
@@ -49,4 +49,8 @@
         m.setValue( in.getInt() );
         return m;
     }
+
+    public void dispose() throws Exception
+    {
+    }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AddMessageEncoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AddMessageEncoder.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AddMessageEncoder.java
(original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/AddMessageEncoder.java
Mon Oct 17 02:08:04 2005
@@ -60,4 +60,8 @@
     {
         return TYPES;
     }
+
+    public void dispose() throws Exception
+    {
+    }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageDecoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageDecoder.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageDecoder.java
(original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageDecoder.java
Mon Oct 17 02:08:04 2005
@@ -74,4 +74,8 @@
             return m;
         }
     }
+
+    public void dispose() throws Exception
+    {
+    }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageEncoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageEncoder.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageEncoder.java
(original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/ResultMessageEncoder.java
Mon Oct 17 02:08:04 2005
@@ -69,4 +69,8 @@
         return TYPES;
     }
 
+    public void dispose() throws Exception
+    {
+    }
+
 }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
Mon Oct 17 02:08:04 2005
@@ -81,7 +81,7 @@
      *                               <tt>true</tt> not consuming the cumulative
buffer.
      */
     public void decode( IoSession session, ByteBuffer in,
-                        ProtocolDecoderOutput out ) throws ProtocolViolationException
+                        ProtocolDecoderOutput out ) throws Exception
     {
         if( session.getTransportType().isStateless() )
         {
@@ -133,8 +133,8 @@
      *         and you want to have <tt>doDecode</tt> method invoked again.
      *         Return <tt>false</tt> if remaining data is not enough to decode,
      *         then this method will be invoked again when more data is cumulated.
-     * @throws ProtocolViolationException if cannot decode <tt>in</tt>.
+     * @throws Exception if cannot decode <tt>in</tt>.
      */
     protected abstract boolean doDecode( IoSession session, ByteBuffer in,
-                                         ProtocolDecoderOutput out ) throws ProtocolViolationException;
+                                         ProtocolDecoderOutput out ) throws Exception;
 }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/DemuxingProtocolCodecFactory.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/DemuxingProtocolCodecFactory.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/DemuxingProtocolCodecFactory.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/DemuxingProtocolCodecFactory.java
Mon Oct 17 02:08:04 2005
@@ -23,6 +23,7 @@
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.logging.Logger;
 
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoSession;
@@ -42,6 +43,7 @@
  * @see MessageDecoder
  */
 public class DemuxingProtocolCodecFactory implements ProtocolCodecFactory {
+    private static final Logger log = Logger.getLogger( DemuxingProtocolCodecFactory.class.getName()
);
 
     private MessageDecoderFactory[] decoderFactories = new MessageDecoderFactory[0];
     private MessageEncoderFactory[] encoderFactories = new MessageEncoderFactory[0];
@@ -141,13 +143,13 @@
         }
         
         public void encode( IoSession session, Object message,
-                            ProtocolEncoderOutput out ) throws ProtocolViolationException
+                            ProtocolEncoderOutput out ) throws Exception
         {
             Class type = message.getClass();
             MessageEncoder encoder = findEncoder( type );
             if( encoder == null )
             {
-                throw new ProtocolViolationException( "Unexpected message type: " + type
);
+                throw new IllegalArgumentException( "Unexpected message type: " + type );
             }
             
             encoder.encode( session, message, out );
@@ -192,6 +194,24 @@
             else
                 return encoder;
         }
+
+        public void dispose() throws Exception
+        {
+            for( Iterator i = encoders.values().iterator(); i.hasNext(); )
+            {
+                MessageEncoder encoder = ( MessageEncoder ) i.next();
+                try
+                {
+                    encoder.dispose();
+                }
+                catch( Throwable t )
+                {
+                    log.warning(
+                            "Failed to dispose: " + encoder.getClass().getName() +
+                            " (" + encoder + ')' );
+                }
+            }
+        }
     }
     
     private class ProtocolDecoderImpl extends CumulativeProtocolDecoder
@@ -212,7 +232,7 @@
         }
 
         protected boolean doDecode( IoSession session, ByteBuffer in,
-                                    ProtocolDecoderOutput out ) throws ProtocolViolationException
+                                    ProtocolDecoderOutput out ) throws Exception
         {
             if( currentDecoder == null )
             {
@@ -254,7 +274,7 @@
                 {
                     // Throw an exception if all decoders cannot decode data.
                     in.position( in.limit() ); // Skip data
-                    throw new ProtocolViolationException(
+                    throw new ProtocolDecoderException(
                             "No appropriate message decoder: " + in.getHexDump() );
                 }
                 
@@ -277,11 +297,29 @@
             }
             else if( result == MessageDecoder.NOT_OK )
             {
-                throw new ProtocolViolationException( "Message decoder returned NOT_OK."
);
+                throw new ProtocolDecoderException( "Message decoder returned NOT_OK." );
             }
             else
             {
                 throw new IllegalStateException( "Unexpected decode result (see your decode()):
" + result );
+            }
+        }
+
+        public void dispose() throws Exception
+        {
+            for( int i = decoders.length - 1; i >= 0; i -- )
+            {
+                MessageDecoder decoder = decoders[ i ];
+                try
+                {
+                    decoder.dispose();
+                }
+                catch( Throwable t )
+                {
+                    log.warning(
+                            "Failed to dispose: " + decoder.getClass().getName() +
+                            " (" + decoder + ')' );
+                }
             }
         }
     }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/MessageDecoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/MessageDecoder.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/MessageDecoder.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/MessageDecoder.java Mon
Oct 17 02:08:04 2005
@@ -74,9 +74,15 @@
      *         {@link #NEED_DATA} if you need more data to finish decoding current message.
      *         {@link #NOT_OK} if you cannot decode current message due to protocol specification
violation.
      *         
-     * @throws ProtocolViolationException if the read data violated protocol
-     *                                    specification 
+     * @throws Exception if the read data violated protocol specification 
      */
     MessageDecoderResult decode( IoSession session, ByteBuffer in,
-                         ProtocolDecoderOutput out ) throws ProtocolViolationException;
+                         ProtocolDecoderOutput out ) throws Exception;
+    
+    /**
+     * Releases all resources related with this decoder.
+     * 
+     * @throws Exception if failed to dispose all resources
+     */
+    void dispose() throws Exception;
 }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
Mon Oct 17 02:08:04 2005
@@ -1,5 +1,7 @@
 package org.apache.mina.filter.codec;
 
+import java.util.logging.Logger;
+
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.ByteBufferProxy;
 import org.apache.mina.common.IoFilterAdapter;
@@ -9,6 +11,8 @@
 
 public class ProtocolCodecFilter extends IoFilterAdapter
 {
+    private static final Logger log = Logger.getLogger( ProtocolCodecFilter.class.getName()
);
+
     public static final String ENCODER = ProtocolCodecFilter.class.getName() + ".encoder";
     public static final String DECODER = ProtocolCodecFilter.class.getName() + ".decoder";
     public static final String ENCODER_OUT = ProtocolCodecFilter.class.getName() + ".encoderOutput";
@@ -38,10 +42,19 @@
                 decoder.decode( session, in, decoderOut );
             }
         }
-        catch( ProtocolViolationException pve )
+        catch( Throwable t )
         {
-            pve.setHexdump( in.getHexDump() );
-            throw pve;
+            ProtocolDecoderException pde;
+            if( t instanceof ProtocolDecoderException )
+            {
+                pde = ( ProtocolDecoderException ) t;
+            }
+            else
+            {
+                pde = new ProtocolDecoderException();
+            }
+            pde.setHexdump( in.getHexDump() );
+            throw pde;
         }
         finally
         {
@@ -88,6 +101,39 @@
         encoderOut.flush();
     }
     
+    public void sessionClosed( NextFilter nextFilter, IoSession session ) throws Exception
+    {
+        try
+        {
+            nextFilter.sessionClosed( session );
+        }
+        finally
+        {
+            // Dispose encoder and decoder safely.
+            ProtocolEncoder encoder = getEncoder( session );
+            ProtocolDecoder decoder = getDecoder( session );
+            try
+            {
+                encoder.dispose();
+            }
+            catch( Throwable t )
+            {
+                log.warning( "Failed to dispose: " + encoder.getClass().getName() +
+                        " (" + encoder + ')' );
+            }
+            
+            try
+            {
+                decoder.dispose();
+            }
+            catch( Throwable t )
+            {
+                log.warning( "Falied to dispose: " + decoder.getClass().getName() +
+                        " (" + decoder + ')' );
+            }
+        }
+    }
+
     private ProtocolEncoder getEncoder( IoSession session )
     {
         ProtocolEncoder encoder = ( ProtocolEncoder ) session.getAttribute( ENCODER );

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoder.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoder.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoder.java Mon
Oct 17 02:08:04 2005
@@ -43,9 +43,15 @@
      * method with read data, and then the decoder implementation puts decoded
      * messages into {@link ProtocolDecoderOutput}.
      * 
-     * @throws ProtocolViolationException if the read data violated protocol
-     *                                    specification 
+     * @throws Exception if the read data violated protocol specification
      */
     void decode( IoSession session, ByteBuffer in,
-                 ProtocolDecoderOutput out ) throws ProtocolViolationException;
+                 ProtocolDecoderOutput out ) throws Exception;
+    
+    /**
+     * Releases all resources related with this decoder.
+     * 
+     * @throws Exception if failed to dispose all resources
+     */
+    void dispose() throws Exception;
 }

Copied: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderException.java
(from r325858, directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolViolationException.java)
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderException.java?p2=directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderException.java&p1=directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolViolationException.java&r1=325858&r2=325865&rev=325865&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolViolationException.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderException.java
Mon Oct 17 02:08:04 2005
@@ -21,15 +21,14 @@
 import org.apache.mina.common.ByteBuffer;
 
 /**
- * An exception that is thrown when {@link ProtocolEncoder} cannot understand or
- * failed to validate the specified message, or when {@link ProtocolDecoder}
+ * An exception that is thrown when {@link ProtocolDecoder}
  * cannot understand or failed to validate the specified {@link ByteBuffer}
  * content.
  * 
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
-public class ProtocolViolationException extends Exception
+public class ProtocolDecoderException extends Exception
 {
     private static final long serialVersionUID = 3545799879533408565L;
 
@@ -38,14 +37,14 @@
     /**
      * Constructs a new instance.
      */
-    public ProtocolViolationException()
+    public ProtocolDecoderException()
     {
     }
 
     /**
      * Constructs a new instance with the specified message.
      */
-    public ProtocolViolationException( String message )
+    public ProtocolDecoderException( String message )
     {
         super( message );
     }
@@ -53,7 +52,7 @@
     /**
      * Constructs a new instance with the specified cause.
      */
-    public ProtocolViolationException( Throwable cause )
+    public ProtocolDecoderException( Throwable cause )
     {
         super( cause );
     }
@@ -62,7 +61,7 @@
      * Constructs a new instance with the specified message and the specified
      * cause.
      */
-    public ProtocolViolationException( String message, Throwable cause )
+    public ProtocolDecoderException( String message, Throwable cause )
     {
         super( message, cause );
     }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoder.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoder.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoder.java Mon
Oct 17 02:08:04 2005
@@ -46,9 +46,16 @@
      * the encoder implementation puts encoded {@link ByteBuffer}s into
      * {@link ProtocolEncoderOutput}.
      * 
-     * @throws ProtocolViolationException if the message violated protocol
-     *                                    specification
+     * @throws Exception if the message violated protocol specification
      */
     void encode( IoSession session, Object message,
-                 ProtocolEncoderOutput out ) throws ProtocolViolationException;
+                 ProtocolEncoderOutput out ) throws Exception;
+
+    
+    /**
+     * Releases all resources related with this encoder.
+     * 
+     * @throws Exception if failed to dispose all resources
+     */
+    void dispose() throws Exception;
 }

Modified: directory/network/trunk/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java?rev=325865&r1=325864&r2=325865&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
Mon Oct 17 02:08:04 2005
@@ -126,7 +126,7 @@
         }
 
         protected boolean doDecode( IoSession session, ByteBuffer in,
-                                    ProtocolDecoderOutput out ) throws ProtocolViolationException
+                                    ProtocolDecoderOutput out ) throws Exception
         {
             Assert.assertTrue( in.hasRemaining() );
             if( in.remaining() < 4 )
@@ -135,6 +135,10 @@
             out.write( new Integer( in.getInt() ) );
             return true;
         }
+
+        public void dispose() throws Exception
+        {
+        }
         
     }
     
@@ -166,8 +170,12 @@
         }
 
         protected boolean doDecode( IoSession session, ByteBuffer in,
-                                    ProtocolDecoderOutput out ) throws ProtocolViolationException
{
+                                    ProtocolDecoderOutput out ) throws Exception {
             return true;
+        }
+
+        public void dispose() throws Exception
+        {
         }
     }
     



Mime
View raw message