directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r165120 - in /directory/network/trunk/src: java/org/apache/mina/common/ java/org/apache/mina/io/datagram/ java/org/apache/mina/io/socket/ java/org/apache/mina/protocol/ java/org/apache/mina/protocol/io/ java/org/apache/mina/protocol/vmpipe/ java/org/apache/mina/util/ test/org/apache/mina/io/ test/org/apache/mina/protocol/ test/org/apache/mina/protocol/codec/
Date Thu, 28 Apr 2005 09:03:58 GMT
Author: trustin
Date: Thu Apr 28 02:03:57 2005
New Revision: 165120

URL: http://svn.apache.org/viewcvs?rev=165120&view=rev
Log:
* Moved BaseSession, BaseSessionConfig, BaseSessionManager to common package
* Added SimpleProtocolEncoderOutput and SimpleProtocolDecoderOutput

Added:
    directory/network/trunk/src/java/org/apache/mina/common/BaseSession.java   (with props)
    directory/network/trunk/src/java/org/apache/mina/common/BaseSessionConfig.java   (with
props)
    directory/network/trunk/src/java/org/apache/mina/common/BaseSessionManager.java   (with
props)
    directory/network/trunk/src/java/org/apache/mina/protocol/SimpleProtocolDecoderOutput.java
  (with props)
    directory/network/trunk/src/java/org/apache/mina/protocol/SimpleProtocolEncoderOutput.java
  (with props)
Removed:
    directory/network/trunk/src/java/org/apache/mina/util/BaseSession.java
    directory/network/trunk/src/java/org/apache/mina/util/BaseSessionConfig.java
    directory/network/trunk/src/java/org/apache/mina/util/BaseSessionManager.java
Modified:
    directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramProcessor.java
    directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSession.java
    directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSessionConfig.java
    directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java
    directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSession.java
    directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSessionConfig.java
    directory/network/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java
    directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolSession.java
    directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
    directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java
    directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSession.java
    directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSessionConfig.java
    directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java
    directory/network/trunk/src/test/org/apache/mina/protocol/ProtocolHandlerFilterChainTest.java
    directory/network/trunk/src/test/org/apache/mina/protocol/codec/CumulativeProtocolDecoderTest.java

Added: directory/network/trunk/src/java/org/apache/mina/common/BaseSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/BaseSession.java?rev=165120&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/BaseSession.java (added)
+++ directory/network/trunk/src/java/org/apache/mina/common/BaseSession.java Thu Apr 28 02:03:57
2005
@@ -0,0 +1,166 @@
+/*
+ *   @(#) $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.common;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.Session;
+
+/**
+ * Base implementation of {@link Session}.
+ * 
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$
+ */
+public abstract class BaseSession implements Session
+{
+    private final Map attributes = new HashMap();
+
+    private long readBytes;
+    
+    private long writtenBytes;
+    
+    private long lastReadTime;
+    
+    private long lastWriteTime;
+
+    private boolean idleForBoth;
+
+    private boolean idleForRead;
+
+    private boolean idleForWrite;
+
+
+    protected BaseSession()
+    {
+    }
+    
+    public void close()
+    {
+        this.close( false );
+    }
+
+    public Object getAttachment()
+    {
+        return attributes.get( "" );
+    }
+
+    public Object setAttachment( Object attachment )
+    {
+        synchronized( attributes )
+        {
+            return attributes.put( "", attachment );
+        }
+    }
+
+    public Object getAttribute( String key )
+    {
+        return attributes.get( key );
+    }
+
+    public Object setAttribute( String key, Object value )
+    {
+        synchronized( attributes )
+        {
+            return attributes.put( key, value );
+        }
+    }
+    
+    public Object removeAttribute( String key )
+    {
+        synchronized( attributes )
+        {
+            return attributes.remove( key );
+        }
+    }
+
+    public Set getAttributeKeys() {
+        synchronized( attributes )
+        {
+            return attributes.keySet();
+        }
+    }
+    
+    public long getReadBytes()
+    {
+        return readBytes;
+    }
+
+    public long getWrittenBytes()
+    {
+        return writtenBytes;
+    }
+
+    public void increaseReadBytes( int increment )
+    {
+        readBytes += increment;
+        lastReadTime = System.currentTimeMillis();
+    }
+
+    public void increaseWrittenBytes( int increment )
+    {
+        writtenBytes += increment;
+        lastWriteTime = System.currentTimeMillis();
+    }
+
+    public long getLastIoTime()
+    {
+        return Math.max( lastReadTime, lastWriteTime );
+    }
+
+    public long getLastReadTime()
+    {
+        return lastReadTime;
+    }
+
+    public long getLastWriteTime()
+    {
+        return lastWriteTime;
+    }
+
+    public boolean isIdle( IdleStatus status )
+    {
+        if( status == IdleStatus.BOTH_IDLE )
+            return idleForBoth;
+
+        if( status == IdleStatus.READER_IDLE )
+            return idleForRead;
+
+        if( status == IdleStatus.WRITER_IDLE )
+            return idleForWrite;
+
+        throw new IllegalArgumentException( "Unknown idle status: " + status );
+    }
+
+    public void setIdle( IdleStatus status, boolean value )
+    {
+        if( status == IdleStatus.BOTH_IDLE )
+            idleForBoth = value;
+        else if( status == IdleStatus.READER_IDLE )
+            idleForRead = value;
+        else if( status == IdleStatus.WRITER_IDLE )
+            idleForWrite = value;
+        else
+            throw new IllegalArgumentException( "Unknown idle status: "
+                                                + status );
+    }
+}

