01: /*
02: * Copyright 2002-2006 the original author or authors.
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.InputStream;
21:
22: import javax.servlet.ServletInputStream;
23:
24: /**
25: * Delegating implementation of ServletInputStream.
26: * @author Joe Walker [joe at getahead dot ltd dot uk]
27: */
28: public class DelegatingServletInputStream extends ServletInputStream {
29: /**
30: * Create a new DelegatingServletInputStream.
31: * @param proxy the sourceStream InputStream
32: */
33: public DelegatingServletInputStream(InputStream proxy) {
34: this .proxy = proxy;
35: }
36:
37: /**
38: * Accessor for the stream that we are proxying to
39: * @return The stream we proxy to
40: */
41: public InputStream getTargetStream() {
42: return proxy;
43: }
44:
45: /**
46: * @return The stream that we proxy to
47: */
48: public InputStream getSourceStream() {
49: return proxy;
50: }
51:
52: /* (non-Javadoc)
53: * @see java.io.InputStream#read()
54: */
55: @Override
56: public int read() throws IOException {
57: return proxy.read();
58: }
59:
60: /* (non-Javadoc)
61: * @see java.io.InputStream#close()
62: */
63: @Override
64: public void close() throws IOException {
65: super .close();
66: proxy.close();
67: }
68:
69: private final InputStream proxy;
70: }
|