1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.portlet.servlet;
23
24 import java.io.IOException;
25 import java.io.OutputStream;
26
27 import javax.servlet.ServletOutputStream;
28
29 /***
30 * Wrapper object exposing a {@link OutputStream} from a portlet as a {@link ServletOutputStream} instance.
31 * Clients accessing this stream object will in fact operate on the
32 * {@link OutputStream} object wrapped by this stream object.
33 */
34 public class PortletServletOutputStream extends ServletOutputStream {
35
36 private OutputStream portletOutputStream;
37
38 public PortletServletOutputStream(OutputStream portletOutputStream) {
39 this.portletOutputStream = portletOutputStream;
40 }
41
42
43
44
45 @Override
46 public void write(int ch) throws IOException {
47 portletOutputStream.write(ch);
48 }
49
50
51
52
53 @Override
54 public void close() throws IOException {
55 portletOutputStream.close();
56 }
57
58
59
60
61 @Override
62 public void flush() throws IOException {
63 portletOutputStream.flush();
64 }
65
66
67
68
69 @Override
70 public void write(byte[] b) throws IOException {
71 portletOutputStream.write(b);
72 }
73
74
75
76
77 @Override
78 public void write(byte[] b, int off, int len) throws IOException {
79 portletOutputStream.write(b, off, len);
80 }
81
82 /***
83 * Get the wrapped {@link OutputStream} instance.
84 * @return The wrapped {@link OutputStream} instance.
85 */
86 public OutputStream getOutputStream() {
87 return portletOutputStream;
88 }
89 }