ResponseT
- Pojo response type.public final class ByteArrayAsyncResponseTransformer<ResponseT> extends Object implements AsyncResponseTransformer<ResponseT,ResponseBytes<ResponseT>>
AsyncResponseTransformer
that dumps content into a byte array and supports further
conversions into types, like strings.
This can be created with static methods on AsyncResponseTransformer
.AsyncResponseTransformer.toBytes()
Constructor and Description |
---|
ByteArrayAsyncResponseTransformer() |
Modifier and Type | Method and Description |
---|---|
ResponseBytes<ResponseT> |
complete()
Called when all data has been successfully published to the
Subscriber . |
void |
exceptionOccurred(Throwable throwable)
Called when an exception occurs while establishing the connection or streaming the response.
|
void |
onStream(org.reactivestreams.Publisher<ByteBuffer> publisher)
Called when the HTTP client is ready to start sending data to the response handler.
|
void |
responseReceived(ResponseT response)
Called when the initial response (headers/status code) has been received and the POJO response has
been unmarshalled.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toBytes, toFile, toFile
public void responseReceived(ResponseT response)
AsyncResponseTransformer
AsyncResponseTransformer.onStream(Publisher)
.
In the event of a retryable error, this callback may be called multiple times. It also may never be invoked if the request never succeeds.
responseReceived
in interface AsyncResponseTransformer<ResponseT,ResponseBytes<ResponseT>>
response
- Unmarshalled POJO containing metadata about the streamed data.public void onStream(org.reactivestreams.Publisher<ByteBuffer> publisher)
AsyncResponseTransformer
Publisher
and request data via a Subscription
as
they can handle it.
If at any time the subscriber wishes to stop receiving data, it may call Subscription.cancel()
. This
will be treated as a failure of the response and the AsyncResponseTransformer.exceptionOccurred(Throwable)
callback will be invoked.
This callback may never be called if the response has no content or if an error occurs.
In the event of a retryable error, this callback may be called multiple times with different Publishers. If this method is called more than once, implementation must either reset any state to prepare for another stream of data or must throw an exception indicating they cannot reset. If any exception is thrown then no automatic retry is performed.
onStream
in interface AsyncResponseTransformer<ResponseT,ResponseBytes<ResponseT>>
public void exceptionOccurred(Throwable throwable)
AsyncResponseTransformer
exceptionOccurred
in interface AsyncResponseTransformer<ResponseT,ResponseBytes<ResponseT>>
throwable
- Exception that occurred.public ResponseBytes<ResponseT> complete()
AsyncResponseTransformer
Subscriber
. This will
only be called once during the lifecycle of the request. Implementors should free up any resources they have
opened and do final transformations to produce the return object.complete
in interface AsyncResponseTransformer<ResponseT,ResponseBytes<ResponseT>>
Copyright © 2017 Amazon Web Services, Inc. All Rights Reserved.