geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r577061 - /geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/
Date Tue, 18 Sep 2007 21:00:42 GMT
Author: jdillon
Date: Tue Sep 18 14:00:41 2007
New Revision: 577061

URL: http://svn.apache.org/viewvc?rev=577061&view=rev
Log:
Rename these, Io* was bugging me

Added:
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java
  (contents, props changed)
      - copied, changed from r576955, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/IoSessionInputStream.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
  (contents, props changed)
      - copied, changed from r576955, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/IoSessionOutputStream.java
Removed:
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/IoSessionInputStream.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/IoSessionOutputStream.java
    geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/StreamIoHandler.java

Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java
(from r576955, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/IoSessionInputStream.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/IoSessionInputStream.java&r1=576955&r2=577061&rev=577061&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/IoSessionInputStream.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java
Tue Sep 18 14:00:41 2007
@@ -26,20 +26,21 @@
 import java.io.IOException;
 import java.io.InputStream;
 
+import org.apache.geronimo.gshell.remote.message.WriteStreamMessage;
 import org.apache.mina.common.ByteBuffer;
-import org.apache.mina.common.IoHandler;
-import org.apache.mina.common.IoSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * An {@link InputStream} that buffers data read from
- * {@link IoHandler#messageReceived(IoSession,Object)} events.
+ * An {@link InputStream} that buffers data read from {@link WriteStreamMessage} messages.
  *
- * @author The Apache MINA Project (dev@mina.apache.org)
- * @version $Rev$, $Date$
+ * @version $Rev$ $Date$
  */
-public class IoSessionInputStream
+public class SessionInputStream
     extends InputStream
 {
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    
     private final Object mutex = new Object();
 
     private final ByteBuffer buff;
@@ -50,10 +51,10 @@
 
     private IOException exception;
 
-    public IoSessionInputStream() {
-        buff = ByteBuffer.allocate(16);
+    public SessionInputStream() {
+        buff = ByteBuffer.allocate(256);
         buff.setAutoExpand(true);
-        buff.limit(0);
+        // buff.limit(0);
     }
 
     @Override
@@ -161,17 +162,21 @@
                 return;
             }
 
+            log.debug("Filling {} byte(s) into stream from: {}", src.remaining(), src);
+            
             if (buff.hasRemaining()) {
-                this.buff.compact();
-                this.buff.put(src);
-                this.buff.flip();
+                log.debug("Buffer has remaining: {} byte(s)", buff.remaining());
+                
+                buff.compact();
             }
             else {
-                this.buff.clear();
-                this.buff.put(src);
-                this.buff.flip();
-                mutex.notifyAll();
+                buff.clear();
             }
+
+            buff.put(src);
+            buff.flip();
+
+            mutex.notifyAll();
         }
     }
 

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionInputStream.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
(from r576955, geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/IoSessionOutputStream.java)
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java?p2=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java&p1=geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/IoSessionOutputStream.java&r1=576955&r2=577061&rev=577061&view=diff
==============================================================================
--- geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/IoSessionOutputStream.java
(original)
+++ geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
Tue Sep 18 14:00:41 2007
@@ -30,22 +30,26 @@
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.WriteFuture;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * An {@link OutputStream} that forwards all write operations to
- * the associated {@link IoSession}.
+ * An {@link OutputStream} that forwards all write operations as {@link WriteStreamMessage}
messages.
  *
- * @author The Apache MINA Project (dev@mina.apache.org)
- * @version $Rev$, $Date$
+ * @version $Rev$ $Date$
  */
-public class IoSessionOutputStream
+public class SessionOutputStream
     extends OutputStream
 {
+    private final Logger log = LoggerFactory.getLogger(getClass());
+    
     private final IoSession session;
 
     private WriteFuture lastWriteFuture;
 
-    public IoSessionOutputStream(final IoSession session) {
+    public SessionOutputStream(final IoSession session) {
+        assert session != null;
+        
         this.session = session;
     }
 
@@ -55,11 +59,7 @@
             flush();
         }
         finally {
-            //
-            // FIXME: This probably should not close the session...
-            //
-            
-            session.close().awaitUninterruptibly();
+            super.close();
         }
     }
 
@@ -72,6 +72,8 @@
     private synchronized void write(final ByteBuffer buff) throws IOException {
         ensureOpened();
 
+        log.trace("Writing stream from: {}", buff);
+
         WriteStreamMessage msg = new WriteStreamMessage("IN", buff);
         
         lastWriteFuture = session.write(msg);
@@ -84,10 +86,13 @@
 
     @Override
     public void write(final int b) throws IOException {
-        ByteBuffer buf = ByteBuffer.allocate(1);
-        buf.put((byte) b);
-        buf.flip();
-        write(buf);
+        ByteBuffer buff = ByteBuffer.allocate(1);
+
+        buff.put((byte) b);
+
+        buff.flip();
+
+        write(buff);
     }
 
     @Override
@@ -96,14 +101,14 @@
             return;
         }
 
-        //
-        // TODO: Really need to provide an abstraction here to use the Transport interfaces
-        //
+        log.trace("Flushing stream...");
         
         lastWriteFuture.awaitUninterruptibly();
         
         if (!lastWriteFuture.isWritten()) {
             throw new IOException("The bytes could not be written to the session");
         }
+
+        log.trace("Flushed");
     }
 }

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/gshell/trunk/gshell-remote/gshell-remote-common/src/main/java/org/apache/geronimo/gshell/remote/stream/SessionOutputStream.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message