Working on client-side support.

This commit is contained in:
Arjen Poutsma
2006-11-05 00:14:51 +00:00
parent ca14719b3f
commit 7a252e6c91
6 changed files with 14 additions and 6 deletions

View File

@@ -30,9 +30,18 @@ import java.util.Iterator;
*/
public abstract class TransportInputStream extends InputStream {
private InputStream inputStream;
protected TransportInputStream() {
}
private InputStream getInputStream() throws IOException {
if (inputStream == null) {
inputStream = createInputStream();
}
return inputStream;
}
public void close() throws IOException {
getInputStream().close();
}
@@ -81,7 +90,7 @@ public abstract class TransportInputStream extends InputStream {
/**
* Returns the input stream to read from.
*/
protected abstract InputStream getInputStream() throws IOException;
protected abstract InputStream createInputStream() throws IOException;
/**
* Returns an iteration over all the header names this request contains. Returns an empty <code>Iterator</code> if

View File

@@ -44,7 +44,7 @@ public class HttpServletTransportInputStream extends TransportInputStream {
this.httpServletRequest = httpServletRequest;
}
protected InputStream getInputStream() throws IOException {
protected InputStream createInputStream() throws IOException {
return httpServletRequest.getInputStream();
}

View File

@@ -37,7 +37,7 @@ public class StubTransportInputStream extends TransportInputStream {
this.headers = headers;
}
protected InputStream getInputStream() throws IOException {
protected InputStream createInputStream() throws IOException {
return inputStream;
}

View File

@@ -39,7 +39,6 @@ public class HttpServletTransportInputStreamTest extends TestCase {
}
public void testReadInputStream() throws Exception {
request.setContent(content);
byte[] result = FileCopyUtils.copyToByteArray(tis);
assertTrue("Invalid contents", Arrays.equals(content, result));
}

View File

@@ -67,7 +67,7 @@ public class HttpUrlConnectionTransportInputStream extends TransportInputStream
}
}
protected InputStream getInputStream() throws IOException {
protected InputStream createInputStream() throws IOException {
return connection.getInputStream();
}
}

View File

@@ -40,7 +40,7 @@ public class JmsTransportInputStream extends TransportInputStream {
this.textMessage = textMessage;
}
protected InputStream getInputStream() throws IOException {
protected InputStream createInputStream() throws IOException {
try {
return new ByteArrayInputStream(textMessage.getText().getBytes("UTF-8"));
}