Enhydra 5.1 API

org.enhydra.servlet.connectionMethods.EnhydraDirector
Class EnhydraDirectorBufferedOutputStream

java.lang.Object
  |
  +--java.io.OutputStream
        |
        +--java.io.FilterOutputStream
              |
              +--java.io.BufferedOutputStream
                    |
                    +--org.enhydra.servlet.connectionMethods.EnhydraDirector.EnhydraDirectorBufferedOutputStream

public class EnhydraDirectorBufferedOutputStream
extends java.io.BufferedOutputStream

Extension of BufferedOutputStream to allow "reset" of the buffer.

A servlet container's ServletResponse object should not go into the "committed" (data sent) state until the headers have actually been sent over the wire. This allows a servlet to specify a large buffer size and be able to reset or change headers well after the first byte of data has been written to the ServletOutputStream.

This class has a reset() that, after checking for committed state of the connection, discards any buffered data and self destructs, dropping any reference to its internally held output stream. Once reset() has been called, this object must be discarded as it is then useless. A new instance should be created in its place.


Field Summary
 
Fields inherited from class java.io.BufferedOutputStream
buf, count
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
EnhydraDirectorBufferedOutputStream(java.io.OutputStream os, int size, EnhydraDirectorConnection connection)
          Creates a new instance with the specified connection context, OutputStream, and buffer size.
 
Method Summary
 void flush()
          Flushes outgoing data, then flushes the contained output stream.
 void reset()
          Discards buffered data and drops reference to the output stream.
 
Methods inherited from class java.io.BufferedOutputStream
write, write
 
Methods inherited from class java.io.FilterOutputStream
close, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EnhydraDirectorBufferedOutputStream

public EnhydraDirectorBufferedOutputStream(java.io.OutputStream os,
                                           int size,
                                           EnhydraDirectorConnection connection)
Creates a new instance with the specified connection context, OutputStream, and buffer size.

Parameters:
os - The output stream.
size - Buffer size.
connection - The connection context.
Method Detail

reset

public void reset()
           throws java.lang.IllegalStateException
Discards buffered data and drops reference to the output stream.

If the current connection has not sent any data over the wire, this method drops any buffered data, as well as the output stream reference, to ensure that this instance makes no further calls to the underlying stream. It is expected that the caller of this method will also discard any reference to this EnhydraDirectorBufferedOutputStream object. Once reset() has been called, this stream becomes unusable.

Throws:
java.lang.IllegalStateException - If called after data has been sent.

flush

public void flush()
           throws java.io.IOException
Flushes outgoing data, then flushes the contained output stream.

Overrides:
flush in class java.io.BufferedOutputStream
Throws:
java.io.IOException - If there is an error sending data.

Enhydra 5.1 API