Package com.azure.core.util.polling
Class SyncDefaultPollingStrategy<T,U>
java.lang.Object
com.azure.core.util.polling.SyncDefaultPollingStrategy<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:
SyncPollingStrategy<T,
U>
public final class SyncDefaultPollingStrategy<T,U>
extends Object
implements SyncPollingStrategy<T,U>
The default synchronous polling strategy to use with Azure data plane services. The default polling strategy will
attempt three known strategies,
SyncOperationResourcePollingStrategy
, SyncLocationPollingStrategy
,
and SyncStatusCheckPollingStrategy
, in this order. The first strategy that can poll on the initial response
will be used. The created chained polling strategy is capable of handling most of the polling scenarios in Azure.-
Constructor Summary
ConstructorDescriptionSyncDefaultPollingStrategy
(HttpPipeline httpPipeline) Creates a synchronous chained polling strategy with three known polling strategies,SyncOperationResourcePollingStrategy
,SyncLocationPollingStrategy
, andSyncStatusCheckPollingStrategy
, in this order, with a JSON serializer.SyncDefaultPollingStrategy
(HttpPipeline httpPipeline, JsonSerializer serializer) Creates a synchronous chained polling strategy with three known polling strategies,SyncOperationResourcePollingStrategy
,SyncLocationPollingStrategy
, andSyncStatusCheckPollingStrategy
, in this order, with a JSON serializer.SyncDefaultPollingStrategy
(HttpPipeline httpPipeline, JsonSerializer serializer, Context context) Creates a synchronous chained polling strategy with three known polling strategies,SyncOperationResourcePollingStrategy
,SyncLocationPollingStrategy
, andSyncStatusCheckPollingStrategy
, in this order, with a JSON serializer.SyncDefaultPollingStrategy
(HttpPipeline httpPipeline, String endpoint, JsonSerializer serializer, Context context) Creates a synchronous chained polling strategy with three known polling strategies,SyncOperationResourcePollingStrategy
,SyncLocationPollingStrategy
, andSyncStatusCheckPollingStrategy
, in this order, with a JSON serializer. -
Method Summary
Modifier and TypeMethodDescriptioncancel
(PollingContext<T> pollingContext, PollResponse<T> initialResponse) Cancels the long-running operation if service supports cancellation.boolean
Checks if this strategy is able to handle polling for this long-running operation based on the information in the initial response.getResult
(PollingContext<T> pollingContext, TypeReference<U> resultType) Parses the response from the final GET call into the result type of the long-running operation.onInitialResponse
(Response<?> response, PollingContext<T> pollingContext, TypeReference<T> pollResponseType) Parses the initial response into aLongRunningOperationStatus
, and stores information useful for polling in thePollingContext
.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
.
-
Constructor Details
-
SyncDefaultPollingStrategy
Creates a synchronous chained polling strategy with three known polling strategies,SyncOperationResourcePollingStrategy
,SyncLocationPollingStrategy
, andSyncStatusCheckPollingStrategy
, in this order, with a JSON serializer.- Parameters:
httpPipeline
- an instance ofHttpPipeline
to send requests with- Throws:
NullPointerException
- IfhttpPipeline
is null.
-
SyncDefaultPollingStrategy
Creates a synchronous chained polling strategy with three known polling strategies,SyncOperationResourcePollingStrategy
,SyncLocationPollingStrategy
, andSyncStatusCheckPollingStrategy
, in this order, with a JSON serializer.- Parameters:
httpPipeline
- an instance ofHttpPipeline
to send requests withserializer
- a custom serializer for serializing and deserializing polling responses- Throws:
NullPointerException
- IfhttpPipeline
is null.
-
SyncDefaultPollingStrategy
public SyncDefaultPollingStrategy(HttpPipeline httpPipeline, JsonSerializer serializer, Context context) Creates a synchronous chained polling strategy with three known polling strategies,SyncOperationResourcePollingStrategy
,SyncLocationPollingStrategy
, andSyncStatusCheckPollingStrategy
, in this order, with a JSON serializer.- Parameters:
httpPipeline
- an instance ofHttpPipeline
to send requests withserializer
- a custom serializer for serializing and deserializing polling responsescontext
- an instance ofContext
- Throws:
NullPointerException
- IfhttpPipeline
is null.
-
SyncDefaultPollingStrategy
public SyncDefaultPollingStrategy(HttpPipeline httpPipeline, String endpoint, JsonSerializer serializer, Context context) Creates a synchronous chained polling strategy with three known polling strategies,SyncOperationResourcePollingStrategy
,SyncLocationPollingStrategy
, andSyncStatusCheckPollingStrategy
, in this order, with a JSON serializer.- Parameters:
httpPipeline
- an instance ofHttpPipeline
to send requests with.endpoint
- an endpoint for creating an absolute path when the path itself is relative.serializer
- a custom serializer for serializing and deserializing polling responses.context
- an instance ofContext
.- Throws:
NullPointerException
- IfhttpPipeline
is null.
-
-
Method Details
-
getResult
Description copied from interface:SyncPollingStrategy
Parses the response from the final GET call into the result type of the long-running operation.- Specified by:
getResult
in interfaceSyncPollingStrategy<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:
- the final result
-
canPoll
Description copied from interface:SyncPollingStrategy
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 interfaceSyncPollingStrategy<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 PollResponse<T> onInitialResponse(Response<?> response, PollingContext<T> pollingContext, TypeReference<T> pollResponseType) Description copied from interface:SyncPollingStrategy
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 interfaceSyncPollingStrategy<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 parameterSyncPollingStrategy
.- Returns:
- the poll response containing the status and the response content
-
poll
Description copied from interface:SyncPollingStrategy
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 interfaceSyncPollingStrategy<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 parameterSyncPollingStrategy
.- Returns:
- the poll response containing the status and the response content
-
cancel
Description copied from interface:SyncPollingStrategy
Cancels the long-running operation if service supports cancellation. If service does not support cancellation then the implementer should throw anIllegalStateException
with an error message indicating absence of cancellation.Implementing this method is optional - by default, cancellation will not be supported unless overridden.
- Specified by:
cancel
in interfaceSyncPollingStrategy<T,
U> - Parameters:
pollingContext
- thePollingContext
for the current polling operation, or null if the polling has started in aSyncPoller
initialResponse
- the response from the initial operation- Returns:
- the cancellation response content
-