directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r164074 - in /directory/network/trunk/src/java/org/apache/mina: common/ByteBuffer.java common/Session.java protocol/io/IoAdapter.java protocol/io/IoProtocolAcceptor.java protocol/vmpipe/VmPipeSession.java util/BaseSession.java
Date Thu, 21 Apr 2005 15:43:17 GMT
Author: trustin
Date: Thu Apr 21 08:43:16 2005
New Revision: 164074

URL: http://svn.apache.org/viewcvs?rev=164074&view=rev
Log:
* Added Session.removeAttribute()
* IoAdapter doesn't store ProtocolSession in attachment anymore.
* Fixed: VmPipeSession doesn't call both SessionInitializer.

Modified:
    directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java
    directory/network/trunk/src/java/org/apache/mina/common/Session.java
    directory/network/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java
    directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java
    directory/network/trunk/src/java/org/apache/mina/util/BaseSession.java

Modified: directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java?rev=164074&r1=164073&r2=164074&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/ByteBuffer.java Thu Apr 21 08:43:16
2005
@@ -32,6 +32,9 @@
 import java.nio.charset.CharsetEncoder;
 import java.nio.charset.CoderResult;
 
+import org.apache.mina.io.IoHandler;
+import org.apache.mina.io.IoSession;
+import org.apache.mina.protocol.ProtocolEncoderOutput;
 import org.apache.mina.util.Stack;
 
 /**

Modified: directory/network/trunk/src/java/org/apache/mina/common/Session.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/Session.java?rev=164074&r1=164073&r2=164074&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/Session.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/Session.java Thu Apr 21 08:43:16
2005
@@ -72,6 +72,13 @@
     Object setAttribute( String key, Object value );
     
     /**
+     * Removes a user-defined attribute with the specified key.
+     * 
+     * @return The old value of the attribute.  <tt>null</tt> if not found.
+     */
+    Object removeAttribute( String key );
+    
+    /**
      * Returns the set of keys of all user-defined attributes.
      */
     Set getAttributeKeys();

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java?rev=164074&r1=164073&r2=164074&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java Thu Apr 21
08:43:16 2005
@@ -53,6 +53,8 @@
  */
 public class IoAdapter
 {
+    private static final String KEY = "IoAdapter.ProtocolSession";
+
     private final IoProtocolFilterChain filters = new IoProtocolFilterChain();
 
     IoAdapter()
@@ -162,14 +164,13 @@
         {
             if( marker == null )
                 return;
-            filters.messageSent( 
-                    ( ProtocolSession ) session.getAttachment(), marker );
+            filters.messageSent( getProtocolSession( session ),
+                                 marker );
         }
 
         void doWrite( IoSession session )
         {
-            ProtocolSessionImpl psession = ( ProtocolSessionImpl ) session
-                    .getAttachment();
+            ProtocolSessionImpl psession = getProtocolSession( session );
             ProtocolEncoder encoder = psession.encoder;
             Queue writeQueue = psession.writeQueue;
 
@@ -210,18 +211,18 @@
 
         private ProtocolSessionImpl getProtocolSession( IoSession session )
         {
-            ProtocolSessionImpl psession = ( ProtocolSessionImpl ) session
-                    .getAttachment();
+            ProtocolSessionImpl psession =
+                ( ProtocolSessionImpl ) session.getAttribute( KEY );
             if( psession == null )
             {
                 synchronized( session )
                 {
-                    psession = ( ProtocolSessionImpl ) session
-                            .getAttachment();
+                    psession =
+                        ( ProtocolSessionImpl ) session.getAttribute( KEY );
                     if( psession == null )
                     {
                         psession = new ProtocolSessionImpl( session, this );
-                        session.setAttachment( psession );
+                        session.setAttribute( KEY, psession );
                     }
                 }
             }
@@ -295,6 +296,11 @@
         public Object setAttribute( String key, Object value )
         {
             return session.setAttribute( key, value );
+        }
+        
+        public Object removeAttribute( String key )
+        {
+            return session.removeAttribute( key );
         }
 
         public Set getAttributeKeys()

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java?rev=164074&r1=164073&r2=164074&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolAcceptor.java Thu
Apr 21 08:43:16 2005
@@ -9,9 +9,11 @@
 import org.apache.mina.common.ExceptionMonitor;
 import org.apache.mina.common.SessionInitializer;
 import org.apache.mina.io.IoAcceptor;
+import org.apache.mina.io.IoSession;
 import org.apache.mina.protocol.ProtocolAcceptor;
 import org.apache.mina.protocol.ProtocolHandlerFilterChain;
 import org.apache.mina.protocol.ProtocolProvider;
+import org.apache.mina.protocol.ProtocolSession;
 
 /**
  * A {@link ProtocolAcceptor} which wraps {@link IoAcceptor} to provide

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java?rev=164074&r1=164073&r2=164074&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java Thu
Apr 21 08:43:16 2005
@@ -61,11 +61,9 @@
         remoteSession = new VmPipeSession( this, remoteEntry.handler );
         if( remoteEntry.initializer != null )
         {
-            boolean success = false;
             try
             {
                 remoteEntry.initializer.initializeSession( remoteSession );
-                success = true;
             }
             catch( Throwable t )
             {
@@ -74,6 +72,8 @@
                 e.initCause( t );
                 throw e;
             }
+            
+            initializer.initializeSession( this );
         }
 
         remoteEntry.filters.sessionOpened( remoteSession );

Modified: directory/network/trunk/src/java/org/apache/mina/util/BaseSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/util/BaseSession.java?rev=164074&r1=164073&r2=164074&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/util/BaseSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/util/BaseSession.java Thu Apr 21 08:43:16
2005
@@ -79,6 +79,14 @@
             return attributes.put( key, value );
         }
     }
+    
+    public Object removeAttribute( String key )
+    {
+        synchronized( attributes )
+        {
+            return attributes.remove( key );
+        }
+    }
 
     public Set getAttributeKeys() {
         synchronized( attributes )
@@ -86,7 +94,7 @@
             return attributes.keySet();
         }
     }
-
+    
     public long getReadBytes()
     {
         return readBytes;



Mime
View raw message