directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r350169 [9/16] - in /directory/network: branches/chain_refactor/src/java/org/apache/mina/common/ trunk/src/examples/org/apache/mina/examples/echoserver/ trunk/src/examples/org/apache/mina/examples/httpserver/ trunk/src/examples/org/apache/m...
Date Thu, 01 Dec 2005 05:19:07 GMT
Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderAdapter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderAdapter.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderAdapter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderAdapter.java Wed Nov 30 21:17:41 2005
@@ -1,39 +1,39 @@
-/*
- *   @(#) $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;
-
-import org.apache.mina.common.IoSession;
-
-/**
- * An abstract {@link ProtocolDecoder} implementation for those who don't have any
- * resources to dispose.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public abstract class ProtocolDecoderAdapter implements ProtocolDecoder
-{
-    /**
-     * Override this method dispose all resources related with this decoder.
-     * The default implementation does nothing.
-     */
-    public void dispose( IoSession session ) throws Exception
-    {
-    }
-}
+/*
+ *   @(#) $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;
+
+import org.apache.mina.common.IoSession;
+
+/**
+ * An abstract {@link ProtocolDecoder} implementation for those who don't have any
+ * resources to dispose.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public abstract class ProtocolDecoderAdapter implements ProtocolDecoder
+{
+    /**
+     * Override this method dispose all resources related with this decoder.
+     * The default implementation does nothing.
+     */
+    public void dispose( IoSession session ) throws Exception
+    {
+    }
+}

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=350169&r1=350168&r2=350169&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 Wed Nov 30 21:17:41 2005
@@ -1,111 +1,111 @@
-/*
- *   @(#) $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;
-
-import org.apache.mina.common.ByteBuffer;
-
-/**
- * An exception that is thrown when {@link ProtocolDecoder}
- * cannot understand or failed to validate the specified {@link ByteBuffer}
- * content.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public class ProtocolDecoderException extends ProtocolCodecException
-{
-    private static final long serialVersionUID = 3545799879533408565L;
-
-	private String hexdump;
-
-    /**
-     * Constructs a new instance.
-     */
-    public ProtocolDecoderException()
-    {
-    }
-
-    /**
-     * Constructs a new instance with the specified message.
-     */
-    public ProtocolDecoderException( String message )
-    {
-        super( message );
-    }
-
-    /**
-     * Constructs a new instance with the specified cause.
-     */
-    public ProtocolDecoderException( Throwable cause )
-    {
-        super( cause );
-    }
-
-    /**
-     * Constructs a new instance with the specified message and the specified
-     * cause.
-     */
-    public ProtocolDecoderException( String message, Throwable cause )
-    {
-        super( message, cause );
-    }
-
-    /**
-     * Returns the message and the hexdump of the unknown part.
-     */
-    public String getMessage()
-    {
-        String message = super.getMessage();
-
-        if( message == null )
-        {
-            message = "";
-        }
-
-        if( hexdump != null )
-        {
-            return message + ( ( message.length() > 0 ) ? " " : "" )
-                   + "(Hexdump: " + hexdump + ')';
-        }
-        else
-        {
-            return message;
-        }
-    }
-
-    /**
-     * Returns the hexdump of the unknown message part.
-     */
-    public String getHexdump()
-    {
-        return hexdump;
-    }
-
-    /**
-     * Sets the hexdump of the unknown message part.
-     */
-    public void setHexdump( String hexdump )
-    {
-        if( this.hexdump != null )
-        {
-            throw new IllegalStateException( "Hexdump cannot be set more than once." );
-        }
-        this.hexdump = hexdump;
-    }
+/*
+ *   @(#) $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;
+
+import org.apache.mina.common.ByteBuffer;
+
+/**
+ * An exception that is thrown when {@link ProtocolDecoder}
+ * cannot understand or failed to validate the specified {@link ByteBuffer}
+ * content.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class ProtocolDecoderException extends ProtocolCodecException
+{
+    private static final long serialVersionUID = 3545799879533408565L;
+
+	private String hexdump;
+
+    /**
+     * Constructs a new instance.
+     */
+    public ProtocolDecoderException()
+    {
+    }
+
+    /**
+     * Constructs a new instance with the specified message.
+     */
+    public ProtocolDecoderException( String message )
+    {
+        super( message );
+    }
+
+    /**
+     * Constructs a new instance with the specified cause.
+     */
+    public ProtocolDecoderException( Throwable cause )
+    {
+        super( cause );
+    }
+
+    /**
+     * Constructs a new instance with the specified message and the specified
+     * cause.
+     */
+    public ProtocolDecoderException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    /**
+     * Returns the message and the hexdump of the unknown part.
+     */
+    public String getMessage()
+    {
+        String message = super.getMessage();
+
+        if( message == null )
+        {
+            message = "";
+        }
+
+        if( hexdump != null )
+        {
+            return message + ( ( message.length() > 0 ) ? " " : "" )
+                   + "(Hexdump: " + hexdump + ')';
+        }
+        else
+        {
+            return message;
+        }
+    }
+
+    /**
+     * Returns the hexdump of the unknown message part.
+     */
+    public String getHexdump()
+    {
+        return hexdump;
+    }
+
+    /**
+     * Sets the hexdump of the unknown message part.
+     */
+    public void setHexdump( String hexdump )
+    {
+        if( this.hexdump != null )
+        {
+            throw new IllegalStateException( "Hexdump cannot be set more than once." );
+        }
+        this.hexdump = hexdump;
+    }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderOutput.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderOutput.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderOutput.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderOutput.java Wed Nov 30 21:17:41 2005
@@ -1,39 +1,39 @@
-/*
- *   @(#) $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;
-
-/**
- * Callback for {@link ProtocolDecoder} to generate decoded messages.
- * {@link ProtocolDecoder} must call {@link #write(Object)} for each decoded
- * messages.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public interface ProtocolDecoderOutput
-{
-    /**
-     * Callback for {@link ProtocolDecoder} to generate decoded messages.
-     * {@link ProtocolDecoder} must call {@link #write(Object)} for each
-     * decoded messages.
-     * 
-     * @param message the decoded message
-     */
-    void write( Object message );
+/*
+ *   @(#) $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;
+
+/**
+ * Callback for {@link ProtocolDecoder} to generate decoded messages.
+ * {@link ProtocolDecoder} must call {@link #write(Object)} for each decoded
+ * messages.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public interface ProtocolDecoderOutput
+{
+    /**
+     * Callback for {@link ProtocolDecoder} to generate decoded messages.
+     * {@link ProtocolDecoder} must call {@link #write(Object)} for each
+     * decoded messages.
+     * 
+     * @param message the decoded message
+     */
+    void write( Object message );
 }

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=350169&r1=350168&r2=350169&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 Wed Nov 30 21:17:41 2005
@@ -1,61 +1,61 @@
-/*
- *   @(#) $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;
-
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-
-/**
- * Encodes higher-level message objects into binary or protocol-specific data.
- * MINA invokes {@link #encode(IoSession, Object, ProtocolEncoderOutput)}
- * method with message which is popped from the session write queue, and then
- * the encoder implementation puts encoded {@link ByteBuffer}s into
- * {@link ProtocolEncoderOutput} by calling
- * {@link ProtocolEncoderOutput#write(ByteBuffer)}.
- * <p>
- * Please refer to
- * <a href="../../../../../xref-examples/org/apache/mina/examples/reverser/TextLineEncoder.html"><code>TextLineEncoder</code></a>
- * example. 
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public interface ProtocolEncoder
-{
-
-    /**
-     * Encodes higher-level message objects into binary or protocol-specific data.
-     * MINA invokes {@link #encode(IoSession, Object, ProtocolEncoderOutput)}
-     * method with message which is popped from the session write queue, and then
-     * the encoder implementation puts encoded {@link ByteBuffer}s into
-     * {@link ProtocolEncoderOutput}.
-     * 
-     * @throws Exception if the message violated protocol specification
-     */
-    void encode( IoSession session, Object message,
-                 ProtocolEncoderOutput out ) throws Exception;
-
-    
-    /**
-     * Releases all resources related with this encoder.
-     * 
-     * @throws Exception if failed to dispose all resources
-     */
-    void dispose( IoSession session ) throws Exception;
+/*
+ *   @(#) $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;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+
+/**
+ * Encodes higher-level message objects into binary or protocol-specific data.
+ * MINA invokes {@link #encode(IoSession, Object, ProtocolEncoderOutput)}
+ * method with message which is popped from the session write queue, and then
+ * the encoder implementation puts encoded {@link ByteBuffer}s into
+ * {@link ProtocolEncoderOutput} by calling
+ * {@link ProtocolEncoderOutput#write(ByteBuffer)}.
+ * <p>
+ * Please refer to
+ * <a href="../../../../../xref-examples/org/apache/mina/examples/reverser/TextLineEncoder.html"><code>TextLineEncoder</code></a>
+ * example. 
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public interface ProtocolEncoder
+{
+
+    /**
+     * Encodes higher-level message objects into binary or protocol-specific data.
+     * MINA invokes {@link #encode(IoSession, Object, ProtocolEncoderOutput)}
+     * method with message which is popped from the session write queue, and then
+     * the encoder implementation puts encoded {@link ByteBuffer}s into
+     * {@link ProtocolEncoderOutput}.
+     * 
+     * @throws Exception if the message violated protocol specification
+     */
+    void encode( IoSession session, Object message,
+                 ProtocolEncoderOutput out ) throws Exception;
+
+    
+    /**
+     * Releases all resources related with this encoder.
+     * 
+     * @throws Exception if failed to dispose all resources
+     */
+    void dispose( IoSession session ) throws Exception;
 }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderAdapter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderAdapter.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderAdapter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderAdapter.java Wed Nov 30 21:17:41 2005
