directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r326428 - in /directory/network: branches/0.7/src/java/org/apache/mina/io/ branches/0.7/src/java/org/apache/mina/io/datagram/ branches/0.7/src/java/org/apache/mina/io/socket/ branches/0.7/src/java/org/apache/mina/protocol/ branches/0.7/src/...
Date Wed, 19 Oct 2005 07:40:47 GMT
Author: trustin
Date: Wed Oct 19 00:40:18 2005
New Revision: 326428

URL: http://svn.apache.org/viewcvs?rev=326428&view=rev
Log:
Resolved issue: DIRMINA-96 - Provide an API for connectionless transport types to create a
session from IoAcceptor.
* Added IoAcceptor.newSession()
** SocketAcceptor throws UnsupportedOperationException
** DatagramAcceptor returns an appropriate DatagramSession
** IoProtocolAcceptor.newSession() wraps IoAcceptor.newSession()


Modified:
    directory/network/branches/0.7/src/java/org/apache/mina/io/IoAcceptor.java
    directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
    directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketAcceptor.java
    directory/network/branches/0.7/src/java/org/apache/mina/protocol/ProtocolAcceptor.java
    directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java
    directory/network/branches/0.7/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/common/BaseIoAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/common/IoAcceptor.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/SocketAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java

Modified: directory/network/branches/0.7/src/java/org/apache/mina/io/IoAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/io/IoAcceptor.java?rev=326428&r1=326427&r2=326428&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/io/IoAcceptor.java (original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/io/IoAcceptor.java Wed Oct 19
00:40:18 2005
@@ -54,4 +54,20 @@
      * Unbinds from the specified <code>address</code>.
      */
     void unbind( SocketAddress address );
+
+    /**
+     * (Optional) Returns an {@link IoSession} that is bound to the specified
+     * <tt>localAddress</tt> and <tt>remoteAddress</tt> which reuses
+     * the <tt>localAddress</tt> that is already bound by {@link IoAcceptor}
+     * via {@link #bind(SocketAddress, IoHandler)}.
+     * <p>
+     * This operation is optional.  Please throw {@link UnsupportedOperationException}
+     * if the transport type doesn't support this operation.  This operation is
+     * usually implemented for connectionless transport types.
+     * 
+     * @throws UnsupportedOperationException if this operation is not supported
+     * @throws IllegalArgumentException if the specified <tt>localAddress</tt>
is
+     *                                  not bound yet. (see {@link #bind(SocketAddress, IoHandler)})
+     */
+    IoSession newSession( SocketAddress remoteAddress, SocketAddress localAddress );
 }

Modified: directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java?rev=326428&r1=326427&r2=326428&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
(original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/io/datagram/DatagramAcceptor.java
Wed Oct 19 00:40:18 2005
@@ -33,6 +33,7 @@
 import org.apache.mina.io.IoAcceptor;
 import org.apache.mina.io.IoFilterChain;
 import org.apache.mina.io.IoHandler;
+import org.apache.mina.io.IoSession;
 import org.apache.mina.io.IoSessionManagerFilterChain;
 import org.apache.mina.util.ExceptionUtil;
 import org.apache.mina.util.Queue;
@@ -165,6 +166,47 @@
         }
     }
     
