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