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 protected final TransportInputStream createTransportInputStream() throws IOException {
37 if (requestInputStream == null) {
38 requestInputStream = new RequestTransportInputStream();
39 }
40 return requestInputStream;
41 }
42
43 protected final TransportOutputStream createTransportOutputStream() throws IOException {
44 if (responseOutputStream == null) {
45 responseOutputStream = new ResponseTransportOutputStream();
46 }
47 return responseOutputStream;
48 }
49
50
51
52
53
54
55 protected void onClose() throws IOException {
56 }
57
58
59
60
61
62 protected abstract Iterator getRequestHeaderNames() throws IOException;
63
64
65
66
67
68 protected abstract Iterator getRequestHeaders(String name) throws IOException;
69
70
71 protected abstract InputStream getRequestInputStream() throws IOException;
72
73
74
75
76
77
78
79
80 protected abstract void addResponseHeader(String name, String value) throws IOException;
81
82
83 protected abstract OutputStream getResponseOutputStream() throws IOException;
84
85
86 private class RequestTransportInputStream extends TransportInputStream {
87
88 protected InputStream createInputStream() throws IOException {
89 return getRequestInputStream();
90 }
91
92 public Iterator getHeaderNames() throws IOException {
93 return getRequestHeaderNames();
94 }
95
96 public Iterator getHeaders(String name) throws IOException {
97 return getRequestHeaders(name);
98 }
99
100 }
101
102
103 private class ResponseTransportOutputStream extends TransportOutputStream {
104
105 public void addHeader(String name, String value) throws IOException {
106 addResponseHeader(name, value);
107 }
108
109 protected OutputStream createOutputStream() throws IOException {
110 return getResponseOutputStream();
111 }
112
113 }
114
115
116 }