Propchange: directory/network/trunk/src/java/org/apache/mina/common/BaseSession.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Added: directory/network/trunk/src/java/org/apache/mina/common/BaseSessionConfig.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/BaseSessionConfig.java?rev=165120&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/BaseSessionConfig.java (added)
+++ directory/network/trunk/src/java/org/apache/mina/common/BaseSessionConfig.java Thu Apr
28 02:03:57 2005
@@ -0,0 +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.common;
+
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.SessionConfig;
+
+/**
+ * Base implementation of {@link SessionConfig}s.
+ * 
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$
+ */
+public abstract class BaseSessionConfig implements SessionConfig
+{
+    private int idleTimeForRead;
+
+    private int idleTimeForWrite;
+
+    private int idleTimeForBoth;
+
+    private int writeTimeout;
+
+    protected BaseSessionConfig()
+    {
+    }
+
+    public int getIdleTime( IdleStatus status )
+    {
+        if( status == IdleStatus.BOTH_IDLE )
+            return idleTimeForBoth;
+
+        if( status == IdleStatus.READER_IDLE )
+            return idleTimeForRead;
+
+        if( status == IdleStatus.WRITER_IDLE )
+            return idleTimeForWrite;
+
+        throw new IllegalArgumentException( "Unknown idle status: " + status );
+    }
+
+    public long getIdleTimeInMillis( IdleStatus status )
+    {
+        return getIdleTime( status ) * 1000L;
+    }
+
+    public void setIdleTime( IdleStatus status, int idleTime )
+    {
+        if( idleTime < 0 )
+            throw new IllegalArgumentException( "Illegal idle time: "
+                                                + idleTime );
+
+        if( status == IdleStatus.BOTH_IDLE )
+            idleTimeForBoth = idleTime;
+        else if( status == IdleStatus.READER_IDLE )
+            idleTimeForRead = idleTime;
+        else if( status == IdleStatus.WRITER_IDLE )
+            idleTimeForWrite = idleTime;
+        else
+            throw new IllegalArgumentException( "Unknown idle status: "
+                                                + status );
+    }
+
+    public int getWriteTimeout()
+    {
+        return writeTimeout;
+    }
+
+    public long getWriteTimeoutInMillis()
+    {
+        return writeTimeout * 1000L;
+    }
+
+    public void setWriteTimeout( int writeTimeout )
+    {
+        if( writeTimeout < 0 )
+            throw new IllegalArgumentException( "Illegal write timeout: "
+                                                + writeTimeout );
+        this.writeTimeout = writeTimeout;
+    }
+}
\ No newline at end of file