@@ -1,39 +1,39 @@
-/*
- *   @(#) $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;
-
-import org.apache.mina.common.IoSession;
-
-/**
- * An abstract {@link ProtocolEncoder} implementation for those who don't have any
- * resources to dispose.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public abstract class ProtocolEncoderAdapter implements ProtocolEncoder
-{
-    /**
-     * Override this method dispose all resources related with this encoder.
-     * The default implementation does nothing.
-     */
-    public void dispose( IoSession session ) throws Exception
-    {
-    }
-}
+/*
+ *   @(#) $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;
+
+import org.apache.mina.common.IoSession;
+
+/**
+ * An abstract {@link ProtocolEncoder} implementation for those who don't have any
+ * resources to dispose.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public abstract class ProtocolEncoderAdapter implements ProtocolEncoder
+{
+    /**
+     * Override this method dispose all resources related with this encoder.
+     * The default implementation does nothing.
+     */
+    public void dispose( IoSession session ) throws Exception
+    {
+    }
+}

Modified: 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=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderException.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderException.java Wed Nov 30 21:17:41 2005
@@ -1,63 +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 The Apache Directory Project (dev@directory.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 );
-    }
+/*
+ *   @(#) $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 The Apache Directory Project (dev@directory.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 );
+    }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderOutput.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderOutput.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderOutput.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderOutput.java Wed Nov 30 21:17:41 2005
@@ -1,58 +1,58 @@
-/*
- *   @(#) $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;
-
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.WriteFuture;
-
-/**
- * Callback for {@link ProtocolEncoder} to generate encoded {@link ByteBuffer}s.
- * {@link ProtocolEncoder} must call {@link #write(ByteBuffer)} for each decoded
- * messages.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public interface ProtocolEncoderOutput
-{
-    /**
-     * Callback for {@link ProtocolEncoder} to generate encoded
-     * {@link ByteBuffer}s. {@link ProtocolEncoder} must call
-     * {@link #write(ByteBuffer)} for each decoded messages.
-     * 
-     * @param buf the buffer which contains encoded data
-     */
-    void write( ByteBuffer buf );
-    
-    /**
-     * Merges all buffers you wrote via {@link #write(ByteBuffer)} into
-     * one {@link ByteBuffer} and replaces the old fragmented ones with it.
-     * This method is useful when you want to control the way MINA generates
-     * network packets.
-     */
-    void mergeAll();
-    
-    /**
-     * Flushes all buffers you wrote via {@link #write(ByteBuffer)} to
-     * the session.  This operation is asynchronous; please wait for
-     * the returned {@link WriteFuture} if you want to wait for
-     * the buffers flushed.
-     */
-    WriteFuture flush();
+/*
+ *   @(#) $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;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.WriteFuture;
+
+/**
+ * Callback for {@link ProtocolEncoder} to generate encoded {@link ByteBuffer}s.
+ * {@link ProtocolEncoder} must call {@link #write(ByteBuffer)} for each decoded
+ * messages.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public interface ProtocolEncoderOutput
+{
+    /**
+     * Callback for {@link ProtocolEncoder} to generate encoded
+     * {@link ByteBuffer}s. {@link ProtocolEncoder} must call
+     * {@link #write(ByteBuffer)} for each decoded messages.
+     * 
+     * @param buf the buffer which contains encoded data
+     */
+    void write( ByteBuffer buf );
+    
+    /**
+     * Merges all buffers you wrote via {@link #write(ByteBuffer)} into
+     * one {@link ByteBuffer} and replaces the old fragmented ones with it.
+     * This method is useful when you want to control the way MINA generates
+     * network packets.
+     */
+    void mergeAll();
+    
+    /**
+     * Flushes all buffers you wrote via {@link #write(ByteBuffer)} to
+     * the session.  This operation is asynchronous; please wait for
+     * the returned {@link WriteFuture} if you want to wait for
+     * the buffers flushed.
+     */
+    WriteFuture flush();
 }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java Wed Nov 30 21:17:41 2005
