Package org.apache.juneau.rest.client
Interface HttpTransportProvider
- All Known Implementing Classes:
ApacheHc45TransportProvider,ApacheHc5TransportProvider,JavaHttpTransportProvider,JettyHttpTransportProvider,OkHttpTransportProvider
public interface HttpTransportProvider
ServiceLoader SPI for auto-discovering HttpTransport implementations on the classpath.
Transport adapter modules (e.g. juneau-rest-client-apache-httpclient-45) register their provider
via META-INF/services/HttpTransportProvider.
When no transport is explicitly set, RestClient uses ServiceLoader to load all
available providers and selects the first one whose isAvailable() returns true.
- Since:
- 9.2.1
-
Method Summary
Modifier and TypeMethodDescriptioncreate()Creates and returns a newHttpTransportinstance using default configuration.default intReturns the priority of this provider.booleanReturnstrueif the required runtime dependencies of this transport are present on the classpath.
-
Method Details
-
getPriority
Returns the priority of this provider.When multiple providers are available, the one with the lowest priority value is used first. This allows applications to install a high-priority mock or test transport that takes precedence over real transports.
- Returns:
- The priority. Defaults to
100.
-
isAvailable
boolean isAvailable()Returnstrueif the required runtime dependencies of this transport are present on the classpath.Providers must check for their dependencies here (e.g. by attempting to load the underlying client class) so that
RestClientcan safely skip providers whose jars are absent.- Returns:
trueif available.
-
create
Creates and returns a newHttpTransportinstance using default configuration.- Returns:
- A new transport. Never
null .
-