You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by tr...@apache.org on 2005/12/01 06:19:07 UTC

svn commit: r350169 [1/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...

Author: trustin
Date: Wed Nov 30 21:17:41 2005
New Revision: 350169

URL: http://svn.apache.org/viewcvs?rev=350169&view=rev
Log:
Merging chain_reafctor branch

Added:
    directory/network/trunk/src/java/org/apache/mina/common/DefaultIoFilterChainBuilder.java
    directory/network/trunk/src/java/org/apache/mina/common/IoFilterChainBuilder.java
    directory/network/trunk/src/java/org/apache/mina/common/IoFilterLifeCycleException.java
    directory/network/trunk/src/java/org/apache/mina/common/support/IoFilterLifeCycleManager.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeFilterChain.java
    directory/network/trunk/src/test/org/apache/mina/common/DefaultIoFilterChainBuilderTest.java
Modified:
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/ConnectFuture.java
    directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
    directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java
    directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/HttpProtocolHandler.java
    directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java
    directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java
    directory/network/trunk/src/examples/org/apache/mina/examples/netcat/NetCatProtocolHandler.java
    directory/network/trunk/src/examples/org/apache/mina/examples/reverser/Main.java
    directory/network/trunk/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java
    directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java
    directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineEncoder.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Client.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Server.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/codec/Constants.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/message/AbstractMessage.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/message/AddMessage.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/message/ResultMessage.java
    directory/network/trunk/src/examples/org/apache/mina/examples/tennis/Main.java
    directory/network/trunk/src/examples/org/apache/mina/examples/tennis/TennisBall.java
    directory/network/trunk/src/examples/org/apache/mina/examples/tennis/TennisPlayer.java
    directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java
    directory/network/trunk/src/java/org/apache/mina/common/ByteBufferProxy.java
    directory/network/trunk/src/java/org/apache/mina/common/ConnectFuture.java
    directory/network/trunk/src/java/org/apache/mina/common/ExceptionMonitor.java
    directory/network/trunk/src/java/org/apache/mina/common/IdleStatus.java
    directory/network/trunk/src/java/org/apache/mina/common/IoAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/common/IoConnector.java
    directory/network/trunk/src/java/org/apache/mina/common/IoFilter.java
    directory/network/trunk/src/java/org/apache/mina/common/IoFilterAdapter.java
    directory/network/trunk/src/java/org/apache/mina/common/IoFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/common/IoHandler.java
    directory/network/trunk/src/java/org/apache/mina/common/IoHandlerAdapter.java
    directory/network/trunk/src/java/org/apache/mina/common/IoSession.java
    directory/network/trunk/src/java/org/apache/mina/common/IoSessionManager.java
    directory/network/trunk/src/java/org/apache/mina/common/TransportType.java
    directory/network/trunk/src/java/org/apache/mina/common/WriteTimeoutException.java
    directory/network/trunk/src/java/org/apache/mina/common/support/AbstractIoFilterChain.java
    directory/network/trunk/src/java/org/apache/mina/common/support/BaseIoAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/common/support/BaseIoConnector.java
    directory/network/trunk/src/java/org/apache/mina/common/support/BaseIoSession.java
    directory/network/trunk/src/java/org/apache/mina/common/support/BaseIoSessionManager.java
    directory/network/trunk/src/java/org/apache/mina/common/support/DefaultExceptionMonitor.java
    directory/network/trunk/src/java/org/apache/mina/common/support/DelegatedIoAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/common/support/DelegatedIoConnector.java
    directory/network/trunk/src/java/org/apache/mina/filter/BlacklistFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/LoggingFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/CumulativeProtocolDecoder.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecException.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFactory.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoder.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderAdapter.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderException.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolDecoderOutput.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoder.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderAdapter.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderException.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolEncoderOutput.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/DemuxingProtocolCodecFactory.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoder.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoderFactory.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageDecoderResult.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageEncoder.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/demux/MessageEncoderFactory.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/support/SimpleProtocolDecoderOutput.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/support/SimpleProtocolEncoderOutput.java
    directory/network/trunk/src/java/org/apache/mina/filter/support/SSLHandler.java
    directory/network/trunk/src/java/org/apache/mina/handler/StreamIoHandler.java
    directory/network/trunk/src/java/org/apache/mina/handler/support/IoSessionInputStream.java
    directory/network/trunk/src/java/org/apache/mina/handler/support/IoSessionOutputStream.java
    directory/network/trunk/src/java/org/apache/mina/integration/spring/support/AbstractIoSessionManagerFactoryBean.java
    directory/network/trunk/src/java/org/apache/mina/registry/Service.java
    directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
    directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramSession.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketSession.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionManager.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketIoProcessor.java
    directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/support/SocketSessionImpl.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAddress.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeConnector.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeSession.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipe.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeIdleStatusChecker.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/support/VmPipeSessionImpl.java
    directory/network/trunk/src/java/org/apache/mina/util/AnonymousSocketAddress.java
    directory/network/trunk/src/java/org/apache/mina/util/ByteBufferUtil.java
    directory/network/trunk/src/java/org/apache/mina/util/ExceptionUtil.java
    directory/network/trunk/src/java/org/apache/mina/util/Queue.java
    directory/network/trunk/src/java/org/apache/mina/util/SessionLog.java
    directory/network/trunk/src/java/org/apache/mina/util/SessionUtil.java
    directory/network/trunk/src/java/org/apache/mina/util/Stack.java
    directory/network/trunk/src/test/org/apache/mina/common/FutureTest.java
    directory/network/trunk/src/test/org/apache/mina/common/IoFilterChainTest.java
    directory/network/trunk/src/test/org/apache/mina/common/TransportTypeTest.java
    directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AbstractTest.java
    directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
    directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
    directory/network/trunk/src/test/org/apache/mina/filter/ThreadPoolFilterRegressionTest.java
    directory/network/trunk/src/test/org/apache/mina/filter/codec/CumulativeProtocolDecoderTest.java
    directory/network/trunk/src/test/org/apache/mina/integration/spring/support/AbstractIoSessionManagerFactoryBeanTest.java
    directory/network/trunk/src/test/org/apache/mina/transport/socket/nio/AbstractBindTest.java
    directory/network/trunk/src/test/org/apache/mina/util/IoFilterImpl.java

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/ConnectFuture.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/ConnectFuture.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/ConnectFuture.java (original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/ConnectFuture.java Wed Nov 30 21:17:41 2005
@@ -50,16 +50,6 @@
     }
 
     /**
-     * Returns a new {@link WriteFuture} which is already marked as 'not written'.
-     */
-    public static WriteFuture newNotWrittenFuture()
-    {
-        WriteFuture unwrittenFuture = new WriteFuture();
-        unwrittenFuture.setWritten( false );
-        return unwrittenFuture;
-    }
-
-    /**
      * Returns {@link IoSession} which is the result of connect operation.
      * 
      * @return <tt>null</tt> if the connect operation is not finished yet

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java Wed Nov 30 21:17:41 2005
@@ -1,82 +1,82 @@
-/*
- *   @(#) $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.examples.echoserver;
-
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IdleStatus;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoHandlerAdapter;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.SSLFilter;
-import org.apache.mina.transport.socket.nio.SocketSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@link IoHandler} implementation for echo server. 
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$,
- */
-public class EchoProtocolHandler extends IoHandlerAdapter
-{
-    private static final Logger log = LoggerFactory.getLogger( EchoProtocolHandler.class );
-
-    public void sessionCreated( IoSession session )
-    {
-        if( session instanceof SocketSession )
-        {
-            ( ( SocketSession ) session ).setSessionReceiveBufferSize( 2048 );
-        }
-        
-        session.setIdleTime( IdleStatus.BOTH_IDLE, 10 );
-        
-        // We're going to use SSL negotiation notification.
-        session.setAttribute( SSLFilter.USE_NOTIFICATION );
-    }
-    
-    public void sessionIdle( IoSession session, IdleStatus status )
-    {
-        log.info(
-                "*** IDLE #" +
-                session.getIdleCount( IdleStatus.BOTH_IDLE ) +
-                " ***" );
-    }
-
-    public void exceptionCaught( IoSession session, Throwable cause )
-    {
-        cause.printStackTrace();
-        session.close();
-    }
-
-    public void messageReceived( IoSession session, Object message ) throws Exception
-    {
-        if( !( message instanceof ByteBuffer ) )
-        {
-            return;
-        }
-
-        ByteBuffer rb = ( ByteBuffer ) message;
-        // Write the received data back to remote peer
-        ByteBuffer wb = ByteBuffer.allocate( rb.remaining() );
-        wb.put( rb );
-        wb.flip();
-        session.write( wb );
-    }
+/*
+ *   @(#) $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.examples.echoserver;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoHandlerAdapter;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.SSLFilter;
+import org.apache.mina.transport.socket.nio.SocketSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@link IoHandler} implementation for echo server. 
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$,
+ */
+public class EchoProtocolHandler extends IoHandlerAdapter
+{
+    private static final Logger log = LoggerFactory.getLogger( EchoProtocolHandler.class );
+
+    public void sessionCreated( IoSession session )
+    {
+        if( session instanceof SocketSession )
+        {
+            ( ( SocketSession ) session ).setSessionReceiveBufferSize( 2048 );
+        }
+        
+        session.setIdleTime( IdleStatus.BOTH_IDLE, 10 );
+        
+        // We're going to use SSL negotiation notification.
+        session.setAttribute( SSLFilter.USE_NOTIFICATION );
+    }
+    
+    public void sessionIdle( IoSession session, IdleStatus status )
+    {
+        log.info(
+                "*** IDLE #" +
+                session.getIdleCount( IdleStatus.BOTH_IDLE ) +
+                " ***" );
+    }
+
+    public void exceptionCaught( IoSession session, Throwable cause )
+    {
+        cause.printStackTrace();
+        session.close();
+    }
+
+    public void messageReceived( IoSession session, Object message ) throws Exception
+    {
+        if( !( message instanceof ByteBuffer ) )
+        {
+            return;
+        }
+
+        ByteBuffer rb = ( ByteBuffer ) message;
+        // Write the received data back to remote peer
+        ByteBuffer wb = ByteBuffer.allocate( rb.remaining() );
+        wb.put( rb );
+        wb.flip();
+        session.write( wb );
+    }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java Wed Nov 30 21:17:41 2005
@@ -1,79 +1,79 @@
-/*
- *   @(#) $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.examples.echoserver;
-
-import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.TransportType;
-import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
-import org.apache.mina.filter.LoggingFilter;
-import org.apache.mina.filter.SSLFilter;
-import org.apache.mina.registry.Service;
-import org.apache.mina.registry.ServiceRegistry;
-import org.apache.mina.registry.SimpleServiceRegistry;
-
-/**
- * (<b>Entry point</b>) Echo server
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public class Main
-{
-    /** Choose your favorite port number. */
-    private static final int PORT = 8080;
-    
-    /** Set this to true if you want to make the server SSL */
-    private static final boolean USE_SSL = false;
-
-    public static void main( String[] args ) throws Exception
-    {
-        ServiceRegistry registry = new SimpleServiceRegistry();
-        
-        // Add SSL filter if SSL is enabled.
-        if( USE_SSL )
-        {
-            addSSLSupport( registry );
-        }
-        
-        addLogger( registry );
-        
-        // Bind
-        Service service = new Service( "echo", TransportType.SOCKET, PORT );
-        registry.bind( service, new EchoProtocolHandler() );
-
-        System.out.println( "Listening on port " + PORT );
-    }
-
-    private static void addSSLSupport( ServiceRegistry registry )
-        throws Exception
-    {
-        SSLFilter sslFilter =
-            new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
-        IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
-        acceptor.getFilterChain().addLast( "sslFilter", sslFilter );
-        System.out.println( "SSL ON" );
-    }
-    
-    private static void addLogger( ServiceRegistry registry ) throws Exception
-    {
-        IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
-        acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
-        System.out.println( "Logging ON" );
-    }
-}
+/*
+ *   @(#) $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.examples.echoserver;
+
+import org.apache.mina.common.IoAcceptor;
+import org.apache.mina.common.TransportType;
+import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
+import org.apache.mina.filter.LoggingFilter;
+import org.apache.mina.filter.SSLFilter;
+import org.apache.mina.registry.Service;
+import org.apache.mina.registry.ServiceRegistry;
+import org.apache.mina.registry.SimpleServiceRegistry;
+
+/**
+ * (<b>Entry point</b>) Echo server
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class Main
+{
+    /** Choose your favorite port number. */
+    private static final int PORT = 8080;
+    
+    /** Set this to true if you want to make the server SSL */
+    private static final boolean USE_SSL = false;
+
+    public static void main( String[] args ) throws Exception
+    {
+        ServiceRegistry registry = new SimpleServiceRegistry();
+        
+        // Add SSL filter if SSL is enabled.
+        if( USE_SSL )
+        {
+            addSSLSupport( registry );
+        }
+        
+        addLogger( registry );
+        
+        // Bind
+        Service service = new Service( "echo", TransportType.SOCKET, PORT );
+        registry.bind( service, new EchoProtocolHandler() );
+
+        System.out.println( "Listening on port " + PORT );
+    }
+
+    private static void addSSLSupport( ServiceRegistry registry )
+        throws Exception
+    {
+        SSLFilter sslFilter =
+            new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
+        IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
+        acceptor.getFilterChain().addLast( "sslFilter", sslFilter );
+        System.out.println( "SSL ON" );
+    }
+    
+    private static void addLogger( ServiceRegistry registry ) throws Exception
+    {
+        IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
+        acceptor.getFilterChain().addLast( "logger", new LoggingFilter() );
+        System.out.println( "Logging ON" );
+    }
+}

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/HttpProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/HttpProtocolHandler.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/HttpProtocolHandler.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/HttpProtocolHandler.java Wed Nov 30 21:17:41 2005
@@ -1,126 +1,126 @@
-/*
- *   @(#) $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.examples.httpserver;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.Map.Entry;
-
-import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.StreamIoHandler;
-
-/**
- * A simplistic HTTP protocol handler that replies back the URL and headers
- * which a client requested.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public class HttpProtocolHandler extends StreamIoHandler
-{
-    protected void processStreamIo( IoSession session, InputStream in,
-                                    OutputStream out )
-    {
-        // You *MUST* execute stream I/O logic in a separate thread.
-        new Worker( in, out ).start();
-    }
-    
-    private static class Worker extends Thread
-    {
-        private final InputStream in;
-        private final OutputStream out;
-        
-        public Worker( InputStream in, OutputStream out )
-        {
-            setDaemon( true );
-            this.in = in;
-            this.out = out;
-        }
-        
-        public void run()
-        {
-            String url;
-            Map headers = new TreeMap();
-            BufferedReader in = new BufferedReader(
-                    new InputStreamReader( this.in ) );
-            PrintWriter out = new PrintWriter(
-                    new BufferedWriter( new OutputStreamWriter( this.out ) ) );
-            
-            try
-            {
-                // Get request URL.
-                url = in.readLine().split( " " )[1];
-                
-                // Read header
-                String line;
-                while ( ( line = in.readLine() ) != null && !line.equals( "" ) )
-                {
-                    String[] tokens = line.split(": ");
-                    headers.put( tokens[0], tokens[1] );
-                }
-                
-                // Write header
-                out.println( "HTTP/1.0 200 OK" );
-                out.println( "Content-Type: text/html" );
-                out.println( "Server: MINA Example" );
-                out.println();
-                
-                // Write content
-                out.println( "<html><head></head><body>" );
-                out.println( "<h3>Request Summary for: " + url + "</h3>" );
-                out.println( "<table border=\"1\"><tr><th>Key</th><th>Value</th></tr>" );
-                
-                Iterator it = headers.entrySet().iterator();
-                while( it.hasNext() )
-                {
-                    Entry e = ( Entry ) it.next();
-                    out.println( "<tr><td>" + e.getKey() + "</td><td>" + e.getValue() + "</td></tr>" );
-                }
-                
-                out.println( "</table>" );
-                out.println( "</body></html>" );
-            }
-            catch( Exception e )
-            {
-                e.printStackTrace();
-            }
-            finally
-            {
-                out.flush();
-                out.close();
-                try
-                {
-                    in.close();
-                }
-                catch( IOException 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.examples.httpserver;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.Map.Entry;
+
+import org.apache.mina.common.IoSession;
+import org.apache.mina.handler.StreamIoHandler;
+
+/**
+ * A simplistic HTTP protocol handler that replies back the URL and headers
+ * which a client requested.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class HttpProtocolHandler extends StreamIoHandler
+{
+    protected void processStreamIo( IoSession session, InputStream in,
+                                    OutputStream out )
+    {
+        // You *MUST* execute stream I/O logic in a separate thread.
+        new Worker( in, out ).start();
+    }
+    
+    private static class Worker extends Thread
+    {
+        private final InputStream in;
+        private final OutputStream out;
+        
+        public Worker( InputStream in, OutputStream out )
+        {
+            setDaemon( true );
+            this.in = in;
+            this.out = out;
+        }
+        
+        public void run()
+        {
+            String url;
+            Map headers = new TreeMap();
+            BufferedReader in = new BufferedReader(
+                    new InputStreamReader( this.in ) );
+            PrintWriter out = new PrintWriter(
+                    new BufferedWriter( new OutputStreamWriter( this.out ) ) );
+            
+            try
+            {
+                // Get request URL.
+                url = in.readLine().split( " " )[1];
+                
+                // Read header
+                String line;
+                while ( ( line = in.readLine() ) != null && !line.equals( "" ) )
+                {
+                    String[] tokens = line.split(": ");
+                    headers.put( tokens[0], tokens[1] );
+                }
+                
+                // Write header
+                out.println( "HTTP/1.0 200 OK" );
+                out.println( "Content-Type: text/html" );
+                out.println( "Server: MINA Example" );
+                out.println();
+                
+                // Write content
+                out.println( "<html><head></head><body>" );
+                out.println( "<h3>Request Summary for: " + url + "</h3>" );
+                out.println( "<table border=\"1\"><tr><th>Key</th><th>Value</th></tr>" );
+                
+                Iterator it = headers.entrySet().iterator();
+                while( it.hasNext() )
+                {
+                    Entry e = ( Entry ) it.next();
+                    out.println( "<tr><td>" + e.getKey() + "</td><td>" + e.getValue() + "</td></tr>" );
+                }
+                
+                out.println( "</table>" );
+                out.println( "</body></html>" );
+            }
+            catch( Exception e )
+            {
+                e.printStackTrace();
+            }
+            finally
+            {
+                out.flush();
+                out.close();
+                try
+                {
+                    in.close();
+                }
+                catch( IOException e )
+                {
+                }
+            }
+        }
+    }
+}

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java Wed Nov 30 21:17:41 2005
@@ -1,69 +1,69 @@
-/*
- *   @(#) $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.examples.httpserver;
-
-import org.apache.mina.common.IoAcceptor;
-import org.apache.mina.common.TransportType;
-import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
-import org.apache.mina.filter.SSLFilter;
-import org.apache.mina.registry.Service;
-import org.apache.mina.registry.ServiceRegistry;
-import org.apache.mina.registry.SimpleServiceRegistry;
-
-/**
- * (<b>Entry point</b>) HTTP server
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$
- */
-public class Main
-{
-    /** Choose your favorite port number. */
-    private static final int PORT = 8080;
-    
-    private static final boolean USE_SSL = false;
-
-    public static void main( String[] args ) throws Exception
-    {
-        ServiceRegistry registry = new SimpleServiceRegistry();
-        
-        // Add SSL filter if SSL is enabled.
-        if( USE_SSL )
-        {
-            addSSLSupport( registry );
-        }
-
-        // Bind
-        Service service = new Service( "http", TransportType.SOCKET, PORT );
-        registry.bind( service, new HttpProtocolHandler() );
-
-        System.out.println( "Listening on port " + PORT );
-    }
-
-
-    private static void addSSLSupport( ServiceRegistry registry )
-        throws Exception
-    {
-        System.out.println( "SSL is enabled." );
-        SSLFilter sslFilter =
-            new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
-        IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
-        acceptor.getFilterChain().addLast( "sslFilter", sslFilter );
-    }
-}
+/*
+ *   @(#) $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.examples.httpserver;
+
+import org.apache.mina.common.IoAcceptor;
+import org.apache.mina.common.TransportType;
+import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
+import org.apache.mina.filter.SSLFilter;
+import org.apache.mina.registry.Service;
+import org.apache.mina.registry.ServiceRegistry;
+import org.apache.mina.registry.SimpleServiceRegistry;
+
+/**
+ * (<b>Entry point</b>) HTTP server
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$
+ */
+public class Main
+{
+    /** Choose your favorite port number. */
+    private static final int PORT = 8080;
+    
+    private static final boolean USE_SSL = false;
+
+    public static void main( String[] args ) throws Exception
+    {
+        ServiceRegistry registry = new SimpleServiceRegistry();
+        
+        // Add SSL filter if SSL is enabled.
+        if( USE_SSL )
+        {
+            addSSLSupport( registry );
+        }
+
+        // Bind
+        Service service = new Service( "http", TransportType.SOCKET, PORT );
+        registry.bind( service, new HttpProtocolHandler() );
+
+        System.out.println( "Listening on port " + PORT );
+    }
+
+
+    private static void addSSLSupport( ServiceRegistry registry )
+        throws Exception
+    {
+        System.out.println( "SSL is enabled." );
+        SSLFilter sslFilter =
+            new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
+        IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
+        acceptor.getFilterChain().addLast( "sslFilter", sslFilter );
+    }
+}

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/netcat/Main.java Wed Nov 30 21:17:41 2005
@@ -1,55 +1,55 @@
-/*
- *   @(#) $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.examples.netcat;
-
-import java.net.InetSocketAddress;
-
-import org.apache.mina.transport.socket.nio.SocketConnector;
-
-/**
- * (<b>Entry point</b>) NetCat client.  NetCat client connects to the specified
- * endpoint and prints out received data.  NetCat client disconnects
- * automatically when no data is read for 10 seconds. 
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$,
- */
-public class Main
-{
-    public static void main( String[] args ) throws Exception
-    {
-        if( args.length != 2 )
-        {
-            System.out.println( Main.class.getName() + " <hostname> <port>" );
-            return;
-        }
-
-        // Create TCP/IP connector.
-        SocketConnector connector = new SocketConnector();
-
-        // Set connect timeout.
-        connector.setConnectTimeout( 30 );
-        
-        // Start communication.
-        connector.connect( 
-                new InetSocketAddress( args[ 0 ],
-                Integer.parseInt( args[ 1 ] ) ),
-                new NetCatProtocolHandler() );
-    }
-}
+/*
+ *   @(#) $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.examples.netcat;
+
+import java.net.InetSocketAddress;
+
+import org.apache.mina.transport.socket.nio.SocketConnector;
+
+/**
+ * (<b>Entry point</b>) NetCat client.  NetCat client connects to the specified
+ * endpoint and prints out received data.  NetCat client disconnects
+ * automatically when no data is read for 10 seconds. 
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$,
+ */
+public class Main
+{
+    public static void main( String[] args ) throws Exception
+    {
+        if( args.length != 2 )
+        {
+            System.out.println( Main.class.getName() + " <hostname> <port>" );
+            return;
+        }
+
+        // Create TCP/IP connector.
+        SocketConnector connector = new SocketConnector();
+
+        // Set connect timeout.
+        connector.setConnectTimeout( 30 );
+        
+        // Start communication.
+        connector.connect( 
+                new InetSocketAddress( args[ 0 ],
+                Integer.parseInt( args[ 1 ] ) ),
+                new NetCatProtocolHandler() );
+    }
+}

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/netcat/NetCatProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/netcat/NetCatProtocolHandler.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/netcat/NetCatProtocolHandler.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/netcat/NetCatProtocolHandler.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.examples.netcat;
-
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IdleStatus;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoHandlerAdapter;
-import org.apache.mina.common.IoSession;
-
-/**
- * {@link IoHandler} implementation for NetCat client.  This class extended
- * {@link IoHandlerAdapter} for convenience. 
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$,
- */
-public class NetCatProtocolHandler extends IoHandlerAdapter
-{
-    public void sessionOpened( IoSession session )
-    {
-        // Set reader idle time to 10 seconds.
-        // sessionIdle(...) method will be invoked when no data is read
-        // for 10 seconds.
-        session.setIdleTime( IdleStatus.READER_IDLE, 10 );
-    }
-
-    public void sessionClosed( IoSession session )
-    {
-        // Print out total number of bytes read from the remote peer.
-        System.err.println( "Total " + session.getReadBytes() + " byte(s)" );
-    }
-
-    public void sessionIdle( IoSession session, IdleStatus status )
-    {
-        // Close the connection if reader is idle.
-        if( status == IdleStatus.READER_IDLE )
-            session.close();
-    }
-
-    public void messageReceived( IoSession session, Object message )
-    {
-        ByteBuffer buf = ( ByteBuffer ) message;
-        // Print out read buffer content.
-        while( buf.hasRemaining() )
-        {
-            System.out.print( ( char ) buf.get() );
-        }
-        System.out.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.examples.netcat;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoHandlerAdapter;
+import org.apache.mina.common.IoSession;
+
+/**
+ * {@link IoHandler} implementation for NetCat client.  This class extended
+ * {@link IoHandlerAdapter} for convenience. 
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$,
+ */
+public class NetCatProtocolHandler extends IoHandlerAdapter
+{
+    public void sessionOpened( IoSession session )
+    {
+        // Set reader idle time to 10 seconds.
+        // sessionIdle(...) method will be invoked when no data is read
+        // for 10 seconds.
+        session.setIdleTime( IdleStatus.READER_IDLE, 10 );
+    }
+
+    public void sessionClosed( IoSession session )
+    {
+        // Print out total number of bytes read from the remote peer.
+        System.err.println( "Total " + session.getReadBytes() + " byte(s)" );
+    }
+
+    public void sessionIdle( IoSession session, IdleStatus status )
+    {
+        // Close the connection if reader is idle.
+        if( status == IdleStatus.READER_IDLE )
+            session.close();
+    }
+
+    public void messageReceived( IoSession session, Object message )
+    {
+        ByteBuffer buf = ( ByteBuffer ) message;
+        // Print out read buffer content.
+        while( buf.hasRemaining() )
+        {
+            System.out.print( ( char ) buf.get() );
+        }
+        System.out.flush();
+    }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/reverser/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/reverser/Main.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/reverser/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/reverser/Main.java Wed Nov 30 21:17:41 2005
@@ -1,47 +1,47 @@
-/*
- *   @(#) $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.examples.reverser;
-
-import org.apache.mina.common.TransportType;
-import org.apache.mina.registry.Service;
-import org.apache.mina.registry.ServiceRegistry;
-import org.apache.mina.registry.SimpleServiceRegistry;
-
-/**
- * (<b>Entry point</b>) Reverser server which reverses all text lines from
- * clients.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$,
- */
-public class Main
-{
-    private static final int PORT = 8080;
-
-    public static void main( String[] args ) throws Exception
-    {
-        ServiceRegistry registry = new SimpleServiceRegistry();
-
-        // Bind
-        Service service = new Service( "reverse", TransportType.SOCKET, PORT );
-        registry.bind( service, new ReverseProtocolHandler() );
-
-        System.out.println( "Listening on port " + PORT );
-    }
-}
+/*
+ *   @(#) $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.examples.reverser;
+
+import org.apache.mina.common.TransportType;
+import org.apache.mina.registry.Service;
+import org.apache.mina.registry.ServiceRegistry;
+import org.apache.mina.registry.SimpleServiceRegistry;
+
+/**
+ * (<b>Entry point</b>) Reverser server which reverses all text lines from
+ * clients.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$,
+ */
+public class Main
+{
+    private static final int PORT = 8080;
+
+    public static void main( String[] args ) throws Exception
+    {
+        ServiceRegistry registry = new SimpleServiceRegistry();
+
+        // Bind
+        Service service = new Service( "reverse", TransportType.SOCKET, PORT );
+        registry.bind( service, new ReverseProtocolHandler() );
+
+        System.out.println( "Listening on port " + PORT );
+    }
+}

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/reverser/ReverseProtocolHandler.java Wed Nov 30 21:17:41 2005
@@ -1,84 +1,84 @@
-/*
- *   @(#) $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.examples.reverser;
-
-import org.apache.mina.common.IoFilter;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoHandlerAdapter;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.LoggingFilter;
-import org.apache.mina.filter.codec.ProtocolCodecFactory;
-import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.apache.mina.filter.codec.ProtocolDecoder;
-import org.apache.mina.filter.codec.ProtocolEncoder;
-
-/**
- * {@link IoHandler} implementation of reverser server protocol.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$,
- */
-public class ReverseProtocolHandler extends IoHandlerAdapter
-{
-    private static IoFilter LOGGING_FILTER = new LoggingFilter();
-    
-    private static ProtocolCodecFactory CODEC_FACTORY = new ProtocolCodecFactory()
-    {
-        public ProtocolEncoder getEncoder()
-        {
-            // Create a new encoder.
-            return new TextLineEncoder();
-        }
-
-        public ProtocolDecoder getDecoder()
-        {
-            // Create a new decoder.
-            return new TextLineDecoder();
-        }
-    };
-
-    private static IoFilter CODEC_FILTER = new ProtocolCodecFilter( CODEC_FACTORY );
-
-    public void sessionCreated( IoSession session ) throws Exception
-    {
-        session.getFilterChain().addLast( "codec", CODEC_FILTER );
-        session.getFilterChain().addLast( "logger", LOGGING_FILTER );
-    }
-
-    public void exceptionCaught( IoSession session, Throwable cause )
-    {
-        cause.printStackTrace();
-        // Close connection when unexpected exception is caught.
-        session.close();
-    }
-
-    public void messageReceived( IoSession session, Object message )
-    {
-        // Reverse reveiced string
-        String str = message.toString();
-        StringBuffer buf = new StringBuffer( str.length() );
-        for( int i = str.length() - 1; i >= 0; i-- )
-        {
-            buf.append( str.charAt( i ) );
-        }
-
-        // and write it back.
-        session.write( buf.toString() );
-    }
+/*
+ *   @(#) $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.examples.reverser;
+
+import org.apache.mina.common.IoFilter;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoHandlerAdapter;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.LoggingFilter;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.filter.codec.ProtocolDecoder;
+import org.apache.mina.filter.codec.ProtocolEncoder;
+
+/**
+ * {@link IoHandler} implementation of reverser server protocol.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$,
+ */
+public class ReverseProtocolHandler extends IoHandlerAdapter
+{
+    private static IoFilter LOGGING_FILTER = new LoggingFilter();
+    
+    private static ProtocolCodecFactory CODEC_FACTORY = new ProtocolCodecFactory()
+    {
+        public ProtocolEncoder getEncoder()
+        {
+            // Create a new encoder.
+            return new TextLineEncoder();
+        }
+
+        public ProtocolDecoder getDecoder()
+        {
+            // Create a new decoder.
+            return new TextLineDecoder();
+        }
+    };
+
+    private static IoFilter CODEC_FILTER = new ProtocolCodecFilter( CODEC_FACTORY );
+
+    public void sessionCreated( IoSession session ) throws Exception
+    {
+        session.getFilterChain().addLast( "codec", CODEC_FILTER );
+        session.getFilterChain().addLast( "logger", LOGGING_FILTER );
+    }
+
+    public void exceptionCaught( IoSession session, Throwable cause )
+    {
+        cause.printStackTrace();
+        // Close connection when unexpected exception is caught.
+        session.close();
+    }
+
+    public void messageReceived( IoSession session, Object message )
+    {
+        // Reverse reveiced string
+        String str = message.toString();
+        StringBuffer buf = new StringBuffer( str.length() );
+        for( int i = str.length() - 1; i >= 0; i-- )
+        {
+            buf.append( str.charAt( i ) );
+        }
+
+        // and write it back.
+        session.write( buf.toString() );
+    }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineDecoder.java 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.examples.reverser;
-
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.ProtocolDecoderAdapter;
-import org.apache.mina.filter.codec.ProtocolDecoderException;
-import org.apache.mina.filter.codec.ProtocolDecoderOutput;
-
-/**
- * Decodes a text line into a string.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$,
- */
-public class TextLineDecoder extends ProtocolDecoderAdapter
-{
-
-    private StringBuffer decodeBuf = new StringBuffer();
-
-    public void decode( IoSession session, ByteBuffer in,
-                        ProtocolDecoderOutput out )
-            throws Exception
-    {
-        do
-        {
-            byte b = in.get();
-            switch( b )
-            {
-            case '\r':
-                break;
-            case '\n':
-                String result = decodeBuf.toString();
-                decodeBuf.delete( 0, decodeBuf.length() );
-                out.write( result );
-                break;
-            default:
-                decodeBuf.append( ( char ) b );
-            }
-
-            // Don't accept too long line
-            if( decodeBuf.length() > 256 )
-            {
-                decodeBuf.delete( 0, decodeBuf.length() );
-                throw new ProtocolDecoderException( "The line is too long." );
-            }
-        }
-        while( in.hasRemaining() );
-    }
+/*
+ *   @(#) $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.examples.reverser;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolDecoderAdapter;
+import org.apache.mina.filter.codec.ProtocolDecoderException;
+import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+
+/**
+ * Decodes a text line into a string.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$,
+ */
+public class TextLineDecoder extends ProtocolDecoderAdapter
+{
+
+    private StringBuffer decodeBuf = new StringBuffer();
+
+    public void decode( IoSession session, ByteBuffer in,
+                        ProtocolDecoderOutput out )
+            throws Exception
+    {
+        do
+        {
+            byte b = in.get();
+            switch( b )
+            {
+            case '\r':
+                break;
+            case '\n':
+                String result = decodeBuf.toString();
+                decodeBuf.delete( 0, decodeBuf.length() );
+                out.write( result );
+                break;
+            default:
+                decodeBuf.append( ( char ) b );
+            }
+
+            // Don't accept too long line
+            if( decodeBuf.length() > 256 )
+            {
+                decodeBuf.delete( 0, decodeBuf.length() );
+                throw new ProtocolDecoderException( "The line is too long." );
+            }
+        }
+        while( in.hasRemaining() );
+    }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineEncoder.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineEncoder.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineEncoder.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/reverser/TextLineEncoder.java Wed Nov 30 21:17:41 2005
@@ -1,62 +1,62 @@
-/*
- *   @(#) $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.examples.reverser;
-
-import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
-import org.apache.mina.filter.codec.ProtocolEncoderOutput;
-
-/**
- * Encodes a string into a text line which ends with <code>"\r\n"</code>.
- * 
- * @author The Apache Directory Project (dev@directory.apache.org)
- * @version $Rev$, $Date$,
- */
-public class TextLineEncoder extends ProtocolEncoderAdapter
-{
-
-    public void encode( IoSession session, Object message,
-                        ProtocolEncoderOutput out )
-            throws Exception
-    {
-
-        String val = message.toString();
-        // Don't accept too long strings.
-        if( val.length() > 256 )
-        {
-            throw new IllegalArgumentException( "Cannot encode too long string." );
-        }
-
-        val += "\r\n";
-
-        ByteBuffer buf = ByteBuffer.allocate( val.length() );
-        for( int i = 0; i < val.length(); i++ )
-        {
-            buf.put( ( byte ) val.charAt( i ) );
-        }
-
-        buf.flip();
-        out.write( buf );
-    }
-
-    public void dispose() 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.examples.reverser;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
+import org.apache.mina.filter.codec.ProtocolEncoderOutput;
+
+/**
+ * Encodes a string into a text line which ends with <code>"\r\n"</code>.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @version $Rev$, $Date$,
+ */
+public class TextLineEncoder extends ProtocolEncoderAdapter
+{
+
+    public void encode( IoSession session, Object message,
+                        ProtocolEncoderOutput out )
+            throws Exception
+    {
+
+        String val = message.toString();
+        // Don't accept too long strings.
+        if( val.length() > 256 )
+        {
+            throw new IllegalArgumentException( "Cannot encode too long string." );
+        }
+
+        val += "\r\n";
+
+        ByteBuffer buf = ByteBuffer.allocate( val.length() );
+        for( int i = 0; i < val.length(); i++ )
+        {
+            buf.put( ( byte ) val.charAt( i ) );
+        }
+
+        buf.flip();
+        out.write( buf );
+    }
+
+    public void dispose() throws Exception
+    {
+    }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Client.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Client.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Client.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Client.java Wed Nov 30 21:17:41 2005
@@ -1,100 +1,97 @@
-/*
- *   @(#) $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.examples.sumup;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-
-import org.apache.mina.common.ConnectFuture;
-import org.apache.mina.common.IoConnector;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.filter.ThreadPoolFilter;
-import org.apache.mina.transport.socket.nio.SocketConnector;
-
-/**
- * (<strong>Entry Point</strong>) Starts SumUp client.
- * 
- * @author The Apache Directory Project
- * @version $Rev$, $Date$
- */
-public class Client
-{
-    private static final String HOSTNAME = "localhost";
-    private static final int PORT = 8080;
-    private static final int CONNECT_TIMEOUT = 30; // seconds
-    // Set this to false to use object serialization instead of custom codec.
-    private static final boolean USE_CUSTOM_CODEC = true;
-
-    public static void main( String[] args ) throws Throwable
-    {
-        if( args.length == 0 )
-        {
-            System.out.println( "Please specify the list of any integers" );
-            return;
-        }
-
-        // prepare values to sum up
-        int[] values = new int[ args.length ];
-        for( int i = 0; i < args.length; i++ )
-        {
-            values[ i ] = Integer.parseInt( args[ i ] );
-        }
-
-        // Create I/O and Protocol thread pool filter.
-        // I/O thread pool performs encoding and decoding of messages.
-        // Protocol thread pool performs actual protocol flow.
-        ThreadPoolFilter ioThreadPoolFilter = new ThreadPoolFilter();
-        ThreadPoolFilter protocolThreadPoolFilter = new ThreadPoolFilter();
-        IoConnector connector = new SocketConnector();
-        connector.getFilterChain().addFirst(
-                "ioThreadPool", ioThreadPoolFilter );
-        connector.getFilterChain().addLast(
-                "protocolThreadPool", protocolThreadPoolFilter );
-
-        // Set connect timeout.
-        connector.setConnectTimeout( CONNECT_TIMEOUT );
-        
-        IoSession session;
-        for( ;; )
-        {
-            try
-            {
-                ConnectFuture future = connector.connect(
-                        new InetSocketAddress( HOSTNAME, PORT ),
-                        new ClientSessionHandler( USE_CUSTOM_CODEC, values ) );
-                
-                future.join();
-                session = future.getSession();
-                break;
-            }
-            catch( IOException e )
-            {
-                System.err.println( "Failed to connect." );
-                e.printStackTrace();
-                Thread.sleep( 5000 );
-            }
-        }
-
-        // wait until the summation is done
-        session.getCloseFuture().join();
-        
-        // Clear the filter chain so that they are deinitialized.
-        connector.getFilterChain().clear();
-    }
-}
+/*
+ *   @(#) $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.examples.sumup;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+
+import org.apache.mina.common.ConnectFuture;
+import org.apache.mina.common.IoConnector;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.filter.ThreadPoolFilter;
+import org.apache.mina.transport.socket.nio.SocketConnector;
+
+/**
+ * (<strong>Entry Point</strong>) Starts SumUp client.
+ * 
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
+public class Client
+{
+    private static final String HOSTNAME = "localhost";
+    private static final int PORT = 8080;
+    private static final int CONNECT_TIMEOUT = 30; // seconds
+    // Set this to false to use object serialization instead of custom codec.
+    private static final boolean USE_CUSTOM_CODEC = true;
+
+    public static void main( String[] args ) throws Throwable
+    {
+        if( args.length == 0 )
+        {
+            System.out.println( "Please specify the list of any integers" );
+            return;
+        }
+
+        // prepare values to sum up
+        int[] values = new int[ args.length ];
+        for( int i = 0; i < args.length; i++ )
+        {
+            values[ i ] = Integer.parseInt( args[ i ] );
+        }
+
+        // Create I/O and Protocol thread pool filter.
+        // I/O thread pool performs encoding and decoding of messages.
+        // Protocol thread pool performs actual protocol flow.
+        ThreadPoolFilter ioThreadPoolFilter = new ThreadPoolFilter();
+        ThreadPoolFilter protocolThreadPoolFilter = new ThreadPoolFilter();
+        IoConnector connector = new SocketConnector();
+        connector.getFilterChain().addFirst(
+                "ioThreadPool", ioThreadPoolFilter );
+        connector.getFilterChain().addLast(
+                "protocolThreadPool", protocolThreadPoolFilter );
+
+        // Set connect timeout.
+        connector.setConnectTimeout( CONNECT_TIMEOUT );
+        
+        IoSession session;
+        for( ;; )
+        {
+            try
+            {
+                ConnectFuture future = connector.connect(
+                        new InetSocketAddress( HOSTNAME, PORT ),
+                        new ClientSessionHandler( USE_CUSTOM_CODEC, values ) );
+                
+                future.join();
+                session = future.getSession();
+                break;
+            }
+            catch( IOException e )
+            {
+                System.err.println( "Failed to connect." );
+                e.printStackTrace();
+                Thread.sleep( 5000 );
+            }
+        }
+
+        // wait until the summation is done
+        session.getCloseFuture().join();
+    }
+}

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java Wed Nov 30 21:17:41 2005
@@ -1,118 +1,118 @@
-/*
- *   @(#) $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.examples.sumup;
-
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoHandlerAdapter;
-import org.apache.mina.common.IoSession;
-import org.apache.mina.examples.sumup.codec.SumUpProtocolCodecFactory;
-import org.apache.mina.examples.sumup.message.AddMessage;
-import org.apache.mina.examples.sumup.message.ResultMessage;
-import org.apache.mina.filter.LoggingFilter;
-import org.apache.mina.filter.codec.ProtocolCodecFactory;
-import org.apache.mina.filter.codec.ProtocolCodecFilter;
-import org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory;
-import org.apache.mina.util.SessionLog;
-
-/**
- * {@link IoHandler} for SumUp client.
- * 
- * @author The Apache Directory Project
- * @version $Rev$, $Date$
- */
-public class ClientSessionHandler extends IoHandlerAdapter
-{
-    private final boolean useCustomCodec;
-    private final int[] values;
-    private boolean finished;
-
-    public ClientSessionHandler( boolean useCustomCodec, int[] values )
-    {
-        this.useCustomCodec = useCustomCodec;
-        this.values = values;
-    }
-
-    public boolean isFinished()
-    {
-        return finished;
-    }
-
-    public void sessionCreated( IoSession session ) throws Exception
-    {
-        ProtocolCodecFactory codec;
-        if( useCustomCodec )
-        {
-            codec = new SumUpProtocolCodecFactory( true );
-        }
-        else
-        {
-            codec = new ObjectSerializationCodecFactory();
-        }
-
-        session.getFilterChain().addLast(
-                "protocolFilter", new ProtocolCodecFilter( codec ) );
-        session.getFilterChain().addLast(
-                "logger", new LoggingFilter() );
-    }
-
-    public void sessionOpened( IoSession session )
-    {
-        // send summation requests
-        for( int i = 0; i < values.length; i++ )
-        {
-            AddMessage m = new AddMessage();
-            m.setSequence( i );
-            m.setValue( values[ i ] );
-            session.write( m );
-        }
-    }
-
-    public void messageReceived( IoSession session, Object message )
-    {
-        // server only sends ResultMessage. otherwise, we will have to identify
-        // its type using instanceof operator.
-        ResultMessage rm = ( ResultMessage ) message;
-        if( rm.isOk() )
-        {
-            // server returned OK code.
-            // if received the result message which has the last sequence
-            // number,
-            // it is time to disconnect.
-            if( rm.getSequence() == values.length - 1 )
-            {
-                // print the sum and disconnect.
-                SessionLog.info( session, "The sum: " + rm.getValue() );
-                session.close();
-                finished = true;
-            }
-        }
-        else
-        {
-            // seever returned error code because of overflow, etc.
-            SessionLog.warn( session, "Server error, disconnecting..." );
-            session.close();
-            finished = true;
-        }
-    }
-
-    public void exceptionCaught( IoSession session, Throwable cause )
-    {
-        session.close();
-    }
+/*
+ *   @(#) $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.examples.sumup;
+
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoHandlerAdapter;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.examples.sumup.codec.SumUpProtocolCodecFactory;
+import org.apache.mina.examples.sumup.message.AddMessage;
+import org.apache.mina.examples.sumup.message.ResultMessage;
+import org.apache.mina.filter.LoggingFilter;
+import org.apache.mina.filter.codec.ProtocolCodecFactory;
+import org.apache.mina.filter.codec.ProtocolCodecFilter;
+import org.apache.mina.filter.codec.serialization.ObjectSerializationCodecFactory;
+import org.apache.mina.util.SessionLog;
+
+/**
+ * {@link IoHandler} for SumUp client.
+ * 
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
+public class ClientSessionHandler extends IoHandlerAdapter
+{
+    private final boolean useCustomCodec;
+    private final int[] values;
+    private boolean finished;
+
+    public ClientSessionHandler( boolean useCustomCodec, int[] values )
+    {
+        this.useCustomCodec = useCustomCodec;
+        this.values = values;
+    }
+
+    public boolean isFinished()
+    {
+        return finished;
+    }
+
+    public void sessionCreated( IoSession session ) throws Exception
+    {
+        ProtocolCodecFactory codec;
+        if( useCustomCodec )
+        {
+            codec = new SumUpProtocolCodecFactory( true );
+        }
+        else
+        {
+            codec = new ObjectSerializationCodecFactory();
+        }
+
+        session.getFilterChain().addLast(
+                "protocolFilter", new ProtocolCodecFilter( codec ) );
+        session.getFilterChain().addLast(
+                "logger", new LoggingFilter() );
+    }
+
+    public void sessionOpened( IoSession session )
+    {
+        // send summation requests
+        for( int i = 0; i < values.length; i++ )
+        {
+            AddMessage m = new AddMessage();
+            m.setSequence( i );
+            m.setValue( values[ i ] );
+            session.write( m );
+        }
+    }
+
+    public void messageReceived( IoSession session, Object message )
+    {
+        // server only sends ResultMessage. otherwise, we will have to identify
+        // its type using instanceof operator.
+        ResultMessage rm = ( ResultMessage ) message;
+        if( rm.isOk() )
+        {
+            // server returned OK code.
+            // if received the result message which has the last sequence
+            // number,
+            // it is time to disconnect.
+            if( rm.getSequence() == values.length - 1 )
+            {
+                // print the sum and disconnect.
+                SessionLog.info( session, "The sum: " + rm.getValue() );
+                session.close();
+                finished = true;
+            }
+        }
+        else
+        {
+            // seever returned error code because of overflow, etc.
+            SessionLog.warn( session, "Server error, disconnecting..." );
+            session.close();
+            finished = true;
+        }
+    }
+
+    public void exceptionCaught( IoSession session, Throwable cause )
+    {
+        session.close();
+    }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Server.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Server.java?rev=350169&r1=350168&r2=350169&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Server.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/sumup/Server.java Wed Nov 30 21:17:41 2005
@@ -1,49 +1,49 @@
-/*
- *   @(#) $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.examples.sumup;
-
-import org.apache.mina.common.TransportType;
-import org.apache.mina.registry.Service;
-import org.apache.mina.registry.ServiceRegistry;
-import org.apache.mina.registry.SimpleServiceRegistry;
-
-/**
- * (<strong>Entry Point</strong>) Starts SumUp server.
- * 
- * @author The Apache Directory Project
- * @version $Rev$, $Date$
- */
-public class Server
-{
-    private static final int SERVER_PORT = 8080;
-    // Set this to false to use object serialization instead of custom codec.
-    private static final boolean USE_CUSTOM_CODEC = true;
-
-    public static void main( String[] args ) throws Throwable
-    {
-        // Create ServiceRegistry.
-        ServiceRegistry registry = new SimpleServiceRegistry();
-
-        registry.bind(
-                new Service( "sumUp", TransportType.SOCKET, SERVER_PORT ),
-                new ServerSessionHandler( USE_CUSTOM_CODEC ) );
-
-        System.out.println( "Listening on port " + SERVER_PORT );
-    }
-}
+/*
+ *   @(#) $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.examples.sumup;
+
+import org.apache.mina.common.TransportType;
+import org.apache.mina.registry.Service;
+import org.apache.mina.registry.ServiceRegistry;
+import org.apache.mina.registry.SimpleServiceRegistry;
+
+/**
+ * (<strong>Entry Point</strong>) Starts SumUp server.
+ * 
+ * @author The Apache Directory Project
+ * @version $Rev$, $Date$
+ */
+public class Server
+{
+    private static final int SERVER_PORT = 8080;
+    // Set this to false to use object serialization instead of custom codec.
+    private static final boolean USE_CUSTOM_CODEC = true;
+
+    public static void main( String[] args ) throws Throwable
+    {
+        // Create ServiceRegistry.
+        ServiceRegistry registry = new SimpleServiceRegistry();
+
+        registry.bind(
+                new Service( "sumUp", TransportType.SOCKET, SERVER_PORT ),
+                new ServerSessionHandler( USE_CUSTOM_CODEC ) );
+
+        System.out.println( "Listening on port " + SERVER_PORT );
+    }
+}