01: /*
02: * Copyright 2005 Joe Walker
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.directwebremoting.util;
18:
19: import java.io.IOException;
20: import java.io.OutputStream;
21:
22: import javax.servlet.ServletOutputStream;
23:
24: /**
25: * Delegating implementation of ServletOutputStream.
26: */
27: public class DelegatingServletOutputStream extends ServletOutputStream {
28: /**
29: * Create a new DelegatingServletOutputStream.
30: * @param proxy the target OutputStream
31: */
32: public DelegatingServletOutputStream(OutputStream proxy) {
33: this .proxy = proxy;
34: }
35:
36: /**
37: * Accessor for the stream that we are proxying to
38: * @return The stream we proxy to
39: */
40: public OutputStream getTargetStream() {
41: return proxy;
42: }
43:
44: /* (non-Javadoc)
45: * @see java.io.OutputStream#write(int)
46: */
47: @Override
48: public void write(int b) throws IOException {
49: proxy.write(b);
50: }
51:
52: /* (non-Javadoc)
53: * @see java.io.OutputStream#flush()
54: */
55: @Override
56: public void flush() throws IOException {
57: super .flush();
58: proxy.flush();
59: }
60:
61: /* (non-Javadoc)
62: * @see java.io.OutputStream#close()
63: */
64: @Override
65: public void close() throws IOException {
66: super .close();
67: proxy.close();
68: }
69:
70: private final OutputStream proxy;
71: }
|