Propchange: directory/network/trunk/src/java/org/apache/mina/common/BaseSessionConfig.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Added: directory/network/trunk/src/java/org/apache/mina/common/BaseSessionManager.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/BaseSessionManager.java?rev=165120&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/BaseSessionManager.java (added)
+++ directory/network/trunk/src/java/org/apache/mina/common/BaseSessionManager.java Thu Apr
28 02:03:57 2005
@@ -0,0 +1,78 @@
+/*
+ *   @(#) $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.common;
+
+import org.apache.mina.common.DefaultExceptionMonitor;
+import org.apache.mina.common.DefaultSessionInitializer;
+import org.apache.mina.common.ExceptionMonitor;
+import org.apache.mina.common.SessionInitializer;
+import org.apache.mina.common.SessionManager;
+
+/**
+ * Base implementation of {@link SessionManager}s.
+ * 
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$
+ */
+public class BaseSessionManager implements SessionManager {
+
+    /**
+     * Default session initializer.
+     */
+    protected SessionInitializer defaultInitializer = new DefaultSessionInitializer();
+
+    /**
+     * Current exception monitor.
+     */
+    protected ExceptionMonitor exceptionMonitor = new DefaultExceptionMonitor();
+    
+    protected BaseSessionManager()
+    {
+    }
+
+    public SessionInitializer getDefaultSessionInitializer()
+    {
+        return defaultInitializer;
+    }
+
+    public void setDefaultSessionInitializer( SessionInitializer defaultInitializer )
+    {
+        if( defaultInitializer == null )
+        {
+            defaultInitializer = new DefaultSessionInitializer();
+        }
+        
+        this.defaultInitializer = defaultInitializer;
+    }
+
+    public ExceptionMonitor getExceptionMonitor()
+    {
+        return exceptionMonitor;
+    }
+
+    public void setExceptionMonitor( ExceptionMonitor monitor )
+    {
+        if( monitor == null )
+        {
+            monitor = new DefaultExceptionMonitor();
+        }
+
+        this.exceptionMonitor = monitor;
+    }
+}

Propchange: directory/network/trunk/src/java/org/apache/mina/common/BaseSessionManager.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Modified: directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramProcessor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramProcessor.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramProcessor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramProcessor.java Thu
Apr 28 02:03:57 2005
@@ -18,7 +18,7 @@
  */
 package org.apache.mina.io.datagram;
 
-import org.apache.mina.util.BaseSessionManager;
+import org.apache.mina.common.BaseSessionManager;
 
 /**
  * A base class for {@link DatagramAcceptor} and {@link DatagramConnector}.

Modified: directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSession.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSession.java Thu
Apr 28 02:03:57 2005
@@ -22,12 +22,12 @@
 import java.nio.channels.DatagramChannel;
 import java.nio.channels.SelectionKey;
 
+import org.apache.mina.common.BaseSession;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.SessionConfig;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.io.IoHandler;
 import org.apache.mina.io.IoSession;
-import org.apache.mina.util.BaseSession;
 import org.apache.mina.util.Queue;
 
 /**

Modified: directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSessionConfig.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSessionConfig.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSessionConfig.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/io/datagram/DatagramSessionConfig.java
Thu Apr 28 02:03:57 2005
@@ -21,10 +21,10 @@
 import java.net.SocketException;
 import java.nio.channels.DatagramChannel;
 
+import org.apache.mina.common.BaseSessionConfig;
 import org.apache.mina.common.SessionConfig;
 import org.apache.mina.io.IoSession;
 import org.apache.mina.protocol.ProtocolSession;
-import org.apache.mina.util.BaseSessionConfig;
 
 /**
  * A {@link SessionConfig} for datagram transport (UDP/IP).

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketAcceptor.java Thu Apr
28 02:03:57 2005
@@ -30,11 +30,11 @@
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.mina.common.BaseSessionManager;
 import org.apache.mina.common.SessionInitializer;
 import org.apache.mina.io.IoAcceptor;
 import org.apache.mina.io.IoHandler;
 import org.apache.mina.io.IoHandlerFilterChain;
-import org.apache.mina.util.BaseSessionManager;
 import org.apache.mina.util.Queue;
 
 /**

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketConnector.java Thu Apr
28 02:03:57 2005
@@ -28,12 +28,12 @@
 import java.util.Iterator;
 import java.util.Set;
 
+import org.apache.mina.common.BaseSessionManager;
 import org.apache.mina.common.SessionInitializer;
 import org.apache.mina.io.IoConnector;
 import org.apache.mina.io.IoHandler;
 import org.apache.mina.io.IoHandlerFilterChain;
 import org.apache.mina.io.IoSession;
-import org.apache.mina.util.BaseSessionManager;
 import org.apache.mina.util.Queue;
 
 /**

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSession.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSession.java Thu Apr
28 02:03:57 2005
@@ -22,12 +22,12 @@
 import java.nio.channels.SelectionKey;
 import java.nio.channels.SocketChannel;
 
+import org.apache.mina.common.BaseSession;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.SessionConfig;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.io.IoHandler;
 import org.apache.mina.io.IoSession;
-import org.apache.mina.util.BaseSession;
 import org.apache.mina.util.Queue;
 
 /**

Modified: directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSessionConfig.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSessionConfig.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSessionConfig.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/socket/SocketSessionConfig.java Thu
Apr 28 02:03:57 2005
@@ -20,10 +20,10 @@
 
 import java.net.SocketException;
 
+import org.apache.mina.common.BaseSessionConfig;
 import org.apache.mina.common.SessionConfig;
 import org.apache.mina.io.IoSession;
 import org.apache.mina.protocol.ProtocolSession;
-import org.apache.mina.util.BaseSessionConfig;
 
 /**
  * A {@link SessionConfig} for socket transport (TCP/IP).

Added: directory/network/trunk/src/java/org/apache/mina/protocol/SimpleProtocolDecoderOutput.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/SimpleProtocolDecoderOutput.java?rev=165120&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/SimpleProtocolDecoderOutput.java
(added)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/SimpleProtocolDecoderOutput.java
Thu Apr 28 02:03:57 2005
@@ -0,0 +1,34 @@
+/**
+ * 
+ */
+package org.apache.mina.protocol;
+
+import org.apache.mina.protocol.ProtocolDecoderOutput;
+import org.apache.mina.util.Queue;
+
+/**
+ * A {@link ProtocolDecoderOutput} based on queue.
+ * 
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$
+ *
+ */
+public class SimpleProtocolDecoderOutput implements ProtocolDecoderOutput
+{
+    private final Queue messageQueue = new Queue();
+    
+    public SimpleProtocolDecoderOutput()
+    {
+    }
+    
+    public Queue getMessageQueue()
+    {
+        return messageQueue;
+    }
+    
+    public void write( Object message )
+    {
+        messageQueue.push( message );
+    }
+}
\ No newline at end of file

