|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
SplitServletOutputStream.java | - | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2003 by OpenSymphony
|
|
3 |
* All rights reserved.
|
|
4 |
*/
|
|
5 |
package com.opensymphony.oscache.web.filter;
|
|
6 |
|
|
7 |
import java.io.IOException;
|
|
8 |
import java.io.OutputStream;
|
|
9 |
|
|
10 |
import javax.servlet.ServletOutputStream;
|
|
11 |
|
|
12 |
/**
|
|
13 |
* Extends the base <code>ServletOutputStream</code> class so that
|
|
14 |
* the stream can be captured as it gets written. This is achieved
|
|
15 |
* by overriding the <code>write()</code> methods and outputting
|
|
16 |
* the data to two streams - the original stream and a secondary stream
|
|
17 |
* that is designed to capture the written data.
|
|
18 |
*
|
|
19 |
* @version $Revision: 1.1 $
|
|
20 |
* @author <a href="mailto:sergek@lokitech.com">Serge Knystautas</a>
|
|
21 |
*/
|
|
22 |
public class SplitServletOutputStream extends ServletOutputStream { |
|
23 |
OutputStream captureStream = null;
|
|
24 |
OutputStream passThroughStream = null;
|
|
25 |
|
|
26 |
/**
|
|
27 |
* Constructs a split output stream that both captures and passes through
|
|
28 |
* the servlet response.
|
|
29 |
*
|
|
30 |
* @param captureStream The stream that will be used to capture the data.
|
|
31 |
* @param passThroughStream The pass-through <code>ServletOutputStream</code>
|
|
32 |
* that will write the response to the client as originally intended.
|
|
33 |
*/
|
|
34 | 0 |
public SplitServletOutputStream(OutputStream captureStream, OutputStream passThroughStream) {
|
35 | 0 |
this.captureStream = captureStream;
|
36 | 0 |
this.passThroughStream = passThroughStream;
|
37 |
} |
|
38 |
|
|
39 |
/**
|
|
40 |
* Writes the incoming data to both the output streams.
|
|
41 |
*
|
|
42 |
* @param value The int data to write.
|
|
43 |
* @throws IOException
|
|
44 |
*/
|
|
45 | 0 |
public void write(int value) throws IOException { |
46 | 0 |
captureStream.write(value); |
47 | 0 |
passThroughStream.write(value); |
48 |
} |
|
49 |
|
|
50 |
/**
|
|
51 |
* Writes the incoming data to both the output streams.
|
|
52 |
*
|
|
53 |
* @param value The bytes to write to the streams.
|
|
54 |
* @throws IOException
|
|
55 |
*/
|
|
56 | 0 |
public void write(byte[] value) throws IOException { |
57 | 0 |
captureStream.write(value); |
58 | 0 |
passThroughStream.write(value); |
59 |
} |
|
60 |
|
|
61 |
/**
|
|
62 |
* Writes the incoming data to both the output streams.
|
|
63 |
*
|
|
64 |
* @param b The bytes to write out to the streams.
|
|
65 |
* @param off The offset into the byte data where writing should begin.
|
|
66 |
* @param len The number of bytes to write.
|
|
67 |
* @throws IOException
|
|
68 |
*/
|
|
69 | 0 |
public void write(byte[] b, int off, int len) throws IOException { |
70 | 0 |
captureStream.write(b, off, len); |
71 | 0 |
passThroughStream.write(b, off, len); |
72 |
} |
|
73 |
} |
|
74 |
|
|