com.sun.grizzly.http
Class SocketChannelOutputBuffer

java.lang.Object
  extended by com.sun.grizzly.tcp.http11.InternalOutputBuffer
      extended by com.sun.grizzly.http.SocketChannelOutputBuffer
All Implemented Interfaces:
OutputBuffer, ByteChunk.ByteOutputChannel
Direct Known Subclasses:
SSLAsyncOutputBuffer, SSLOutputBuffer

public class SocketChannelOutputBuffer
extends InternalOutputBuffer

Output buffer. Buffer the bytes until the ByteChunk is full or the request is completed.

Author:
Jean-Francois Arcand, Scott Oaks

Nested Class Summary
 
Nested classes/interfaces inherited from class com.sun.grizzly.tcp.http11.InternalOutputBuffer
InternalOutputBuffer.OutputStreamOutputBuffer
 
Field Summary
protected  SocketChannel socketChannel
          Underlying output socketChannel.
 
Fields inherited from class com.sun.grizzly.tcp.http11.InternalOutputBuffer
activeFilters, buf, committed, filterLibrary, finished, headers, lastActiveFilter, outputStream, outputStreamOutputBuffer, pos, response, sm, socketBuffer, useSocketBuffer
 
Constructor Summary
SocketChannelOutputBuffer(Response response, int headerBufferSize, boolean useSocketBuffer)
          Alternate constructor.
 
Method Summary
 void endRequest()
          End request.
 void flush()
          Flush the buffered bytes,
 void flushBuffer()
          Writes bytes to the underlying socketChannel.
 void flushChannel(ByteBuffer bb)
          Flush the buffer by looping until the ByteBuffer is empty
 SocketChannel getChannel()
          Return the underlying SocketChannel
static int getMaxBufferedBytes()
           
 void realWriteBytes(byte[] cbuf, int off, int len)
          Callback to write data from the buffer.
 void recycle()
          Recycle the output buffer.
 void sendAck()
          Send an acknoledgement without buffering.
 void setChannel(SocketChannel socketChannel)
          Set the underlying socket output stream.
static void setMaxBufferedBytes(int aMaxBufferedBytes)
           
 
Methods inherited from class com.sun.grizzly.tcp.http11.InternalOutputBuffer
addActiveFilter, addFilter, clearFilters, commit, doWrite, endHeaders, getFilters, getOutputStream, nextRequest, reset, sendHeader, sendHeader, sendHeader, sendStatus, setOutputStream, setSocketBuffer, write, write, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

socketChannel

protected SocketChannel socketChannel
Underlying output socketChannel.

Constructor Detail

SocketChannelOutputBuffer

public SocketChannelOutputBuffer(Response response,
                                 int headerBufferSize,
                                 boolean useSocketBuffer)
Alternate constructor.

Method Detail

setChannel

public void setChannel(SocketChannel socketChannel)
Set the underlying socket output stream.


getChannel

public SocketChannel getChannel()
Return the underlying SocketChannel


sendAck

public void sendAck()
             throws IOException
Send an acknoledgement without buffering.

Overrides:
sendAck in class InternalOutputBuffer
Throws:
IOException

realWriteBytes

public void realWriteBytes(byte[] cbuf,
                           int off,
                           int len)
                    throws IOException
Callback to write data from the buffer.

Specified by:
realWriteBytes in interface ByteChunk.ByteOutputChannel
Overrides:
realWriteBytes in class InternalOutputBuffer
Throws:
IOException

flushChannel

public void flushChannel(ByteBuffer bb)
                  throws IOException
Flush the buffer by looping until the ByteBuffer is empty

Parameters:
bb - the ByteBuffer to write.
Throws:
IOException

flush

public void flush()
           throws IOException
Flush the buffered bytes,

Overrides:
flush in class InternalOutputBuffer
Throws:
IOException - an undelying I/O error occured

endRequest

public void endRequest()
                throws IOException
End request.

Overrides:
endRequest in class InternalOutputBuffer
Throws:
IOException - an undelying I/O error occured

flushBuffer

public void flushBuffer()
                 throws IOException
Writes bytes to the underlying socketChannel.

Throws:
IOException

recycle

public void recycle()
Recycle the output buffer. This should be called when closing the connection.

Overrides:
recycle in class InternalOutputBuffer

getMaxBufferedBytes

public static int getMaxBufferedBytes()

setMaxBufferedBytes

public static void setMaxBufferedBytes(int aMaxBufferedBytes)


Copyright © 2008 SUN Microsystems. All Rights Reserved.