Propchange: directory/network/trunk/src/java/org/apache/mina/protocol/SimpleProtocolDecoderOutput.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

Added: directory/network/trunk/src/java/org/apache/mina/protocol/SimpleProtocolEncoderOutput.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/SimpleProtocolEncoderOutput.java?rev=165120&view=auto
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/SimpleProtocolEncoderOutput.java
(added)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/SimpleProtocolEncoderOutput.java
Thu Apr 28 02:03:57 2005
@@ -0,0 +1,73 @@
+/**
+ * 
+ */
+package org.apache.mina.protocol;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.mina.protocol.ProtocolEncoderOutput;
+import org.apache.mina.util.Queue;
+
+/**
+ * A {@link ProtocolEncoderOutput} based on queue.
+ *
+ * @author The Apache Directory Project (dev@directory.apache.org)
+ * @author Trustin Lee (trustin@apache.org)
+ * @version $Rev$, $Date$
+ */
+public class SimpleProtocolEncoderOutput implements ProtocolEncoderOutput
+{
+
+    private final Queue bufferQueue = new Queue();
+    
+    public SimpleProtocolEncoderOutput()
+    {
+    }
+    
+    public Queue getBufferQueue()
+    {
+        return bufferQueue;
+    }
+    
+    public void write( ByteBuffer buf )
+    {
+        bufferQueue.push( buf );
+    }
+    
+    public void mergeAll()
+    {
+        int sum = 0;
+        final int size = bufferQueue.size();
+        
+        if( size < 2 )
+        {
+            // no need to merge!
+            return;
+        }
+        
+        // Get the size of merged BB
+        for( int i = size - 1; i >= 0; i -- )
+        {
+            sum += ( ( ByteBuffer ) bufferQueue.get( i ) ).remaining();
+        }
+        
+        // Allocate a new BB that will contain all fragments
+        ByteBuffer newBuf = ByteBuffer.allocate( sum );
+        
+        // and merge all.
+        for( ;; )
+        {
+            ByteBuffer buf = ( ByteBuffer ) bufferQueue.pop();
+            if( buf == null )
+            {
+                break;
+            }
+    
+            newBuf.put( buf );
+            buf.release();
+        }
+        
+        // Push the new buffer finally.
+        newBuf.flip();
+        bufferQueue.push(newBuf);
+    }
+}
\ No newline at end of file

