1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.transport;
18
19 import java.io.IOException;
20 import java.io.InputStream;
21 import java.io.OutputStream;
22 import java.util.Iterator;
23
24
25
26
27
28
29
30 public abstract class AbstractReceiverConnection extends AbstractWebServiceConnection {
31
32 private TransportInputStream requestInputStream;
33
34 private TransportOutputStream responseOutputStream;
35
36 @Override
37 protected final TransportInputStream createTransportInputStream() throws IOException {
38 if (requestInputStream == null) {
39 requestInputStream = new RequestTransportInputStream();
40 }
41 return requestInputStream;
42 }
43
44 @Override
45 protected final TransportOutputStream createTransportOutputStream() throws IOException {
46 if (responseOutputStream == null) {
47 responseOutputStream = new ResponseTransportOutputStream();
48 }
49 return responseOutputStream;
50 }
51
52
53
54
55
56
57 @Override
58 protected void onClose() throws IOException {
59 }
60
61
62
63
64
65 protected abstract Iterator<String> getRequestHeaderNames() throws IOException;
66
67
68
69
70
71 protected abstract Iterator<String> getRequestHeaders(String name) throws IOException;
72
73
74 protected abstract InputStream getRequestInputStream() throws IOException;
75
76
77
78
79
80
81
82
83 protected abstract void addResponseHeader(String name, String value) throws IOException;
84
85
86 protected abstract OutputStream getResponseOutputStream() throws IOException;
87
88
89 private class RequestTransportInputStream extends TransportInputStream {
90
91 @Override
92 protected InputStream createInputStream() throws IOException {
93 return getRequestInputStream();
94 }
95
96 @Override
97 public Iterator<String> getHeaderNames() throws IOException {
98 return getRequestHeaderNames();
99 }
100
101 @Override
102 public Iterator<String> getHeaders(String name) throws IOException {
103 return getRequestHeaders(name);
104 }
105
106 }
107
108
109 private class ResponseTransportOutputStream extends TransportOutputStream {
110
111 @Override
112 public void addHeader(String name, String value) throws IOException {
113 addResponseHeader(name, value);
114 }
115
116 @Override
117 protected OutputStream createOutputStream() throws IOException {
118 return getResponseOutputStream();
119 }
120
121 }
122
123
124 }