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 Type
    Method
    Description
    Creates and returns a new HttpTransport instance using default configuration.
    default int
    Returns the priority of this provider.
    boolean
    Returns true if the required runtime dependencies of this transport are present on the classpath.
  • Method Details

    • getPriority

      default int 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()
      Returns true if 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 RestClient can safely skip providers whose jars are absent.

      Returns:
      true if available.
    • create

      Creates and returns a new HttpTransport instance using default configuration.
      Returns:
      A new transport. Never null.