+    public IoSession newSession( SocketAddress remoteAddress, SocketAddress localAddress
)
+    {
+        if( remoteAddress == null )
+        {
+            throw new NullPointerException( "remoteAddress" );
+        }
+        if( localAddress == null )
+        {
+            throw new NullPointerException( "localAddress" );
+        }
+        
+        Selector selector = this.selector;
+        DatagramChannel ch = ( DatagramChannel ) channels.get( localAddress );
+        if( selector == null || ch == null )
+        {
+            throw new IllegalArgumentException( "Unknown localAddress: " + localAddress );
+        }
+            
+        SelectionKey key = ch.keyFor( selector );
+        if( key == null )
+        {
+            throw new IllegalArgumentException( "Unknown lodalAddress: " + localAddress );
+        }
+
+        RegistrationRequest req = ( RegistrationRequest ) key.attachment();
+        DatagramSession s = new DatagramSession( filters, ch, req.handler );
+        s.setRemoteAddress( remoteAddress );
+        s.setSelectionKey( key );
+        
+        try
+        {
+            req.handler.sessionCreated( s );
+        }
+        catch( Throwable t )
+        {
+            exceptionMonitor.exceptionCaught( this, t );
+        }
+        
+        return s;
+    }
+
     private synchronized void startupWorker() throws IOException
     {
         if( worker == null )

Modified: directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketAcceptor.java?rev=326428&r1=326427&r2=326428&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketAcceptor.java
(original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/io/socket/SocketAcceptor.java
Wed Oct 19 00:40:18 2005
@@ -34,6 +34,7 @@
 import org.apache.mina.io.IoAcceptor;
 import org.apache.mina.io.IoFilterChain;
 import org.apache.mina.io.IoHandler;
+import org.apache.mina.io.IoSession;
 import org.apache.mina.io.IoSessionManagerFilterChain;
 import org.apache.mina.util.Queue;
 
@@ -488,5 +489,11 @@
         {
             this.address = address;
         }
+    }
+
+
+    public IoSession newSession( SocketAddress remoteAddress, SocketAddress localAddress
)
+    {
+        throw new UnsupportedOperationException();
     }
 }

Modified: directory/network/branches/0.7/src/java/org/apache/mina/protocol/ProtocolAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/protocol/ProtocolAcceptor.java?rev=326428&r1=326427&r2=326428&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/protocol/ProtocolAcceptor.java
(original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/protocol/ProtocolAcceptor.java
Wed Oct 19 00:40:18 2005
@@ -55,4 +55,20 @@
      * Unbinds from the specified <code>address</code>.
      */
     void unbind( SocketAddress address );
+    
+    /**
+     * (Optional) Returns a {@link ProtocolSession} that is bound to the specified
+     * <tt>localAddress</tt> and <tt>remoteAddress</tt> which reuses
+     * the <tt>localAddress</tt> that is already bound by {@link ProtocolAcceptor}
+     * via {@link #bind(SocketAddress, ProtocolProvider)}.
+     * <p>
+     * This operation is optional.  Please throw {@link UnsupportedOperationException}
+     * if the transport type doesn't support this operation.  This operation is
+     * usually implemented for connectionless transport types.
+     * 
+     * @throws UnsupportedOperationException if this operation is not supported
+     * @throws IllegalArgumentException if the specified <tt>localAddress</tt>
is
+     *                                  not bound yet. (see {@link #bind(SocketAddress, ProtocolProvider)})
+     */
+    ProtocolSession newSession( SocketAddress remoteAddress, SocketAddress localAddress );
 }

Modified: directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java?rev=326428&r1=326427&r2=326428&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java
(original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java
Wed Oct 19 00:40:18 2005
@@ -61,6 +61,11 @@
         acceptor.unbind( address );
     }
     
