directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r349998 - in /directory/network/branches/chain_refactor/src: java/org/apache/mina/common/support/ java/org/apache/mina/transport/socket/nio/ java/org/apache/mina/transport/socket/nio/support/ test/org/apache/mina/common/
Date Wed, 30 Nov 2005 17:32:59 GMT
Author: trustin
Date: Wed Nov 30 09:32:35 2005
New Revision: 349998

URL: http://svn.apache.org/viewcvs?rev=349998&view=rev
Log:
Fixed: SocketSession.getManager() and DatagramSession.getManager() returns delegate.

Modified:
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSession.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoAcceptor.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoConnector.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java
    directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java
    directory/network/branches/chain_refactor/src/test/org/apache/mina/common/FutureTest.java

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSession.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSession.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSession.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/BaseIoSession.java
Wed Nov 30 09:32:35 2005
@@ -38,8 +38,6 @@
  */
 public abstract class BaseIoSession implements IoSession
 {
-    // TODO pull up getManager() from other implementations.
-    
     private final Map attributes = new HashMap();
     private final long creationTime;
 

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoAcceptor.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoAcceptor.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoAcceptor.java
Wed Nov 30 09:32:35 2005
@@ -36,12 +36,19 @@
  */
 public class DelegatedIoAcceptor implements IoAcceptor
 {
-    protected final IoAcceptor delegate;
+    protected IoAcceptor delegate;
     
     /**
      * Creates a new instance.
      */
-    protected DelegatedIoAcceptor( IoAcceptor delegate )
+    protected DelegatedIoAcceptor()
+    {
+    }
+    
+    /**
+     * Sets the delegate.
+     */
+    protected void init( IoAcceptor delegate )
     {
         this.delegate = delegate;
     }

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoConnector.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoConnector.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/common/support/DelegatedIoConnector.java
Wed Nov 30 09:32:35 2005
@@ -36,16 +36,23 @@
  */
 public class DelegatedIoConnector implements IoConnector
 {
-    protected final IoConnector delegate;
+    protected IoConnector delegate;
 
     /**
      * Creates a new instance.
      */
-    protected DelegatedIoConnector( IoConnector delegate )
+    protected DelegatedIoConnector()
     {
-        this.delegate = delegate;
     }
 
+    /**
+     * Sets the delegate.
+     */
+    protected void init( IoConnector delegate )
+    {
+        this.delegate = delegate;
+    }
+    
     public ConnectFuture connect( SocketAddress address, IoHandler handler ) throws IOException
     {
         return delegate.connect( address, handler );

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
Wed Nov 30 09:32:35 2005
@@ -35,6 +35,6 @@
      */
     public DatagramAcceptor()
     {
-        super( new DatagramAcceptorDelegate() );
+        init( new DatagramAcceptorDelegate( this ) );
     }
 }

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/DatagramConnector.java
Wed Nov 30 09:32:35 2005
@@ -35,6 +35,6 @@
      */
     public DatagramConnector()
     {
-        super( new DatagramConnectorDelegate() );
+        init( new DatagramConnectorDelegate( this ) );
     }
 }

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
Wed Nov 30 09:32:35 2005
@@ -35,7 +35,7 @@
      */
     public SocketAcceptor()
     {
-        super( new SocketAcceptorDelegate() );
+        init( new SocketAcceptorDelegate( this ) );
     }
 
     public int getReceiveBufferSize()

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/SocketConnector.java
Wed Nov 30 09:32:35 2005
@@ -35,7 +35,7 @@
      */
     public SocketConnector()
     {
-        super( new SocketConnectorDelegate() );
+        init( new SocketConnectorDelegate( this ) );
     }
 
 

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramAcceptorDelegate.java
Wed Nov 30 09:32:35 2005
@@ -47,9 +47,9 @@
  */
 public class DatagramAcceptorDelegate extends BaseIoAcceptor implements IoAcceptor, DatagramSessionManager
 {
-    // FIXME use real manager, not the delegate
     private static volatile int nextId = 0;
 
+    private final IoAcceptor wrapper;
     private final int id = nextId ++ ;
     private Selector selector;
     private final Map channels = new HashMap();
@@ -61,8 +61,9 @@
     /**
      * Creates a new instance.
      */
-    public DatagramAcceptorDelegate()
+    public DatagramAcceptorDelegate( IoAcceptor wrapper )
     {
+        this.wrapper = wrapper;
     }
 
     public void bind( SocketAddress address, IoHandler handler, IoFilterChainBuilder filterChainBuilder
)
@@ -190,7 +191,7 @@
         }
 
         RegistrationRequest req = ( RegistrationRequest ) key.attachment();
-        DatagramSessionImpl s = new DatagramSessionImpl( this, ch, req.handler );
+        DatagramSessionImpl s = new DatagramSessionImpl( wrapper, this, ch, req.handler );
         s.setRemoteAddress( remoteAddress );
         s.setSelectionKey( key );
         
@@ -316,7 +317,7 @@
 
             RegistrationRequest req = ( RegistrationRequest ) key.attachment();
             DatagramSessionImpl session =
-                new DatagramSessionImpl( this, ch, req.handler );
+                new DatagramSessionImpl( wrapper, this, ch, req.handler );
             session.setSelectionKey( key );
             
             try

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramConnectorDelegate.java
Wed Nov 30 09:32:35 2005
@@ -44,9 +44,9 @@
  */
 public class DatagramConnectorDelegate extends BaseIoConnector implements DatagramSessionManager
 {
-    // FIXME use real manager, not the delegate
     private static volatile int nextId = 0;
 
+    private final IoConnector wrapper;
     private final int id = nextId ++ ;
     private Selector selector;
     private final Queue registerQueue = new Queue();
@@ -58,8 +58,9 @@
     /**
      * Creates a new instance.
      */
-    public DatagramConnectorDelegate()
+    public DatagramConnectorDelegate( IoConnector wrapper )
     {
+        this.wrapper = wrapper;
     }
 
     public ConnectFuture connect( SocketAddress address, IoHandler handler, IoFilterChainBuilder
filterChainBuilder ) throws IOException
@@ -474,7 +475,7 @@
                 break;
 
             DatagramSessionImpl session =
-                new DatagramSessionImpl( this, req.channel, req.handler );
+                new DatagramSessionImpl( wrapper, this, req.channel, req.handler );
 
             boolean success = false;
             try

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramFilterChain.java
Wed Nov 30 09:32:35 2005
@@ -30,17 +30,18 @@
             if( writeRequestQueue.size() == 1 && session.getTrafficMask().isWritable()
)
             {
                 // Notify DatagramSessionManager only when writeRequestQueue was empty.
-                ( ( DatagramSessionManager ) s.getManager() ).flushSession( s );
+                s.getManagerDelegate().flushSession( s );
             }
         }
     }
 
     protected void doClose( IoSession session, CloseFuture closeFuture )
     {
-        DatagramSessionManager manager = ( DatagramSessionManager ) session.getManager();
+        DatagramSessionImpl s = ( DatagramSessionImpl ) session;
+        DatagramSessionManager manager = s.getManagerDelegate();
         if( manager instanceof DatagramConnectorDelegate )
         {
-            ( ( DatagramConnectorDelegate ) manager ).closeSession( ( DatagramSessionImpl
) session );
+            ( ( DatagramConnectorDelegate ) manager ).closeSession( s );
         }
         else
         {

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/DatagramSessionImpl.java
Wed Nov 30 09:32:35 2005
@@ -42,7 +42,8 @@
  */
 class DatagramSessionImpl extends BaseIoSession implements DatagramSession
 {
-    private final DatagramSessionManager manager;
+    private final IoSessionManager wrapperManager;
+    private final DatagramSessionManager managerDelegate;
     private final DatagramFilterChain filterChain;
     private final DatagramChannel ch;
     private final Queue writeRequestQueue;
@@ -54,10 +55,12 @@
     /**
      * Creates a new instance.
      */
-    DatagramSessionImpl( DatagramSessionManager manager,
+    DatagramSessionImpl( IoSessionManager wrapperManager,
+                         DatagramSessionManager managerDelegate,
                          DatagramChannel ch, IoHandler defaultHandler )
     {
-        this.manager = manager;
+        this.wrapperManager = wrapperManager;
+        this.managerDelegate = managerDelegate;
         this.filterChain = new DatagramFilterChain( this );
         this.ch = ch;
         this.writeRequestQueue = new Queue();
@@ -68,7 +71,12 @@
     
     public IoSessionManager getManager()
     {
-        return manager;
+        return wrapperManager;
+    }
+    
+    DatagramSessionManager getManagerDelegate()
+    {
+        return managerDelegate;
     }
 
     public IoFilterChain getFilterChain()
@@ -166,6 +174,6 @@
 
     protected void updateTrafficMask()
     {
-        manager.updateTrafficMask( this );
+        managerDelegate.updateTrafficMask( this );
     }
 }

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketAcceptorDelegate.java
Wed Nov 30 09:32:35 2005
@@ -45,9 +45,9 @@
  */
 public class SocketAcceptorDelegate extends BaseIoAcceptor implements SocketSessionManager
 {
-    // FIXME use real manager, not the delegate
     private static volatile int nextId = 0;
 
+    private final IoAcceptor wrapper;
     private final int id = nextId ++ ;
     private final String threadName = "SocketAcceptor-" + id;
     private boolean reuseAddress = false;
@@ -65,8 +65,9 @@
     /**
      * Creates a new instance.
      */
-    public SocketAcceptorDelegate()
+    public SocketAcceptorDelegate( IoAcceptor wrapper )
     {
+        this.wrapper = wrapper;
     }
 
     /**
@@ -303,7 +304,7 @@
                 try
                 {
                     RegistrationRequest req = ( RegistrationRequest ) key.attachment();
-                    SocketSessionImpl session = new SocketSessionImpl( SocketAcceptorDelegate.this,
ioProcessor, ch, req.handler );
+                    SocketSessionImpl session = new SocketSessionImpl( SocketAcceptorDelegate.this.wrapper,
ioProcessor, ch, req.handler );
                     SocketAcceptorDelegate.this.filterChainBuilder.buildFilterChain( session.getFilterChain()
);
                     req.filterChainBuilder.buildFilterChain( session.getFilterChain() );
                     ( ( SocketFilterChain ) session.getFilterChain() ).sessionCreated( session
);

Modified: directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java
(original)
+++ directory/network/branches/chain_refactor/src/java/org/apache/mina/transport/socket/nio/support/SocketConnectorDelegate.java
Wed Nov 30 09:32:35 2005
@@ -45,9 +45,9 @@
  */
 public class SocketConnectorDelegate extends BaseIoConnector implements SocketSessionManager
 {
-    // FIXME use real manager, not the delegate
     private static volatile int nextId = 0;
 
+    private final IoConnector wrapper;
     private final int id = nextId++;
     private final String threadName = "SocketConnector-" + id;
     private Selector selector;
@@ -58,8 +58,9 @@
     /**
      * Creates a new instance.
      */
-    public SocketConnectorDelegate()
+    public SocketConnectorDelegate( IoConnector wrapper )
     {
+        this.wrapper = wrapper;
     }
 
     public ConnectFuture connect( SocketAddress address, IoHandler handler, IoFilterChainBuilder
filterChainBuilder ) throws IOException
@@ -241,7 +242,7 @@
 
     private SocketSessionImpl newSession( SocketChannel ch, IoHandler handler, IoFilterChainBuilder
filterChainBuilder ) throws IOException
     {
-        SocketSessionImpl session = new SocketSessionImpl( this, ioProcessor, ch, handler
);
+        SocketSessionImpl session = new SocketSessionImpl( wrapper, ioProcessor, ch, handler
);
         try
         {
             this.filterChainBuilder.buildFilterChain( session.getFilterChain() );

Modified: directory/network/branches/chain_refactor/src/test/org/apache/mina/common/FutureTest.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/chain_refactor/src/test/org/apache/mina/common/FutureTest.java?rev=349998&r1=349997&r2=349998&view=diff
==============================================================================
--- directory/network/branches/chain_refactor/src/test/org/apache/mina/common/FutureTest.java
(original)
+++ directory/network/branches/chain_refactor/src/test/org/apache/mina/common/FutureTest.java
Wed Nov 30 09:32:35 2005
@@ -73,24 +73,9 @@
                 return null;
             }
 
-            public WriteFuture write( Object message )
-            {
-                return null;
-            }
-
-            public CloseFuture close()
-            {
-                return null;
-            }
-
             public TransportType getTransportType()
             {
                 return null;
-            }
-
-            public boolean isConnected()
-            {
-                return false;
             }
 
             public SocketAddress getRemoteAddress()



Mime
View raw message