Package com.azure.core.http.policy
Class HttpPolicyProviders
java.lang.Object
com.azure.core.http.policy.HttpPolicyProviders
The
HttpPolicyProviders class is responsible for adding Service Provider Interface (SPI) pluggable policies
to an HTTP pipeline automatically.
This class is useful when you need to add custom policies to the HTTP pipeline that are loaded using Java's
ServiceLoader. It provides methods to add policies before and after the retry policy in the pipeline.
Code sample:
In this example, an empty list of policies is created. Then, the
HttpPolicyProviders.addBeforeRetryPolicies method is used to add policies that should be executed before
the retry policy. The HttpPolicyProviders.addAfterRetryPolicies method is used to add policies that should
be executed after the retry policy. The list of policies can then be used to build an HTTP pipeline.
List<HttpPipelinePolicy> policies = new ArrayList<>(); // Add policies that should be executed before the retry policy HttpPolicyProviders.addBeforeRetryPolicies(policies); // Add the retry policy policies.add(new RetryPolicy()); // Add policies that should be executed after the retry policy HttpPolicyProviders.addAfterRetryPolicies(policies);
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddAfterRetryPolicies(List<HttpPipelinePolicy> policies) Adds SPI policies that implementAfterRetryPolicyProvider.static voidaddBeforeRetryPolicies(List<HttpPipelinePolicy> policies) Adds SPI policies that implementBeforeRetryPolicyProvider.
-
Method Details
-
addBeforeRetryPolicies
Adds SPI policies that implementBeforeRetryPolicyProvider.- Parameters:
policies- Policy list to append the policies.
-
addAfterRetryPolicies
Adds SPI policies that implementAfterRetryPolicyProvider.- Parameters:
policies- Policy list to append the policies.
-