Package com.azure.core.util.polling
Class LocationPollingStrategy<T,U>
- java.lang.Object
-
- com.azure.core.util.polling.LocationPollingStrategy<T,U>
-
- Type Parameters:
T
- the type of the response type from a polling call, or BinaryData if raw response body should be keptU
- the type of the final result object to deserialize into, or BinaryData if raw response body should be kept
- All Implemented Interfaces:
PollingStrategy<T,U>
public class LocationPollingStrategy<T,U> extends Object implements PollingStrategy<T,U>
Implements a Location polling strategy.
-
-
Constructor Summary
Constructors Constructor Description LocationPollingStrategy(HttpPipeline httpPipeline)
Creates an instance of the location polling strategy using a JSON serializer.LocationPollingStrategy(HttpPipeline httpPipeline, ObjectSerializer serializer)
Creates an instance of the location polling strategy.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Mono<Boolean>
canPoll(Response<?> initialResponse)
Checks if this strategy is able to handle polling for this long running operation based on the information in the initial response.Mono<U>
getResult(PollingContext<T> pollingContext, TypeReference<U> resultType)
Parses the response from the final GET call into the result type of the long running operation.Mono<PollResponse<T>>
onInitialResponse(Response<?> response, PollingContext<T> pollingContext, TypeReference<T> pollResponseType)
Parses the initial response into aLongRunningOperationStatus
, and stores information useful for polling in thePollingContext
.Mono<PollResponse<T>>
poll(PollingContext<T> pollingContext, TypeReference<T> pollResponseType)
Parses the response from the polling URL into aPollResponse
, and stores information useful for further polling and final response in thePollingContext
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.azure.core.util.polling.PollingStrategy
cancel
-
-
-
-
Constructor Detail
-
LocationPollingStrategy
public LocationPollingStrategy(HttpPipeline httpPipeline)
Creates an instance of the location polling strategy using a JSON serializer.- Parameters:
httpPipeline
- an instance ofHttpPipeline
to send requests with
-
LocationPollingStrategy
public LocationPollingStrategy(HttpPipeline httpPipeline, ObjectSerializer serializer)
Creates an instance of the location polling strategy.- Parameters:
httpPipeline
- an instance ofHttpPipeline
to send requests withserializer
- a custom serializer for serializing and deserializing polling responses
-
-
Method Detail
-
canPoll
public Mono<Boolean> canPoll(Response<?> initialResponse)
Description copied from interface:PollingStrategy
Checks if this strategy is able to handle polling for this long running operation based on the information in the initial response.- Specified by:
canPoll
in interfacePollingStrategy<T,U>
- Parameters:
initialResponse
- the response from the initial method call to activate the long running operation- Returns:
- true if this polling strategy can handle the initial response, false if not
-
onInitialResponse
public Mono<PollResponse<T>> onInitialResponse(Response<?> response, PollingContext<T> pollingContext, TypeReference<T> pollResponseType)
Description copied from interface:PollingStrategy
Parses the initial response into aLongRunningOperationStatus
, and stores information useful for polling in thePollingContext
. If the result is anything other thanLongRunningOperationStatus.IN_PROGRESS
, the long running operation will be terminated and none of the other methods will be invoked.- Specified by:
onInitialResponse
in interfacePollingStrategy<T,U>
- Parameters:
response
- the response from the initial method call to activate the long running operationpollingContext
- thePollingContext
for the current polling operationpollResponseType
- theTypeReference
of the response type from a polling call, or BinaryData if raw response body should be kept. This should match the generic parameterPollingStrategy
.- Returns:
- a publisher emitting the poll response containing the status and the response content
-
poll
public Mono<PollResponse<T>> poll(PollingContext<T> pollingContext, TypeReference<T> pollResponseType)
Description copied from interface:PollingStrategy
Parses the response from the polling URL into aPollResponse
, and stores information useful for further polling and final response in thePollingContext
. The result must have theLongRunningOperationStatus
specified, and the entire polling response content as aBinaryData
.- Specified by:
poll
in interfacePollingStrategy<T,U>
- Parameters:
pollingContext
- thePollingContext
for the current polling operationpollResponseType
- theTypeReference
of the response type from a polling call, or BinaryData if raw response body should be kept. This should match the generic parameterPollingStrategy
.- Returns:
- a publisher emitting the poll response containing the status and the response content
-
getResult
public Mono<U> getResult(PollingContext<T> pollingContext, TypeReference<U> resultType)
Description copied from interface:PollingStrategy
Parses the response from the final GET call into the result type of the long running operation.- Specified by:
getResult
in interfacePollingStrategy<T,U>
- Parameters:
pollingContext
- thePollingContext
for the current polling operationresultType
- theTypeReference
of the final result object to deserialize into, or BinaryData if raw response body should be kept.- Returns:
- a publisher emitting the final result
-
-