Refactored TransportOutputStream to represent TransportIntputStream more.

This commit is contained in:
Arjen Poutsma
2007-02-17 12:50:32 +00:00
parent 4db01de468
commit ce3182bb6a
10 changed files with 76 additions and 35 deletions

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -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();
}
/**

View File

@@ -34,7 +34,7 @@ public class StubTransportOutputStream extends TransportOutputStream {
this.outputStream = outputStream;
}
protected OutputStream getOutputStream() throws IOException {
protected OutputStream createOutputStream() throws IOException {
return outputStream;
}