directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r439147 - in /directory/trunks/mina: core/src/main/java/org/apache/mina/filter/codec/ core/src/main/java/org/apache/mina/filter/codec/demux/ examples/src/main/java/org/apache/mina/examples/sumup/codec/
Date Fri, 01 Sep 2006 02:42:31 GMT
Author: trustin
Date: Thu Aug 31 19:42:30 2006
New Revision: 439147

URL: http://svn.apache.org/viewvc?rev=439147&view=rev
Log:
Fixed issue: DIRMINA-248 (ProtocolDecoder should get notified when a connection is closed)
* Added finishDecode() to MessageDecoder
* Added MessageDecoderAdapter for those who don't want finishDecode()
* Fixed compilation errors in SumUp example
* Removed unused method in SumUp message decoders


Added:
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/MessageDecoderAdapter.java
  (with props)
Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolDecoderAdapter.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/MessageDecoder.java
    directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/sumup/codec/AddMessageDecoder.java
    directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/sumup/codec/ResultMessageDecoder.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolDecoderAdapter.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolDecoderAdapter.java?rev=439147&r1=439146&r2=439147&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolDecoderAdapter.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/ProtocolDecoderAdapter.java
Thu Aug 31 19:42:30 2006
@@ -22,8 +22,9 @@
 import org.apache.mina.common.IoSession;
 
 /**
- * An abstract {@link ProtocolDecoder} implementation for those who don't have any
- * resources to dispose.
+ * An abstract {@link ProtocolDecoder} implementation for those who don't need
+ * {@link ProtocolDecoder#finishDecode(IoSession, ProtocolDecoderOutput)} nor
+ * {@link ProtocolDecoder#dispose(IoSession)} method.
  * 
  * @author The Apache Directory Project (mina-dev@directory.apache.org)
  * @version $Rev$, $Date$

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java?rev=439147&r1=439146&r2=439147&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java
Thu Aug 31 19:42:30 2006
@@ -333,7 +333,17 @@
             }
         }
 
-        public void dispose( IoSession session ) throws Exception
+        public void finishDecode( IoSession session, ProtocolDecoderOutput out ) throws Exception
+        {
+            if( currentDecoder == null )
+            {
+        	return;
+            }
+            
+            currentDecoder.finishDecode( session, out ); 
+	}
+
+	public void dispose( IoSession session ) throws Exception
         {
             super.dispose( session );
             

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/MessageDecoder.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/MessageDecoder.java?rev=439147&r1=439146&r2=439147&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/MessageDecoder.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/MessageDecoder.java
Thu Aug 31 19:42:30 2006
@@ -78,5 +78,17 @@
      * @throws Exception if the read data violated protocol specification 
      */
     MessageDecoderResult decode( IoSession session, ByteBuffer in,
-                         ProtocolDecoderOutput out ) throws Exception;
+                                 ProtocolDecoderOutput out ) throws Exception;
+    
+    /**
+     * Invoked when the specified <tt>session</tt> is closed while this decoder
was
+     * parsing the data.  This method is useful when you deal with the protocol which doesn't
+     * specify the length of a message such as HTTP response without <tt>content-length</tt>
+     * header. Implement this method to process the remaining data that
+     * {@link #decode(IoSession, ByteBuffer, ProtocolDecoderOutput)} method didn't process
+     * completely.
+     * 
+     * @throws Exception if the read data violated protocol specification
+     */
+    void finishDecode( IoSession session, ProtocolDecoderOutput out ) throws Exception;
 }

Added: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/MessageDecoderAdapter.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/MessageDecoderAdapter.java?rev=439147&view=auto
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/MessageDecoderAdapter.java
(added)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/MessageDecoderAdapter.java
Thu Aug 31 19:42:30 2006
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.demux;
+
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+
+/**
+ * An abstract {@link MessageDecoder} implementation for those who don't need to
+ * implement {@link MessageDecoder#finishDecode(IoSession, ProtocolDecoderOutput)}
+ * method.
+ * 
+ * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ */
+public abstract class MessageDecoderAdapter implements MessageDecoder
+{
+    /**
+     * Override this method to deal with the closed connection.
+     * The default implementation does nothing.
+     */
+    public void finishDecode( IoSession session, ProtocolDecoderOutput out ) throws Exception
+    {
+    }
+}

Propchange: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/codec/demux/MessageDecoderAdapter.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/sumup/codec/AddMessageDecoder.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/sumup/codec/AddMessageDecoder.java?rev=439147&r1=439146&r2=439147&view=diff
==============================================================================
--- directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/sumup/codec/AddMessageDecoder.java
(original)
+++ directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/sumup/codec/AddMessageDecoder.java
Thu Aug 31 19:42:30 2006
@@ -23,6 +23,7 @@
 import org.apache.mina.common.IoSession;
 import org.apache.mina.examples.sumup.message.AbstractMessage;
 import org.apache.mina.examples.sumup.message.AddMessage;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 import org.apache.mina.filter.codec.demux.MessageDecoder;
 
 /**
@@ -51,7 +52,7 @@
         return m;
     }
 
-    public void dispose() throws Exception
+    public void finishDecode( IoSession session, ProtocolDecoderOutput out ) throws Exception
     {
     }
 }

Modified: directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/sumup/codec/ResultMessageDecoder.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/sumup/codec/ResultMessageDecoder.java?rev=439147&r1=439146&r2=439147&view=diff
==============================================================================
--- directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/sumup/codec/ResultMessageDecoder.java
(original)
+++ directory/trunks/mina/examples/src/main/java/org/apache/mina/examples/sumup/codec/ResultMessageDecoder.java
Thu Aug 31 19:42:30 2006
@@ -23,6 +23,7 @@
 import org.apache.mina.common.IoSession;
 import org.apache.mina.examples.sumup.message.AbstractMessage;
 import org.apache.mina.examples.sumup.message.ResultMessage;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 import org.apache.mina.filter.codec.demux.MessageDecoder;
 
 /**
@@ -76,7 +77,7 @@
         }
     }
 
-    public void dispose() throws Exception
+    public void finishDecode( IoSession session, ProtocolDecoderOutput out ) throws Exception
     {
     }
 }



Mime
View raw message