Class ChainedPollingStrategy<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
    All Implemented Interfaces:
    PollingStrategy<T,​U>

    public final class ChainedPollingStrategy<T,​U>
    extends Object
    implements PollingStrategy<T,​U>
    A polling strategy that chains multiple polling strategies, finds the first strategy that can poll the current long running operation, and polls with that strategy.
    • Constructor Detail

      • ChainedPollingStrategy

        public ChainedPollingStrategy​(List<PollingStrategy<T,​U>> strategies)
        Creates a chained polling strategy with a list of polling strategies.
        Parameters:
        strategies - the list of polling strategies
    • 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 interface PollingStrategy<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
      • cancel

        public Mono<T> cancel​(PollingContext<T> pollingContext,
                              PollResponse<T> initialResponse)
        Cancels the long running operation if service supports cancellation. If service does not support cancellation then the implementer should return Mono.error 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 interface PollingStrategy<T,​U>
        Parameters:
        pollingContext - the PollingContext for the current polling operation, or null if the polling has started in a SyncPoller
        initialResponse - the response from the initial operation
        Returns:
        a publisher emitting the cancellation response content
        Throws:
        NullPointerException - if canPoll(Response) is not called prior to this, or if it returns false.