İngilizce dilinde oku

Aracılığıyla paylaş


SyncDefaultPollingStrategy<T,U> Class

  • 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 kept

U

the type of the final result object to deserialize into, or BinaryData if raw response body should be kept

Implements

public final class SyncDefaultPollingStrategy<T,U>
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<T,U>, SyncLocationPollingStrategy<T,U>, and SyncStatusCheckPollingStrategy<T,U>, 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

Constructor Description
SyncDefaultPollingStrategy(HttpPipeline httpPipeline)

Creates a synchronous chained polling strategy with three known polling strategies, SyncOperationResourcePollingStrategy<T,U>, SyncLocationPollingStrategy<T,U>, and SyncStatusCheckPollingStrategy<T,U>, in this order, with a JSON serializer.

SyncDefaultPollingStrategy(HttpPipeline httpPipeline, JsonSerializer serializer)

Creates a synchronous chained polling strategy with three known polling strategies, SyncOperationResourcePollingStrategy<T,U>, SyncLocationPollingStrategy<T,U>, and SyncStatusCheckPollingStrategy<T,U>, 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<T,U>, SyncLocationPollingStrategy<T,U>, and SyncStatusCheckPollingStrategy<T,U>, 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<T,U>, SyncLocationPollingStrategy<T,U>, and SyncStatusCheckPollingStrategy<T,U>, in this order, with a JSON serializer.

SyncDefaultPollingStrategy(PollingStrategyOptions pollingStrategyOptions)

Creates a chained polling strategy with 3 known polling strategies, SyncOperationResourcePollingStrategy<T,U>, SyncLocationPollingStrategy<T,U>, and SyncStatusCheckPollingStrategy<T,U>, in this order, with a custom serializer.

Method Summary

Modifier and Type Method and Description
T cancel(PollingContext<T> pollingContext, PollResponse<T> initialResponse)

Cancels the long-running operation if service supports cancellation.

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.

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.

PollResponse<T> onInitialResponse(Response<?> response, PollingContext<T> pollingContext, TypeReference<T> pollResponseType)

Parses the initial response into a LongRunningOperationStatus, and stores information useful for polling in the PollingContext<T>.

PollResponse<T> poll(PollingContext<T> pollingContext, TypeReference<T> pollResponseType)

Parses the response from the polling URL into a PollResponse<T>, and stores information useful for further polling and final response in the PollingContext<T>.

Methods inherited from java.lang.Object

Constructor Details

SyncDefaultPollingStrategy

public SyncDefaultPollingStrategy(HttpPipeline httpPipeline)

Creates a synchronous chained polling strategy with three known polling strategies, SyncOperationResourcePollingStrategy<T,U>, SyncLocationPollingStrategy<T,U>, and SyncStatusCheckPollingStrategy<T,U>, in this order, with a JSON serializer.

Parameters:

httpPipeline - an instance of HttpPipeline to send requests with

SyncDefaultPollingStrategy

public SyncDefaultPollingStrategy(HttpPipeline httpPipeline, JsonSerializer serializer)

Creates a synchronous chained polling strategy with three known polling strategies, SyncOperationResourcePollingStrategy<T,U>, SyncLocationPollingStrategy<T,U>, and SyncStatusCheckPollingStrategy<T,U>, in this order, with a JSON serializer.

Parameters:

httpPipeline - an instance of HttpPipeline to send requests with
serializer - a custom serializer for serializing and deserializing polling responses

SyncDefaultPollingStrategy

public SyncDefaultPollingStrategy(HttpPipeline httpPipeline, JsonSerializer serializer, Context context)

Creates a synchronous chained polling strategy with three known polling strategies, SyncOperationResourcePollingStrategy<T,U>, SyncLocationPollingStrategy<T,U>, and SyncStatusCheckPollingStrategy<T,U>, in this order, with a JSON serializer.

Parameters:

httpPipeline - an instance of HttpPipeline to send requests with
serializer - a custom serializer for serializing and deserializing polling responses
context - an instance of Context

SyncDefaultPollingStrategy

public SyncDefaultPollingStrategy(HttpPipeline httpPipeline, String endpoint, JsonSerializer serializer, Context context)

Creates a synchronous chained polling strategy with three known polling strategies, SyncOperationResourcePollingStrategy<T,U>, SyncLocationPollingStrategy<T,U>, and SyncStatusCheckPollingStrategy<T,U>, in this order, with a JSON serializer.

Parameters:

httpPipeline - an instance of HttpPipeline 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 of Context.

SyncDefaultPollingStrategy

public SyncDefaultPollingStrategy(PollingStrategyOptions pollingStrategyOptions)

Creates a chained polling strategy with 3 known polling strategies, SyncOperationResourcePollingStrategy<T,U>, SyncLocationPollingStrategy<T,U>, and SyncStatusCheckPollingStrategy<T,U>, in this order, with a custom serializer.

Parameters:

pollingStrategyOptions - options to configure this polling strategy.

Method Details

cancel

public T cancel(PollingContext pollingContext, PollResponse initialResponse)

Cancels the long-running operation if service supports cancellation. If service does not support cancellation then the implementer should throw an IllegalStateException with an error message indicating absence of cancellation.

Implementing this method is optional - by default, cancellation will not be supported unless overridden.

Parameters:

pollingContext
initialResponse

canPoll

public 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.

Parameters:

initialResponse

getResult

public U getResult(PollingContext pollingContext, TypeReference resultType)

Parses the response from the final GET call into the result type of the long-running operation.

Parameters:

pollingContext
resultType

onInitialResponse

public PollResponse onInitialResponse(Response response, PollingContext pollingContext, TypeReference pollResponseType)

Parses the initial response into a LongRunningOperationStatus, and stores information useful for polling in the PollingContext<T>. If the result is anything other than IN_PROGRESS, the long-running operation will be terminated and none of the other methods will be invoked.

Parameters:

response
pollingContext
pollResponseType

poll

public PollResponse poll(PollingContext pollingContext, TypeReference pollResponseType)

Parses the response from the polling URL into a PollResponse<T>, and stores information useful for further polling and final response in the PollingContext<T>. The result must have the LongRunningOperationStatus specified, and the entire polling response content as a BinaryData.

Parameters:

pollingContext
pollResponseType

Applies to

Azure SDK for Java

Latest