+    public ProtocolSession newSession( SocketAddress remoteAddress, SocketAddress localAddress
)
+    {
+        return adapter.toProtocolSession( acceptor.newSession( remoteAddress, localAddress
) );
+    }
+
     public ProtocolFilterChain getFilterChain()
     {
         return adapter.getFilterChain();

Modified: directory/network/branches/0.7/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java?rev=326428&r1=326427&r2=326428&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
(original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
Wed Oct 19 00:40:18 2005
@@ -13,6 +13,7 @@
 import org.apache.mina.protocol.ProtocolFilterChain;
 import org.apache.mina.protocol.ProtocolHandler;
 import org.apache.mina.protocol.ProtocolProvider;
+import org.apache.mina.protocol.ProtocolSession;
 
 /**
  * Binds the specified {@link ProtocolProvider} to the specified
@@ -97,5 +98,10 @@
             this.managerFilterChain = managerFilterChain;
             this.handler = handler;
         }
+    }
+
+    public ProtocolSession newSession( SocketAddress remoteAddress, SocketAddress localAddress
)
+    {
+        throw new UnsupportedOperationException();
     }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/common/BaseIoAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/BaseIoAcceptor.java?rev=326428&r1=326427&r2=326428&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/BaseIoAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/BaseIoAcceptor.java Wed Oct 19
00:40:18 2005
@@ -36,4 +36,9 @@
     {
         unbind( address, true );
     }
+    
+    public IoSession newSession( SocketAddress remoteAddress, SocketAddress localAddress
)
+    {
+        throw new UnsupportedOperationException();
+    }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/common/IoAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/IoAcceptor.java?rev=326428&r1=326427&r2=326428&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/IoAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/IoAcceptor.java Wed Oct 19 00:40:18
2005
@@ -64,4 +64,20 @@
      *                          <tt>false</tt> otherwise.
      */
     void unbind( SocketAddress address, boolean disconnectClients );
+    
+    /**
+     * (Optional) Returns an {@link IoSession} that is bound to the specified
+     * <tt>localAddress</tt> and <tt>remoteAddress</tt> which reuses
+     * the <tt>localAddress</tt> that is already bound by {@link IoAcceptor}
+     * via {@link #bind(SocketAddress, IoHandler)}.
+     * <p>
+     * This operation is optional.  Please throw {@link UnsupportedOperationException}
+     * if the transport type doesn't support this operation.  This operation is
+     * usually implemented for connectionless transport types.
+     * 
+     * @throws UnsupportedOperationException if this operation is not supported
+     * @throws IllegalArgumentException if the specified <tt>localAddress</tt>
is
+     *                                  not bound yet. (see {@link #bind(SocketAddress, IoHandler)})
+     */
+    IoSession newSession( SocketAddress remoteAddress, SocketAddress localAddress );
 }

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java?rev=326428&r1=326427&r2=326428&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/DatagramAcceptor.java
Wed Oct 19 00:40:18 2005
@@ -34,6 +34,7 @@
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionManagerConfig;
 import org.apache.mina.common.IoSessionManagerFilterChain;
 import org.apache.mina.common.IoFilter.WriteRequest;
@@ -174,6 +175,47 @@
         }
     }
     
+    public IoSession newSession( SocketAddress remoteAddress, SocketAddress localAddress
)
+    {
+        if( remoteAddress == null )
+        {
+            throw new NullPointerException( "remoteAddress" );
+        }
+        if( localAddress == null )
+        {
+            throw new NullPointerException( "localAddress" );
+        }
+        
+        Selector selector = this.selector;
+        DatagramChannel ch = ( DatagramChannel ) channels.get( localAddress );
+        if( selector == null || ch == null )
+        {
+            throw new IllegalArgumentException( "Unknown localAddress: " + localAddress );
+        }
+            
+        SelectionKey key = ch.keyFor( selector );
+        if( key == null )
+        {
+            throw new IllegalArgumentException( "Unknown lodalAddress: " + localAddress );
+        }
+
+        RegistrationRequest req = ( RegistrationRequest ) key.attachment();
+        DatagramSession s = new DatagramSession( filters, ch, req.handler );
+        s.setRemoteAddress( remoteAddress );
+        s.setSelectionKey( key );
+        
+        try
+        {
+            req.handler.sessionCreated( s );
+        }
+        catch( Throwable t )
+        {
+            exceptionMonitor.exceptionCaught( this, t );
+        }
+        
+        return s;
+    }
+
     private synchronized void startupWorker() throws IOException
     {
         if( worker == null )

Modified: directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java?rev=326428&r1=326427&r2=326428&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/socket/nio/SocketAcceptor.java
Wed Oct 19 00:40:18 2005
@@ -34,6 +34,7 @@
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionManagerConfig;
 import org.apache.mina.common.IoSessionManagerFilterChain;
 import org.apache.mina.util.Queue;

Modified: directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java?rev=326428&r1=326427&r2=326428&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/transport/vmpipe/VmPipeAcceptor.java
Wed Oct 19 00:40:18 2005
@@ -12,6 +12,7 @@
 import org.apache.mina.common.BaseIoAcceptorConfig;
 import org.apache.mina.common.IoFilterChain;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
 import org.apache.mina.common.IoSessionManagerConfig;
 
 /**



Mime
View raw message