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 AbstractSenderConnection extends AbstractWebServiceConnection {
31
32 private TransportOutputStream requestOutputStream;
33
34 private TransportInputStream responseInputStream;
35
36 protected final TransportOutputStream createTransportOutputStream() throws IOException {
37 if (requestOutputStream == null) {
38 requestOutputStream = new RequestTransportOutputStream();
39 }
40 return requestOutputStream;
41 }
42
43 protected final TransportInputStream createTransportInputStream() throws IOException {
44 if (hasResponse()) {
45 if (responseInputStream == null) {
46 responseInputStream = new ResponseTransportInputStream();
47 }
48 return responseInputStream;
49 }
50 else {
51 return null;
52 }
53 }
54
55
56
57
58
59
60 protected void onClose() throws IOException {
61 }
62
63
64 protected abstract boolean hasResponse() throws IOException;
65
66
67
68
69
70
71
72
73 protected abstract void addRequestHeader(String name, String value) throws IOException;
74
75
76 protected abstract OutputStream getRequestOutputStream() throws IOException;
77
78
79
80
81
82 protected abstract Iterator getResponseHeaderNames() throws IOException;
83
84
85
86
87
88 protected abstract Iterator getResponseHeaders(String name) throws IOException;
89
90
91 protected abstract InputStream getResponseInputStream() throws IOException;
92
93
94 class RequestTransportOutputStream extends TransportOutputStream {
95
96 public void addHeader(String name, String value) throws IOException {
97 addRequestHeader(name, value);
98 }
99
100 protected OutputStream createOutputStream() throws IOException {
101 return getRequestOutputStream();
102 }
103 }
104
105
106 class ResponseTransportInputStream extends TransportInputStream {
107
108 protected InputStream createInputStream() throws IOException {
109 return getResponseInputStream();
110 }
111
112 public Iterator getHeaderNames() throws IOException {
113 return getResponseHeaderNames();
114 }
115
116 public Iterator getHeaders(String name) throws IOException {
117 return getResponseHeaders(name);
118 }
119
120 }
121
122 }