Refactored TransportOutputStream to represent TransportIntputStream more.
This commit is contained in:
@@ -28,9 +28,18 @@ import java.io.OutputStream;
|
||||
*/
|
||||
public abstract class TransportOutputStream extends OutputStream {
|
||||
|
||||
private OutputStream outputStream;
|
||||
|
||||
protected TransportOutputStream() {
|
||||
}
|
||||
|
||||
private OutputStream getOutputStream() throws IOException {
|
||||
if (outputStream == null) {
|
||||
outputStream = createOutputStream();
|
||||
}
|
||||
return outputStream;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
getOutputStream().close();
|
||||
}
|
||||
@@ -63,5 +72,5 @@ public abstract class TransportOutputStream extends OutputStream {
|
||||
/**
|
||||
* Returns the output stream to write to.
|
||||
*/
|
||||
protected abstract OutputStream getOutputStream() throws IOException;
|
||||
protected abstract OutputStream createOutputStream() throws IOException;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class CommonsHttpTransportOutputStream extends TransportOutputStream {
|
||||
postMethod.setRequestEntity(new ByteArrayRequestEntity(bos.toByteArray()));
|
||||
}
|
||||
|
||||
protected OutputStream getOutputStream() throws IOException {
|
||||
protected OutputStream createOutputStream() throws IOException {
|
||||
return bos;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class HttpServletTransportOutputStream extends TransportOutputStream {
|
||||
this.httpServletResponse = httpServletResponse;
|
||||
}
|
||||
|
||||
protected OutputStream getOutputStream() throws IOException {
|
||||
protected OutputStream createOutputStream() throws IOException {
|
||||
return httpServletResponse.getOutputStream();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class HttpUrlConnectionTransportOutputStream extends TransportOutputStrea
|
||||
connection.setRequestProperty(name, value);
|
||||
}
|
||||
|
||||
protected OutputStream getOutputStream() throws IOException {
|
||||
protected OutputStream createOutputStream() throws IOException {
|
||||
return connection.getOutputStream();
|
||||
}
|
||||
|
||||
|
||||
@@ -115,6 +115,7 @@ public abstract class WebServiceMessageReceiverObjectSupport implements Initiali
|
||||
protected void handleResponse(TransportInputStream tis, TransportOutputStream tos, WebServiceMessage response)
|
||||
throws Exception {
|
||||
response.writeTo(tos);
|
||||
tos.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,7 +34,7 @@ public class StubTransportOutputStream extends TransportOutputStream {
|
||||
this.outputStream = outputStream;
|
||||
}
|
||||
|
||||
protected OutputStream getOutputStream() throws IOException {
|
||||
protected OutputStream createOutputStream() throws IOException {
|
||||
return outputStream;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user