directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r325867 - in /directory/network/trunk/src/java/org/apache/mina/filter/codec: DemuxingProtocolCodecFactory.java ProtocolCodecException.java ProtocolCodecFilter.java ProtocolDecoderException.java ProtocolEncoderException.java
Date Mon, 17 Oct 2005 09:17:17 GMT
Author: trustin
Date: Mon Oct 17 02:17:10 2005
New Revision: 325867

URL: http://svn.apache.org/viewcvs?rev=325867&view=rev
Log:
* Added ProtocolDecoderException for decoders
* Added ProtocolCodecExceptions for those who wants to detect both encoder and decoder exceptions

Added:
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecException.java
  (with props)
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderException.java
  (with props)
Modified:
    directory/network/trunk/src/java/org/apache/mina/filter/codec/DemuxingProtocolCodecFactory.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderException.java

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=325867&r1=325866&r2=325867&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:17:10 2005
@@ -149,7 +149,7 @@
             MessageEncoder encoder = findEncoder( type );
             if( encoder == null )
             {
-                throw new IllegalArgumentException( "Unexpected message type: " + type );
+                throw new ProtocolEncoderException( "Unexpected message type: " + type );
             }
             
             encoder.encode( session, message, out );

Added: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecException.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecException.java?rev=325867&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecException.java
(added)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecException.java
Mon Oct 17 02:17:10 2005
@@ -0,0 +1,64 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.mina.filter.codec;
+
+/**
+ * An exception that is thrown when {@link ProtocolEncoder} or
+ * {@link ProtocolDecoder} cannot understand or failed to validate
+ * data to process.
+ * 
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$
+ */
+public class ProtocolCodecException extends Exception
+{
+    private static final long serialVersionUID = 5939878548186330695L;
+
+    /**
+     * Constructs a new instance.
+     */
+    public ProtocolCodecException()
+    {
+    }
+
+    /**
+     * Constructs a new instance with the specified message.
+     */
+    public ProtocolCodecException( String message )
+    {
+        super( message );
+    }
+
+    /**
+     * Constructs a new instance with the specified cause.
+     */
+    public ProtocolCodecException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    /**
+     * Constructs a new instance with the specified message and the specified
+     * cause.
+     */
+    public ProtocolCodecException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}
\ No newline at end of file

Propchange: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecException.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

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=325867&r1=325866&r2=325867&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:17:10 2005
@@ -51,7 +51,7 @@
             }
             else
             {
-                pde = new ProtocolDecoderException();
+                pde = new ProtocolDecoderException( t );
             }
             pde.setHexdump( in.getHexDump() );
             throw pde;
@@ -95,7 +95,23 @@
         ProtocolEncoderOutputImpl encoderOut = getEncoderOut( session );
         encoderOut.nextFilter = nextFilter;
         
-        encoder.encode( session, writeRequest.getMessage(), encoderOut );
+        try
+        {
+            encoder.encode( session, writeRequest.getMessage(), encoderOut );
+        }
+        catch( Throwable t )
+        {
+            ProtocolEncoderException pee;
+            if( t instanceof ProtocolEncoderException )
+            {
+                pee = ( ProtocolEncoderException ) t;
+            }
+            else
+            {
+                pee = new ProtocolEncoderException( t );
+            }
+            throw pee;
+        }
 
         encoderOut.writeRequest = writeRequest;
         encoderOut.flush();
@@ -110,6 +126,7 @@
         finally
         {
             // Dispose encoder and decoder safely.
+            // FIXME: Think what we have to do for connectionless transport types
             ProtocolEncoder encoder = getEncoder( session );
             ProtocolDecoder decoder = getDecoder( session );
             try

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderException.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderException.java?rev=325867&r1=325866&r2=325867&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderException.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderException.java
Mon Oct 17 02:17:10 2005
@@ -28,7 +28,7 @@
  * @author Trustin Lee (trustin@apache.org)
  * @version $Rev$, $Date$
  */
-public class ProtocolDecoderException extends Exception
+public class ProtocolDecoderException extends ProtocolCodecException
 {
     private static final long serialVersionUID = 3545799879533408565L;
 

Added: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderException.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderException.java?rev=325867&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderException.java
(added)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderException.java
Mon Oct 17 02:17:10 2005
@@ -0,0 +1,63 @@
+/*
+ *   @(#) $Id$
+ *
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed 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.mina.filter.codec;
+
+/**
+ * An exception that is thrown when {@link ProtocolEncoder}
+ * cannot understand or failed to validate the specified message object.
+ * 
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$
+ */
+public class ProtocolEncoderException extends ProtocolCodecException
+{
+    private static final long serialVersionUID = 8752989973624459604L;
+
+    /**
+     * Constructs a new instance.
+     */
+    public ProtocolEncoderException()
+    {
+    }
+
+    /**
+     * Constructs a new instance with the specified message.
+     */
+    public ProtocolEncoderException( String message )
+    {
+        super( message );
+    }
+
+    /**
+     * Constructs a new instance with the specified cause.
+     */
+    public ProtocolEncoderException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    /**
+     * Constructs a new instance with the specified message and the specified
+     * cause.
+     */
+    public ProtocolEncoderException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+}
\ No newline at end of file

Propchange: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderException.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision



Mime
View raw message