@@ -1,431 +1,431 @@
-/*
- *   @(#) $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.demux;
-
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
-import org.apache.mina.filter.codec.ProtocolCodecFactory;
-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.ProtocolEncoder;
-import org.apache.mina.filter.codec.ProtocolEncoderException;
-import org.apache.mina.filter.codec.ProtocolEncoderOutput;
-import org.apache.mina.util.IdentityHashSet;
-
-/**
- * A composite {@link ProtocolCodecFactory} that consists of multiple
- * {@link MessageEncoder}s and {@link MessageDecoder}s.
- * {@link ProtocolEncoder} and {@link ProtocolDecoder} this factory
- * returns demultiplex incoming messages and buffers to
- * appropriate {@link MessageEncoder}s and {@link MessageDecoder}s. 
- * 
- * <h2>Disposing resources acquired by {@link MessageEncoder} and {@link MessageDecoder}</h2>
- * <p>
- * Make your {@link MessageEncoder} and {@link MessageDecoder} to put all
- * resources that need to be released as a session attribute.  {@link #disposeCodecResources(IoSession)}
- * method will be invoked when a session is closed.  Override {@link #disposeCodecResources(IoSession)}
- * to release the resources you've put as an attribute.
- * <p>
- * We didn't provide any <tt>dispose</tt> method for {@link MessageEncoder} and {@link MessageDecoder}
- * because they can give you a big performance penalty in case you have a lot of
- * message types to handle.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- * 
- * @see MessageEncoder
- * @see MessageDecoder
- */
-public class DemuxingProtocolCodecFactory implements ProtocolCodecFactory {
-    private MessageDecoderFactory[] decoderFactories = new MessageDecoderFactory[0];
-    private MessageEncoderFactory[] encoderFactories = new MessageEncoderFactory[0];
-    
-    public DemuxingProtocolCodecFactory()
-    {
-    }
-    
-    public void register( Class encoderOrDecoderClass )
-    {
-        if( encoderOrDecoderClass == null )
-        {
-            throw new NullPointerException( "encoderOrDecoderClass" );
-        }
-
-        boolean registered = false;
-        if( MessageEncoder.class.isAssignableFrom( encoderOrDecoderClass ) )
-        {
-            register( new DefaultConstructorMessageEncoderFactory( encoderOrDecoderClass ) );
-            registered = true;
-        }
-        
-        if( MessageDecoder.class.isAssignableFrom( encoderOrDecoderClass ) )
-        {
-            register( new DefaultConstructorMessageDecoderFactory( encoderOrDecoderClass ) );
-            registered = true;
-        }
-        
-        if( !registered )
-        {
-            throw new IllegalArgumentException( "Unregisterable type: " + encoderOrDecoderClass );
-        }
-    }
-
-    
-    public void register( MessageEncoder encoder )
-    {
-        register( new SingletonMessageEncoderFactory( encoder ) );
-    }
-    
-    public void register( MessageEncoderFactory factory )
-    {
-        if( factory == null )
-        {
-            throw new NullPointerException( "factory" );
-        }
-        MessageEncoderFactory[] encoderFactories = this.encoderFactories;
-        MessageEncoderFactory[] newEncoderFactories = new MessageEncoderFactory[ encoderFactories.length + 1 ];
-        System.arraycopy( encoderFactories, 0, newEncoderFactories, 0, encoderFactories.length );
-        newEncoderFactories[ encoderFactories.length ] = factory;
-        this.encoderFactories = newEncoderFactories;
-    }
-    
-    public void register( MessageDecoder decoder )
-    {
-        register( new SingletonMessageDecoderFactory( decoder ) );
-    }
-    
-    public void register( MessageDecoderFactory factory )
-    {
-        if( factory == null )
-        {
-            throw new NullPointerException( "factory" );
-        }
-        MessageDecoderFactory[] decoderFactories = this.decoderFactories;
-        MessageDecoderFactory[] newDecoderFactories = new MessageDecoderFactory[ decoderFactories.length + 1 ];
-        System.arraycopy( decoderFactories, 0, newDecoderFactories, 0, decoderFactories.length );
-        newDecoderFactories[ decoderFactories.length ] = factory;
-        this.decoderFactories = newDecoderFactories;
-    }
-    
-    public ProtocolEncoder getEncoder() {
-        return new ProtocolEncoderImpl();
-    }
-
-    public ProtocolDecoder getDecoder() {
-        return new ProtocolDecoderImpl();
-    }
-    
-    /**
-     * Implement this method to release all resources acquired to perform
-     * encoding and decoding messages for the specified <tt>session</tt>.
-     * By default, this method does nothing.
-     * 
-     * @param session the session that requires resource deallocation now
-     */
-    protected void disposeCodecResources( IoSession session )
-    {
-        // Do nothing by default; let users implement it as they want.
-    }
-    
-    private class ProtocolEncoderImpl implements ProtocolEncoder
-    {
-        private final Map encoders = new IdentityHashMap();
-        
-        private ProtocolEncoderImpl()
-        {
-            MessageEncoderFactory[] encoderFactories = DemuxingProtocolCodecFactory.this.encoderFactories;
-            for( int i = encoderFactories.length - 1; i >= 0; i-- )
-            {
-                MessageEncoder encoder = encoderFactories[ i ].newEncoder();
-                Iterator it = encoder.getMessageTypes().iterator();
-                while( it.hasNext() )
-                {
-                    Class type = ( Class ) it.next();
-                    encoders.put( type, encoder );
-                }
-            }
-        }
-        
-        public void encode( IoSession session, Object message,
-                            ProtocolEncoderOutput out ) throws Exception
-        {
-            Class type = message.getClass();
-            MessageEncoder encoder = findEncoder( type );
-            if( encoder == null )
-            {
-                throw new ProtocolEncoderException( "Unexpected message type: " + type );
-            }
-            
-            encoder.encode( session, message, out );
-        }
-        
-        private MessageEncoder findEncoder( Class type )
-        {
-            MessageEncoder encoder = ( MessageEncoder ) encoders.get( type );
-            if( encoder == null )
-            {
-                encoder = findEncoder( type, new IdentityHashSet() );
-            }
-
-            return encoder;
-        }
-
-        private MessageEncoder findEncoder( Class type, Set triedClasses )
-        {
-            MessageEncoder encoder;
-
-            if( triedClasses.contains( type ) )
-                return null;
-            triedClasses.add( type );
-
-            encoder = ( MessageEncoder ) encoders.get( type );
-            if( encoder == null )
-            {
-                encoder = findEncoder( type, triedClasses );
-                if( encoder != null )
-                    return encoder;
-
-                Class[] interfaces = type.getInterfaces();
-                for( int i = 0; i < interfaces.length; i ++ )
-                {
-                    encoder = findEncoder( interfaces[ i ], triedClasses );
-                    if( encoder != null )
-                        return encoder;
-                }
-
-                return null;
-            }
-            else
-                return encoder;
-        }
-
-        public void dispose( IoSession session ) throws Exception
-        {
-            DemuxingProtocolCodecFactory.this.disposeCodecResources( session );
-        }
-    }
-    
-    private class ProtocolDecoderImpl extends CumulativeProtocolDecoder
-    {
-        private final MessageDecoder[] decoders;
-        private MessageDecoder currentDecoder;
-
-        protected ProtocolDecoderImpl()
-        {
-            super( 16 );
-            
-            MessageDecoderFactory[] decoderFactories = DemuxingProtocolCodecFactory.this.decoderFactories;
-            decoders = new MessageDecoder[ decoderFactories.length ];
-            for( int i = decoderFactories.length - 1; i >= 0; i-- )
-            {
-                decoders[ i ] = decoderFactories[ i ].newDecoder();
-            }
-        }
-
-        protected boolean doDecode( IoSession session, ByteBuffer in,
-                                    ProtocolDecoderOutput out ) throws Exception
-        {
-            if( currentDecoder == null )
-            {
-                MessageDecoder[] decoders = this.decoders;
-                int undecodables = 0;
-                for( int i = decoders.length - 1; i >= 0; i -- ) 
-                {
-                    MessageDecoder decoder = decoders[i];
-                    int limit = in.limit();
-                    int pos = in.position();
-
-                    MessageDecoderResult result;
-                    try
-                    {
-                        result = decoder.decodable( session, in );
-                    }
-                    finally
-                    {
-                        in.position( pos );
-                        in.limit( limit );
-                    }
-                    
-                    if( result == MessageDecoder.OK )
-                    {
-                        currentDecoder = decoder;
-                        break;
-                    }
-                    else if( result == MessageDecoder.NOT_OK )
-                    {
-                        undecodables ++;
-                    }
-                    else if( result != MessageDecoder.NEED_DATA )
-                    {
-                        throw new IllegalStateException( "Unexpected decode result (see your decodable()): " + result );
-                    }
-                }
-                
-                if( undecodables == decoders.length )
-                {
-                    // Throw an exception if all decoders cannot decode data.
-                    in.position( in.limit() ); // Skip data
-                    throw new ProtocolDecoderException(
-                            "No appropriate message decoder: " + in.getHexDump() );
-                }
-                
-                if( currentDecoder == null )
-                {
-                    // Decoder is not determined yet (i.e. we need more data)
-                    return false;
-                }
-            }
-            
-            MessageDecoderResult result = currentDecoder.decode( session, in, out );
-            if( result == MessageDecoder.OK )
-            {
-                currentDecoder = null;
-                return true;
-            }
-            else if( result == MessageDecoder.NEED_DATA )
-            {
-                return false;
-            }
-            else if( result == MessageDecoder.NOT_OK )
-            {
-                throw new ProtocolDecoderException( "Message decoder returned NOT_OK." );
-            }
-            else
-            {
-                throw new IllegalStateException( "Unexpected decode result (see your decode()): " + result );
-            }
-        }
-
-        public void dispose( IoSession session ) throws Exception
-        {
-            super.dispose( session );
-            
-            // ProtocolEncoder.dispose() already called disposeCodec(),
-            // so there's nothing more we need to do.
-        }
-    }
-    
-    private static class SingletonMessageEncoderFactory implements MessageEncoderFactory
-    {
-        private final MessageEncoder encoder;
-        
-        private SingletonMessageEncoderFactory( MessageEncoder encoder )
-        {
-            if( encoder == null )
-            {
-                throw new NullPointerException( "encoder" );
-            }
-            this.encoder = encoder;
-        }
-
-        public MessageEncoder newEncoder()
-        {
-            return encoder;
-        }
-    }
-
-    private static class SingletonMessageDecoderFactory implements MessageDecoderFactory
-    {
-        private final MessageDecoder decoder;
-        
-        private SingletonMessageDecoderFactory( MessageDecoder decoder )
-        {
-            if( decoder == null )
-            {
-                throw new NullPointerException( "decoder" );
-            }
-            this.decoder = decoder;
-        }
-
-        public MessageDecoder newDecoder()
-        {
-            return decoder;
-        }
-    }
-
-    
-    private static class DefaultConstructorMessageEncoderFactory implements MessageEncoderFactory
-    {
-        private final Class encoderClass;
-        
-        private DefaultConstructorMessageEncoderFactory( Class encoderClass )
-        {
-            if( encoderClass == null )
-            {
-                throw new NullPointerException( "encoderClass" );
-            }
-            
-            if( !MessageEncoder.class.isAssignableFrom( encoderClass ) )
-            {
-                throw new IllegalArgumentException( "encoderClass is not assignable to MessageEncoder" );
-            }
-            this.encoderClass = encoderClass;
-        }
-
-        public MessageEncoder newEncoder()
-        {
-            try
-            {
-                return ( MessageEncoder ) encoderClass.newInstance();
-            }
-            catch( Exception e )
-            {
-                throw new RuntimeException( "Failed to create a new instance of " + encoderClass, e );
-            }
-        }
-    }
-
-    private static class DefaultConstructorMessageDecoderFactory implements MessageDecoderFactory
-    {
-        private final Class decoderClass;
-        
-        private DefaultConstructorMessageDecoderFactory( Class decoderClass )
-        {
-            if( decoderClass == null )
-            {
-                throw new NullPointerException( "decoderClass" );
-            }
-            
-            if( !MessageDecoder.class.isAssignableFrom( decoderClass ) )
-            {
-                throw new IllegalArgumentException( "decoderClass is not assignable to MessageDecoder" );
-            }
-            this.decoderClass = decoderClass;
-        }
-
-        public MessageDecoder newDecoder()
-        {
-            try
-            {
-                return ( MessageDecoder ) decoderClass.newInstance();
-            }
-            catch( Exception e )
-            {
-                throw new RuntimeException( "Failed to create a new instance of " + decoderClass, e );
-            }
-        }
-    }
-}
+/*
+ *   @(#) $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.demux;
+
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+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.ProtocolEncoder;
+import org.apache.mina.filter.codec.ProtocolEncoderException;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+import org.apache.mina.util.IdentityHashSet;
+
+/**
+ * A composite {@link ProtocolCodecFactory} that consists of multiple
+ * {@link MessageEncoder}s and {@link MessageDecoder}s.
+ * {@link ProtocolEncoder} and {@link ProtocolDecoder} this factory
+ * returns demultiplex incoming messages and buffers to
+ * appropriate {@link MessageEncoder}s and {@link MessageDecoder}s. 
+ * 
+ * <h2>Disposing resources acquired by {@link MessageEncoder} and {@link MessageDecoder}</h2>
+ * <p>
+ * Make your {@link MessageEncoder} and {@link MessageDecoder} to put all
+ * resources that need to be released as a session attribute.  {@link #disposeCodecResources(IoSession)}
+ * method will be invoked when a session is closed.  Override {@link #disposeCodecResources(IoSession)}
+ * to release the resources you've put as an attribute.
+ * <p>
+ * We didn't provide any <tt>dispose</tt> method for {@link MessageEncoder} and {@link MessageDecoder}
+ * because they can give you a big performance penalty in case you have a lot of
+ * message types to handle.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ * 
+ * @see MessageEncoder
+ * @see MessageDecoder
+ */
+public class DemuxingProtocolCodecFactory implements ProtocolCodecFactory {
+    private MessageDecoderFactory[] decoderFactories = new MessageDecoderFactory[0];
+    private MessageEncoderFactory[] encoderFactories = new MessageEncoderFactory[0];
+    
+    public DemuxingProtocolCodecFactory()
+    {
+    }
+    
+    public void register( Class encoderOrDecoderClass )
+    {
+        if( encoderOrDecoderClass == null )
+        {
+            throw new NullPointerException( "encoderOrDecoderClass" );
+        }
+
+        boolean registered = false;
+        if( MessageEncoder.class.isAssignableFrom( encoderOrDecoderClass ) )
+        {
+            register( new DefaultConstructorMessageEncoderFactory( encoderOrDecoderClass ) );
+            registered = true;
+        }
+        
+        if( MessageDecoder.class.isAssignableFrom( encoderOrDecoderClass ) )
+        {
+            register( new DefaultConstructorMessageDecoderFactory( encoderOrDecoderClass ) );
+            registered = true;
+        }
+        
+        if( !registered )
+        {
+            throw new IllegalArgumentException( "Unregisterable type: " + encoderOrDecoderClass );
+        }
+    }
+
+    
+    public void register( MessageEncoder encoder )
+    {
+        register( new SingletonMessageEncoderFactory( encoder ) );
+    }
+    
+    public void register( MessageEncoderFactory factory )
+    {
+        if( factory == null )
+        {
+            throw new NullPointerException( "factory" );
+        }
+        MessageEncoderFactory[] encoderFactories = this.encoderFactories;
+        MessageEncoderFactory[] newEncoderFactories = new MessageEncoderFactory[ encoderFactories.length + 1 ];
+        System.arraycopy( encoderFactories, 0, newEncoderFactories, 0, encoderFactories.length );
+        newEncoderFactories[ encoderFactories.length ] = factory;
+        this.encoderFactories = newEncoderFactories;
+    }
+    
+    public void register( MessageDecoder decoder )
+    {
+        register( new SingletonMessageDecoderFactory( decoder ) );
+    }
+    
+    public void register( MessageDecoderFactory factory )
+    {
+        if( factory == null )
+        {
+            throw new NullPointerException( "factory" );
+        }
+        MessageDecoderFactory[] decoderFactories = this.decoderFactories;
+        MessageDecoderFactory[] newDecoderFactories = new MessageDecoderFactory[ decoderFactories.length + 1 ];
+        System.arraycopy( decoderFactories, 0, newDecoderFactories, 0, decoderFactories.length );
+        newDecoderFactories[ decoderFactories.length ] = factory;
+        this.decoderFactories = newDecoderFactories;
+    }
+    
+    public ProtocolEncoder getEncoder() {
+        return new ProtocolEncoderImpl();
+    }
+
+    public ProtocolDecoder getDecoder() {
+        return new ProtocolDecoderImpl();
+    }
+    
+    /**
+     * Implement this method to release all resources acquired to perform
+     * encoding and decoding messages for the specified <tt>session</tt>.
+     * By default, this method does nothing.
+     * 
+     * @param session the session that requires resource deallocation now
+     */
+    protected void disposeCodecResources( IoSession session )
+    {
+        // Do nothing by default; let users implement it as they want.
+    }
+    
+    private class ProtocolEncoderImpl implements ProtocolEncoder
+    {
+        private final Map encoders = new IdentityHashMap();
+        
+        private ProtocolEncoderImpl()
+        {
+            MessageEncoderFactory[] encoderFactories = DemuxingProtocolCodecFactory.this.encoderFactories;
+            for( int i = encoderFactories.length - 1; i >= 0; i-- )
+            {
+                MessageEncoder encoder = encoderFactories[ i ].newEncoder();
+                Iterator it = encoder.getMessageTypes().iterator();
+                while( it.hasNext() )
+                {
+                    Class type = ( Class ) it.next();
+                    encoders.put( type, encoder );
+                }
+            }
+        }
+        
+        public void encode( IoSession session, Object message,
+                            ProtocolEncoderOutput out ) throws Exception
+        {
+            Class type = message.getClass();
+            MessageEncoder encoder = findEncoder( type );
+            if( encoder == null )
+            {
+                throw new ProtocolEncoderException( "Unexpected message type: " + type );
+            }
+            
+            encoder.encode( session, message, out );
+        }
+        
+        private MessageEncoder findEncoder( Class type )
+        {
+            MessageEncoder encoder = ( MessageEncoder ) encoders.get( type );
+            if( encoder == null )
+            {
+                encoder = findEncoder( type, new IdentityHashSet() );
+            }
+
+            return encoder;
+        }
+
+        private MessageEncoder findEncoder( Class type, Set triedClasses )
+        {
+            MessageEncoder encoder;
+
+            if( triedClasses.contains( type ) )
+                return null;
+            triedClasses.add( type );
+
+            encoder = ( MessageEncoder ) encoders.get( type );
+            if( encoder == null )
+            {
+                encoder = findEncoder( type, triedClasses );
+                if( encoder != null )
+                    return encoder;
+
+                Class[] interfaces = type.getInterfaces();
+                for( int i = 0; i < interfaces.length; i ++ )
+                {
+                    encoder = findEncoder( interfaces[ i ], triedClasses );
+                    if( encoder != null )
+                        return encoder;
+                }
+
+                return null;
+            }
+            else
+                return encoder;
+        }
+
+        public void dispose( IoSession session ) throws Exception
+        {
+            DemuxingProtocolCodecFactory.this.disposeCodecResources( session );
+        }
+    }
+    
+    private class ProtocolDecoderImpl extends CumulativeProtocolDecoder
+    {
+        private final MessageDecoder[] decoders;
+        private MessageDecoder currentDecoder;
+
+        protected ProtocolDecoderImpl()
+        {
+            super( 16 );
+            
+            MessageDecoderFactory[] decoderFactories = DemuxingProtocolCodecFactory.this.decoderFactories;
+            decoders = new MessageDecoder[ decoderFactories.length ];
+            for( int i = decoderFactories.length - 1; i >= 0; i-- )
+            {
+                decoders[ i ] = decoderFactories[ i ].newDecoder();
+            }
+        }
+
+        protected boolean doDecode( IoSession session, ByteBuffer in,
+                                    ProtocolDecoderOutput out ) throws Exception
+        {
+            if( currentDecoder == null )
+            {
+                MessageDecoder[] decoders = this.decoders;
+                int undecodables = 0;
+                for( int i = decoders.length - 1; i >= 0; i -- ) 
+                {
+                    MessageDecoder decoder = decoders[i];
+                    int limit = in.limit();
+                    int pos = in.position();
+
+                    MessageDecoderResult result;
+                    try
+                    {
+                        result = decoder.decodable( session, in );
+                    }
+                    finally
+                    {
+                        in.position( pos );
+                        in.limit( limit );
+                    }
+                    
+                    if( result == MessageDecoder.OK )
+                    {
+                        currentDecoder = decoder;
+                        break;
+                    }
+                    else if( result == MessageDecoder.NOT_OK )
+                    {
+                        undecodables ++;
+                    }
+                    else if( result != MessageDecoder.NEED_DATA )
+                    {
+                        throw new IllegalStateException( "Unexpected decode result (see your decodable()): " + result );
+                    }
+                }
+                
+                if( undecodables == decoders.length )
+                {
+                    // Throw an exception if all decoders cannot decode data.
+                    in.position( in.limit() ); // Skip data
+                    throw new ProtocolDecoderException(
+                            "No appropriate message decoder: " + in.getHexDump() );
+                }
+                
+                if( currentDecoder == null )
+                {
+                    // Decoder is not determined yet (i.e. we need more data)
+                    return false;
+                }
+            }
+            
+            MessageDecoderResult result = currentDecoder.decode( session, in, out );
+            if( result == MessageDecoder.OK )
+            {
+                currentDecoder = null;
+                return true;
+            }
+            else if( result == MessageDecoder.NEED_DATA )
+            {
+                return false;
+            }
+            else if( result == MessageDecoder.NOT_OK )
+            {
+                throw new ProtocolDecoderException( "Message decoder returned NOT_OK." );
+            }
+            else
+            {
+                throw new IllegalStateException( "Unexpected decode result (see your decode()): " + result );
+            }
+        }
+
+        public void dispose( IoSession session ) throws Exception
+        {
+            super.dispose( session );
+            
+            // ProtocolEncoder.dispose() already called disposeCodec(),
+            // so there's nothing more we need to do.
+        }
+    }
+    
+    private static class SingletonMessageEncoderFactory implements MessageEncoderFactory
+    {
+        private final MessageEncoder encoder;
+        
+        private SingletonMessageEncoderFactory( MessageEncoder encoder )
+        {
+            if( encoder == null )
+            {
+                throw new NullPointerException( "encoder" );
+            }
+            this.encoder = encoder;
+        }
+
+        public MessageEncoder newEncoder()
+        {
+            return encoder;
+        }
+    }
+
+    private static class SingletonMessageDecoderFactory implements MessageDecoderFactory
+    {
+        private final MessageDecoder decoder;
+        
+        private SingletonMessageDecoderFactory( MessageDecoder decoder )
+        {
+            if( decoder == null )
+            {
+                throw new NullPointerException( "decoder" );
+            }
+            this.decoder = decoder;
+        }
+
+        public MessageDecoder newDecoder()
+        {
+            return decoder;
+        }
+    }
+
+    
+    private static class DefaultConstructorMessageEncoderFactory implements MessageEncoderFactory
+    {
+        private final Class encoderClass;
+        
+        private DefaultConstructorMessageEncoderFactory( Class encoderClass )
+        {
+            if( encoderClass == null )
+            {
+                throw new NullPointerException( "encoderClass" );
+            }
+            
+            if( !MessageEncoder.class.isAssignableFrom( encoderClass ) )
+            {
+                throw new IllegalArgumentException( "encoderClass is not assignable to MessageEncoder" );
+            }
+            this.encoderClass = encoderClass;
+        }
+
+        public MessageEncoder newEncoder()
+        {
+            try
+            {
+                return ( MessageEncoder ) encoderClass.newInstance();
+            }
+            catch( Exception e )
+            {
+                throw new RuntimeException( "Failed to create a new instance of " + encoderClass, e );
+            }
+        }
+    }
+
+    private static class DefaultConstructorMessageDecoderFactory implements MessageDecoderFactory
+    {
+        private final Class decoderClass;
+        
+        private DefaultConstructorMessageDecoderFactory( Class decoderClass )
+        {
+            if( decoderClass == null )
+            {
+                throw new NullPointerException( "decoderClass" );
+            }
+            
+            if( !MessageDecoder.class.isAssignableFrom( decoderClass ) )
+            {
+                throw new IllegalArgumentException( "decoderClass is not assignable to MessageDecoder" );
+            }
+            this.decoderClass = decoderClass;
+        }
+
+        public MessageDecoder newDecoder()
+        {
+            try
+            {
+                return ( MessageDecoder ) decoderClass.newInstance();
+            }
+            catch( Exception e )
+            {
+                throw new RuntimeException( "Failed to create a new instance of " + decoderClass, e );
+            }
+        }
+    }
+}

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoder.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoder.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoder.java Wed Nov 30 21:17:41 2005
@@ -1,81 +1,81 @@
-/*
- *   @(#) $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.demux;
-
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.ProtocolDecoderOutput;
-
-/**
- * Decodes specific messages.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- * 
- * @see DemuxingProtocolCodecFactory
- * @see MessageDecoderFactory
- */
-public interface MessageDecoder {
-    /**
-     * Represents a result from {@link #decodable(IoSession, ByteBuffer)} and
-     * {@link #decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.  Please
-     * refer to each method's documentation for detailed explanation.
-     */
-    static MessageDecoderResult OK = MessageDecoderResult.OK;
-
-    /**
-     * Represents a result from {@link #decodable(IoSession, ByteBuffer)} and
-     * {@link #decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.  Please
-     * refer to each method's documentation for detailed explanation.
-     */
-    static MessageDecoderResult NEED_DATA = MessageDecoderResult.NEED_DATA;
-
-    /**
-     * Represents a result from {@link #decodable(IoSession, ByteBuffer)} and
-     * {@link #decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.  Please
-     * refer to each method's documentation for detailed explanation.
-     */
-    static MessageDecoderResult NOT_OK = MessageDecoderResult.NOT_OK;
-    
-    /**
-     * Checks the specified buffer is decodable by this decoder.
-     * 
-     * @return {@link #OK} if this decoder can decode the specified buffer.
-     *         {@link #NOT_OK} if this decoder cannot decode the specified buffer.
-     *         {@link #NEED_DATA} if more data is required to determine if the
-     *         specified buffer is decodable ({@link #OK}) or not decodable
-     *         {@link #NOT_OK}.
-     */
-    MessageDecoderResult decodable( IoSession session, ByteBuffer in );
-    
-    /**
-     * Decodes binary or protocol-specific content into higher-level message objects.
-     * MINA invokes {@link #decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}
-     * method with read data, and then the decoder implementation puts decoded
-     * messages into {@link ProtocolDecoderOutput}.
-     * 
-     * @return {@link #OK} if you finished decoding messages successfully.
-     *         {@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 Exception if the read data violated protocol specification 
-     */
-    MessageDecoderResult decode( IoSession session, ByteBuffer in,
-                         ProtocolDecoderOutput out ) throws Exception;
-}
+/*
+ *   @(#) $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.demux;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+
+/**
+ * Decodes specific messages.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ * 
+ * @see DemuxingProtocolCodecFactory
+ * @see MessageDecoderFactory
+ */
+public interface MessageDecoder {
+    /**
+     * Represents a result from {@link #decodable(IoSession, ByteBuffer)} and
+     * {@link #decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.  Please
+     * refer to each method's documentation for detailed explanation.
+     */
+    static MessageDecoderResult OK = MessageDecoderResult.OK;
+
+    /**
+     * Represents a result from {@link #decodable(IoSession, ByteBuffer)} and
+     * {@link #decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.  Please
+     * refer to each method's documentation for detailed explanation.
+     */
+    static MessageDecoderResult NEED_DATA = MessageDecoderResult.NEED_DATA;
+
+    /**
+     * Represents a result from {@link #decodable(IoSession, ByteBuffer)} and
+     * {@link #decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.  Please
+     * refer to each method's documentation for detailed explanation.
+     */
+    static MessageDecoderResult NOT_OK = MessageDecoderResult.NOT_OK;
+    
+    /**
+     * Checks the specified buffer is decodable by this decoder.
+     * 
+     * @return {@link #OK} if this decoder can decode the specified buffer.
+     *         {@link #NOT_OK} if this decoder cannot decode the specified buffer.
+     *         {@link #NEED_DATA} if more data is required to determine if the
+     *         specified buffer is decodable ({@link #OK}) or not decodable
+     *         {@link #NOT_OK}.
+     */
+    MessageDecoderResult decodable( IoSession session, ByteBuffer in );
+    
+    /**
+     * Decodes binary or protocol-specific content into higher-level message objects.
+     * MINA invokes {@link #decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}
+     * method with read data, and then the decoder implementation puts decoded
+     * messages into {@link ProtocolDecoderOutput}.
+     * 
+     * @return {@link #OK} if you finished decoding messages successfully.
+     *         {@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 Exception if the read data violated protocol specification 
+     */
+    MessageDecoderResult decode( IoSession session, ByteBuffer in,
+                         ProtocolDecoderOutput out ) throws Exception;
+}

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoderFactory.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoderFactory.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoderFactory.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoderFactory.java Wed Nov 30 21:17:41 2005
@@ -1,35 +1,35 @@
-/*
- *   @(#) $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.demux;
-
-/**
- * A factory that creates a new instance of {@link MessageDecoder}.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- * 
- * @see DemuxingProtocolCodecFactory
- */
-public interface MessageDecoderFactory
-{
-    /**
-     * Creates a new message decoder.
-     */
-    MessageDecoder newDecoder();
-}
+/*
+ *   @(#) $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.demux;
+
+/**
+ * A factory that creates a new instance of {@link MessageDecoder}.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ * 
+ * @see DemuxingProtocolCodecFactory
+ */
+public interface MessageDecoderFactory
+{
+    /**
+     * Creates a new message decoder.
+     */
+    MessageDecoder newDecoder();
+}

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoderResult.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoderResult.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoderResult.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoderResult.java Wed Nov 30 21:17:41 2005
@@ -1,67 +1,67 @@
-/*
- *   @(#) $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.demux;
-
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.ProtocolDecoderOutput;
-
-/**
- * Represents results from {@link MessageDecoder}.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- * 
- * @see MessageDecoder
- */
-public class MessageDecoderResult
-{
-    /**
-     * Represents a result from {@link MessageDecoder#decodable(IoSession, ByteBuffer)}
-     * and {@link MessageDecoder#decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.
-     * Please refer to each method's documentation for detailed explanation.
-     */
-    public static MessageDecoderResult OK = new MessageDecoderResult( "OK" );
-
-    /**
-     * Represents a result from {@link MessageDecoder#decodable(IoSession, ByteBuffer)}
-     * and {@link MessageDecoder#decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.
-     * Please refer to each method's documentation for detailed explanation.
-     */
-    public static MessageDecoderResult NEED_DATA = new MessageDecoderResult( "NEED_DATA" );
-
-    /**
-     * Represents a result from {@link MessageDecoder#decodable(IoSession, ByteBuffer)}
-     * and {@link MessageDecoder#decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.
-     * Please refer to each method's documentation for detailed explanation.
-     */
-    public static MessageDecoderResult NOT_OK = new MessageDecoderResult( "NOT_OK" );
-
-    private final String name;
-
-    private MessageDecoderResult( String name )
-    {
-        this.name = name;
-    }
-    
-    public String toString()
-    {
-        return name;
-    }
+/*
+ *   @(#) $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.demux;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+
+/**
+ * Represents results from {@link MessageDecoder}.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ * 
+ * @see MessageDecoder
+ */
+public class MessageDecoderResult
+{
+    /**
+     * Represents a result from {@link MessageDecoder#decodable(IoSession, ByteBuffer)}
+     * and {@link MessageDecoder#decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.
+     * Please refer to each method's documentation for detailed explanation.
+     */
+    public static MessageDecoderResult OK = new MessageDecoderResult( "OK" );
+
+    /**
+     * Represents a result from {@link MessageDecoder#decodable(IoSession, ByteBuffer)}
+     * and {@link MessageDecoder#decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.
+     * Please refer to each method's documentation for detailed explanation.
+     */
+    public static MessageDecoderResult NEED_DATA = new MessageDecoderResult( "NEED_DATA" );
+
+    /**
+     * Represents a result from {@link MessageDecoder#decodable(IoSession, ByteBuffer)}
+     * and {@link MessageDecoder#decode(IoSession, ByteBuffer, ProtocolDecoderOutput)}.
+     * Please refer to each method's documentation for detailed explanation.
+     */
+    public static MessageDecoderResult NOT_OK = new MessageDecoderResult( "NOT_OK" );
+
+    private final String name;
+
+    private MessageDecoderResult( String name )
+    {
+        this.name = name;
+    }
+    
+    public String toString()
+    {
+        return name;
+    }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageEncoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageEncoder.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageEncoder.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageEncoder.java Wed Nov 30 21:17:41 2005
@@ -1,54 +1,54 @@
-/*
- *   @(#) $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.demux;
-
-import java.util.Set;
-
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.ProtocolEncoderOutput;
-
-/**
- * Encodes messages of specific types specified by {@link #getMessageTypes()}.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- * 
- * @see DemuxingProtocolCodecFactory
- * @see MessageEncoderFactory
- */
-public interface MessageEncoder
-{  
-    /**
-     * Returns the set of message classes this encoder can encode.
-     */
-    Set getMessageTypes();
-
-    /**
-     * Encodes higher-level message objects into binary or protocol-specific data.
-     * MINA invokes {@link #encode(IoSession, Object, ProtocolEncoderOutput)}
-     * method with message which is popped from the session write queue, and then
-     * the encoder implementation puts encoded {@link ByteBuffer}s into
-     * {@link ProtocolEncoderOutput}.
-     * 
-     * @throws Exception if the message violated protocol specification
-     */
-    void encode( IoSession session, Object message,
-                 ProtocolEncoderOutput out ) throws Exception;
-}
+/*
+ *   @(#) $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.demux;
+
+import java.util.Set;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+
+/**
+ * Encodes messages of specific types specified by {@link #getMessageTypes()}.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ * 
+ * @see DemuxingProtocolCodecFactory
+ * @see MessageEncoderFactory
+ */
+public interface MessageEncoder
+{  
+    /**
+     * Returns the set of message classes this encoder can encode.
+     */
+    Set getMessageTypes();
+
+    /**
+     * Encodes higher-level message objects into binary or protocol-specific data.
+     * MINA invokes {@link #encode(IoSession, Object, ProtocolEncoderOutput)}
+     * method with message which is popped from the session write queue, and then
+     * the encoder implementation puts encoded {@link ByteBuffer}s into
+     * {@link ProtocolEncoderOutput}.
+     * 
+     * @throws Exception if the message violated protocol specification
+     */
+    void encode( IoSession session, Object message,
+                 ProtocolEncoderOutput out ) throws Exception;
+}

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageEncoderFactory.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageEncoderFactory.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageEncoderFactory.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageEncoderFactory.java Wed Nov 30 21:17:41 2005
@@ -1,35 +1,35 @@
-/*
- *   @(#) $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.demux;
-
-/**
- * A factory that creates a new instance of {@link MessageEncoder}.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- * 
- * @see DemuxingProtocolCodecFactory
- */
-public interface MessageEncoderFactory
-{
-    /**
-     * Creates a new message encoder.
-     */
-    MessageEncoder newEncoder();
-}
+/*
+ *   @(#) $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.demux;
+
+/**
+ * A factory that creates a new instance of {@link MessageEncoder}.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ * 
+ * @see DemuxingProtocolCodecFactory
+ */
+public interface MessageEncoderFactory
+{
+    /**
+     * Creates a new message encoder.
+     */
+    MessageEncoder newEncoder();
+}

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/support/SimpleProtocolDecoderOutput.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/support/SimpleProtocolDecoderOutput.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/support/SimpleProtocolDecoderOutput.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/support/SimpleProtocolDecoderOutput.java Wed Nov 30 21:17:41 2005
@@ -1,33 +1,33 @@
-/**
- * 
- */
-package org.apache.mina.filter.codec.support;
-
-import org.apache.mina.filter.codec.ProtocolDecoderOutput;
-import org.apache.mina.util.Queue;
-
-/**
- * A {@link ProtocolDecoderOutput} based on queue.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- *
- */
-public class SimpleProtocolDecoderOutput implements ProtocolDecoderOutput
-{
-    private final Queue messageQueue = new Queue();
-    
-    public SimpleProtocolDecoderOutput()
-    {
-    }
-    
-    public Queue getMessageQueue()
-    {
-        return messageQueue;
-    }
-    
-    public void write( Object message )
-    {
-        messageQueue.push( message );
-    }
+/**
+ * 
+ */
+package org.apache.mina.filter.codec.support;
+
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+import org.apache.mina.util.Queue;
+
+/**
+ * A {@link ProtocolDecoderOutput} based on queue.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ *
+ */
+public class SimpleProtocolDecoderOutput implements ProtocolDecoderOutput
+{
+    private final Queue messageQueue = new Queue();
+    
+    public SimpleProtocolDecoderOutput()
+    {
+    }
+    
+    public Queue getMessageQueue()
+    {
+        return messageQueue;
+    }
+    
+    public void write( Object message )
+    {
+        messageQueue.push( message );
+    }
 }



Mime
View raw message