|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.OutputStream
javax.servlet.ServletOutputStream
org.rakeshv.filters.CachingResponseStream
public class CachingResponseStream
A sub-class of ServletOutputStream that is used to
cache the response sent by the server to a client request. This
stream writes every byte that is send to the client to the cache
file also.
© Copyright 2005, Rakesh Vidyadharan
| Field Summary | |
|---|---|
protected java.io.BufferedOutputStream |
cacheFile
The file to which the responses are to be cached. |
protected boolean |
closed
Has this stream been closed? |
protected javax.servlet.ServletOutputStream |
output
The underlying servlet output stream to which we should write data. |
protected javax.servlet.http.HttpServletResponse |
response
The response with which this servlet output stream is associated. |
private TeeOutputStream |
tee
The tee that represents the output and
cacheFile. |
| Constructor Summary | |
|---|---|
CachingResponseStream(javax.servlet.http.HttpServletResponse response,
java.io.File file)
Initialise a new instance of this class with the specified servlet response. |
|
| Method Summary | |
|---|---|
void |
close()
Close this output stream, causing any buffered data to be flushed and any further output data to throw an IOException. |
void |
closeCacheFile()
Closes the cacheFile without closing the output. |
void |
flush()
Flushes the underlying servlet output stream. |
boolean |
getClosed()
Returns closed. |
void |
write(byte[] buf)
Over-ridden to ensure that the method just invokes the write( byte[], int, int ) method. |
void |
write(byte[] buf,
int off,
int len)
Over-ridden form of the method. |
void |
write(int value)
Over-ridden form of the method. |
| 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 |
| Field Detail |
|---|
protected boolean closed
protected javax.servlet.http.HttpServletResponse response
protected javax.servlet.ServletOutputStream output
protected java.io.BufferedOutputStream cacheFile
private TeeOutputStream tee
tee that represents the output and
cacheFile.
| Constructor Detail |
|---|
public CachingResponseStream(javax.servlet.http.HttpServletResponse response,
java.io.File file)
throws java.io.IOException
tee.
response - The response to which the contents are to be
sent.file - The file to which the response is to be cached.
java.io.IOException - If errors are encountered while writing
to the streams.| Method Detail |
|---|
public void write(int value)
throws java.io.IOException
output and cacheFile if the stream has not been
closed.
write in class java.io.OutputStreamvalue - - The integer value that is being written.
java.io.IOException - - If the stream has already been closed.
public void write(byte[] buf)
throws java.io.IOException
write( byte[], int, int ) method.
write in class java.io.OutputStreambuf - - The byte buffer from which the data is to
read and written to the output and cacheFile.
java.io.IOException - - If errors are encountered while writing
to the stream.
public void write(byte[] buf,
int off,
int len)
throws java.io.IOException
byte array
to the output and cacheFile.
write in class java.io.OutputStreambuf - - The byte buffer from which the data is to
read and written to the output and cacheFile.off - - The offset from the start of the buffer from
which to start reading data.len - - The length of data that is to be read from the
array.
java.io.IOException - - If errors are encountered while writing
to the stream.
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.OutputStreamjava.io.IOException - - If the stream has already been closed.
public void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOException - - If the stream has already been closed.
public void closeCacheFile()
throws java.io.IOException
cacheFile without closing the output.
Note: This method must be invoked by to ensure that the cache file that was generated is properly closed after the actual response was generated.
java.io.IOException - - If errors are encountered while closing
the file.public final boolean getClosed()
closed.
|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||