public static class ProtocolBase.StreamBufferRequest extends Object implements Request
Message.read(InputStream)
using a (likely) shared data buffer. It is not thread safe and can only
be used by connections that serialized request processing through a single
requesting thread.
Specifically, if an instance of this class is obtained and not immediately used (by calling read) before the user has obtained another instance of the same, data corruption is guaranteed.
Constructor and Description |
---|
StreamBufferRequest(ByteArrayOutputStream buffer) |
Modifier and Type | Method and Description |
---|---|
void |
read(InputStream in)
Reads itself from the provided
InputStream |
void |
reset(ByteArrayOutputStream buffer) |
void |
write(OutputStream out)
Writes the entire content of the message to the output stream and flushes it.
|
public StreamBufferRequest(ByteArrayOutputStream buffer)
buffer
- public void reset(ByteArrayOutputStream buffer)
public void read(InputStream in) throws ClientRuntimeException, ProviderException
Message
InputStream
read
in interface Message
in
- the steam to read from.ClientRuntimeException
- to indicate a system error, potentially network related
and hopefully recoverable. Typically used to wrap and propagate the IO stream's thrown
IOException
s.ProviderException
- to indicate operational error not directly related to the stream,
and should be treated as a bug.public void write(OutputStream out) throws ClientRuntimeException, ProviderException
write
in interface Message
out
- the stream to write the Request message to.ClientRuntimeException
- to indicate a system error, potentially network related
and hopefully recoverable. Typically used to wrap and propagate the IO stream's thrown
IOException
s.ProviderException
- to indicate operational error not directly related to the stream,
and should be treated as a bug.Copyright © 2009–2017. All rights reserved.