com.opensymphony.oscache.web.filter
Class SplitServletOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by javax.servlet.ServletOutputStream
          extended by com.opensymphony.oscache.web.filter.SplitServletOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class SplitServletOutputStream
extends ServletOutputStream

Extends the base ServletOutputStream class so that the stream can be captured as it gets written. This is achieved by overriding the write() methods and outputting the data to two streams - the original stream and a secondary stream that is designed to capture the written data.

Version:
$Revision: 393 $
Author:
Serge Knystautas

Constructor Summary
SplitServletOutputStream(OutputStream captureStream, OutputStream passThroughStream)
          Constructs a split output stream that both captures and passes through the servlet response.
 
Method Summary
 void close()
          Closes both the output streams.
 void flush()
          Flushes both the output streams.
 void write(byte[] value)
          Writes the incoming data to both the output streams.
 void write(byte[] b, int off, int len)
          Writes the incoming data to both the output streams.
 void write(int value)
          Writes the incoming data to both the output streams.
 
Methods inherited from class javax.servlet.ServletOutputStream
print, print, print, print, print, print, print, println, println, println, println, println, println, println, println
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SplitServletOutputStream

public SplitServletOutputStream(OutputStream captureStream,
                                OutputStream passThroughStream)
Constructs a split output stream that both captures and passes through the servlet response.

Parameters:
captureStream - The stream that will be used to capture the data.
passThroughStream - The pass-through ServletOutputStream that will write the response to the client as originally intended.
Method Detail

write

public void write(int value)
           throws IOException
Writes the incoming data to both the output streams.

Specified by:
write in class OutputStream
Parameters:
value - The int data to write.
Throws:
IOException

write

public void write(byte[] value)
           throws IOException
Writes the incoming data to both the output streams.

Overrides:
write in class OutputStream
Parameters:
value - The bytes to write to the streams.
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Writes the incoming data to both the output streams.

Overrides:
write in class OutputStream
Parameters:
b - The bytes to write out to the streams.
off - The offset into the byte data where writing should begin.
len - The number of bytes to write.
Throws:
IOException

flush

public void flush()
           throws IOException
Flushes both the output streams.

Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

close

public void close()
           throws IOException
Closes both the output streams.

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

OSCache Project Page