ResponseT
- Response POJO type. Returned on complete()
.public final class FileAsyncResponseTransformer<ResponseT> extends Object implements AsyncResponseTransformer<ResponseT,ResponseT>
AsyncResponseTransformer
that writes the data to the specified file.Constructor and Description |
---|
FileAsyncResponseTransformer(Path path) |
Modifier and Type | Method and Description |
---|---|
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(SdkPublisher<ByteBuffer> publisher)
Called when events are ready to be streamed.
|
void |
responseReceived(ResponseT response)
Called when the initial response has been received and the POJO response has
been unmarshalled.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
toBytes, toFile, toFile
public FileAsyncResponseTransformer(Path path)
public void responseReceived(ResponseT response)
AsyncResponseTransformer
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,ResponseT>
response
- Unmarshalled POJO containing metadata about the streamed data.public void onStream(SdkPublisher<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,ResponseT>
public void exceptionOccurred(Throwable throwable)
AsyncResponseTransformer
exceptionOccurred
in interface AsyncResponseTransformer<ResponseT,ResponseT>
throwable
- Exception that occurred.public 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,ResponseT>
Copyright © 2017 Amazon Web Services, Inc. All Rights Reserved.