Propchange: directory/network/trunk/src/java/org/apache/mina/protocol/SimpleProtocolEncoderOutput.java
------------------------------------------------------------------------------
    svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision

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=165120&r1=165119&r2=165120&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 28
02:03:57 2005
@@ -130,7 +130,7 @@
                     decoder.decode( psession, in, psession.decOut );
                 }
 
-                Queue queue = psession.decOut.messageQueue;
+                Queue queue = psession.decOut.getMessageQueue();
                 synchronized( queue )
                 {
                     if( !queue.isEmpty() )
@@ -183,7 +183,7 @@
                         if( message == null )
                             break;
 
-                        Queue queue = psession.encOut.queue;
+                        Queue queue = psession.encOut.getBufferQueue();
                         encoder.encode( psession, message, psession.encOut );
                         for( ;; )
                         {

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolSession.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolSession.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolSession.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/io/IoProtocolSession.java Thu
Apr 28 02:03:57 2005
@@ -6,17 +6,16 @@
 import java.net.SocketAddress;
 import java.util.Set;
 
-import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.SessionConfig;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.io.IoSession;
 import org.apache.mina.protocol.ProtocolDecoder;
-import org.apache.mina.protocol.ProtocolDecoderOutput;
 import org.apache.mina.protocol.ProtocolEncoder;
-import org.apache.mina.protocol.ProtocolEncoderOutput;
 import org.apache.mina.protocol.ProtocolHandler;
 import org.apache.mina.protocol.ProtocolSession;
+import org.apache.mina.protocol.SimpleProtocolDecoderOutput;
+import org.apache.mina.protocol.SimpleProtocolEncoderOutput;
 import org.apache.mina.protocol.io.IoAdapter.SessionHandlerAdapter;
 import org.apache.mina.util.Queue;
 
@@ -40,9 +39,9 @@
     
     final ProtocolDecoder decoder;
 
-    final ProtocolEncoderOutputImpl encOut;
+    final SimpleProtocolEncoderOutput encOut;
 
-    final ProtocolDecoderOutputImpl decOut;
+    final SimpleProtocolDecoderOutput decOut;
 
     IoProtocolSession( IoAdapter ioAdapter, IoSession session,
                        SessionHandlerAdapter shAdapter )
@@ -52,8 +51,8 @@
         this.shAdapter = shAdapter;
         this.encoder = shAdapter.codecFactory.newEncoder();
         this.decoder = shAdapter.codecFactory.newDecoder();
-        this.encOut = new ProtocolEncoderOutputImpl();
-        this.decOut = new ProtocolDecoderOutputImpl();
+        this.encOut = new SimpleProtocolEncoderOutput();
+        this.decOut = new SimpleProtocolDecoderOutput();
     }
     
     /**
@@ -177,72 +176,5 @@
     public boolean isIdle( IdleStatus status )
     {
         return session.isIdle( status );
-    }
-
-    static class ProtocolEncoderOutputImpl implements ProtocolEncoderOutput
-    {
-    
-        final Queue queue = new Queue();
-        
-        private ProtocolEncoderOutputImpl()
-        {
-        }
-        
-        public void write( ByteBuffer buf )
-        {
-            queue.push( buf );
-        }
-        
-        public void mergeAll()
-        {
-            int sum = 0;
-            final int size = queue.size();
-            
-            if( size < 2 )
-            {
-                // no need to merge!
-                return;
-            }
-            
-            // Get the size of merged BB
-            for( int i = size - 1; i >= 0; i -- )
-            {
-                sum += ( ( ByteBuffer ) queue.get( i ) ).remaining();
-            }
-            
-            // Allocate a new BB that will contain all fragments
-            ByteBuffer newBuf = ByteBuffer.allocate( sum );
-            
-            // and merge all.
-            for( ;; )
-            {
-                ByteBuffer buf = ( ByteBuffer ) queue.pop();
-                if( buf == null )
-                {
-                    break;
-                }
-        
-                newBuf.put( buf );
-                buf.release();
-            }
-            
-            // Push the new buffer finally.
-            newBuf.flip();
-            queue.push(newBuf);
-        }
-    }
-        
-    static class ProtocolDecoderOutputImpl implements ProtocolDecoderOutput
-    {
-        final Queue messageQueue = new Queue();
-        
-        private ProtocolDecoderOutputImpl()
-        {
-        }
-        
-        public void write( Object message )
-        {
-            messageQueue.push( message );
-        }
     }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeAcceptor.java Thu
Apr 28 02:03:57 2005
@@ -8,12 +8,12 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.mina.common.BaseSessionManager;
 import org.apache.mina.common.SessionInitializer;
 import org.apache.mina.protocol.ProtocolAcceptor;
 import org.apache.mina.protocol.ProtocolHandler;
 import org.apache.mina.protocol.ProtocolHandlerFilterChain;
 import org.apache.mina.protocol.ProtocolProvider;
-import org.apache.mina.util.BaseSessionManager;
 
 /**
  * Binds the specified {@link ProtocolProvider} to the specified

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeConnector.java
Thu Apr 28 02:03:57 2005
@@ -6,13 +6,13 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
+import org.apache.mina.common.BaseSessionManager;
 import org.apache.mina.common.SessionInitializer;
 import org.apache.mina.protocol.ProtocolConnector;
 import org.apache.mina.protocol.ProtocolHandlerFilterChain;
 import org.apache.mina.protocol.ProtocolProvider;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.vmpipe.VmPipeAcceptor.Entry;
-import org.apache.mina.util.BaseSessionManager;
 
 /**
  * Connects to {@link ProtocolProvider}s which is bound on the specified

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=165120&r1=165119&r2=165120&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 28 02:03:57 2005
@@ -6,6 +6,7 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
+import org.apache.mina.common.BaseSession;
 import org.apache.mina.common.SessionConfig;
 import org.apache.mina.common.SessionInitializer;
 import org.apache.mina.common.TransportType;
@@ -14,7 +15,6 @@
 import org.apache.mina.protocol.ProtocolHandler;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.vmpipe.VmPipeAcceptor.Entry;
-import org.apache.mina.util.BaseSession;
 
 /**
  * A {@link ProtocolSession} for in-VM transport (VM_PIPE).

Modified: directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSessionConfig.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSessionConfig.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSessionConfig.java
(original)
+++ directory/network/trunk/src/java/org/apache/mina/protocol/vmpipe/VmPipeSessionConfig.java
Thu Apr 28 02:03:57 2005
@@ -3,8 +3,8 @@
  */
 package org.apache.mina.protocol.vmpipe;
 
+import org.apache.mina.common.BaseSessionConfig;
 import org.apache.mina.common.SessionConfig;
-import org.apache.mina.util.BaseSessionConfig;
 
 /**
  * A {@link SessionConfig} for in-VM pipe transport.

Modified: directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java (original)
+++ directory/network/trunk/src/test/org/apache/mina/io/IoHandlerFilterChainTest.java Thu
Apr 28 02:03:57 2005
@@ -23,11 +23,11 @@
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
+import org.apache.mina.common.BaseSession;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.SessionConfig;
 import org.apache.mina.common.TransportType;
-import org.apache.mina.util.BaseSession;
 
 /**
  * Tests {@link AbstractIoHandlerFilterChain}.

Modified: directory/network/trunk/src/test/org/apache/mina/protocol/ProtocolHandlerFilterChainTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/protocol/ProtocolHandlerFilterChainTest.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/protocol/ProtocolHandlerFilterChainTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/protocol/ProtocolHandlerFilterChainTest.java
Thu Apr 28 02:03:57 2005
@@ -23,10 +23,10 @@
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
+import org.apache.mina.common.BaseSession;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.SessionConfig;
 import org.apache.mina.common.TransportType;
-import org.apache.mina.util.BaseSession;
 
 /**
  * Tests {@link AbstractProtocolHandlerFilterChain}.

Modified: directory/network/trunk/src/test/org/apache/mina/protocol/codec/CumulativeProtocolDecoderTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/protocol/codec/CumulativeProtocolDecoderTest.java?rev=165120&r1=165119&r2=165120&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/protocol/codec/CumulativeProtocolDecoderTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/protocol/codec/CumulativeProtocolDecoderTest.java
Thu Apr 28 02:03:57 2005
@@ -25,6 +25,7 @@
 import junit.framework.Assert;
 import junit.framework.TestCase;
 
+import org.apache.mina.common.BaseSession;
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.SessionConfig;
 import org.apache.mina.common.TransportType;
@@ -34,7 +35,6 @@
 import org.apache.mina.protocol.ProtocolHandler;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.protocol.ProtocolViolationException;
-import org.apache.mina.util.BaseSession;
 
 /**
  * Tests {@link CumulativeProtocolDecoder}.



Mime
View raw message