Interface HttpClientFactory


@NonNullByDefault public interface HttpClientFactory
Factory class to create Jetty http clients
Author:
Michael Bock - Initial contribution, Martin van Wingerden - add createHttpClient without endpoint, Andrew Fiddian-Green - Added support for HTTP2 client creation
  • Method Summary

    Modifier and Type
    Method
    Description
    org.eclipse.jetty.http2.client.HTTP2Client
    createHttp2Client(String consumerName)
    Creates a new Jetty HTTP/2 client.
    org.eclipse.jetty.http2.client.HTTP2Client
    createHttp2Client(String consumerName, @Nullable org.eclipse.jetty.util.ssl.SslContextFactory sslContextFactory)
    Creates a new Jetty HTTP/2 client.
    org.eclipse.jetty.client.HttpClient
    createHttpClient(String consumerName)
    Creates a new Jetty http client.
    org.eclipse.jetty.client.HttpClient
    createHttpClient(String consumerName, @Nullable org.eclipse.jetty.util.ssl.SslContextFactory sslContextFactory)
    Creates a new Jetty http client.
    org.eclipse.jetty.client.HttpClient
    Returns the shared Jetty http client.
  • Method Details

    • createHttpClient

      org.eclipse.jetty.client.HttpClient createHttpClient(String consumerName)
      Creates a new Jetty http client. The returned client is not started yet. You have to start it yourself before using. Don't forget to stop a started client again after its usage. The client lifecycle should be the same as for your service. DO NOT CREATE NEW CLIENTS FOR EACH REQUEST!
      Parameters:
      consumerName - the for identifying the consumer in the Jetty thread pool. Must be between 4 and 20 characters long and must contain only the following characters [a-zA-Z0-9-_]
      Returns:
      the Jetty client
      Throws:
      IllegalArgumentException - if consumerName is invalid
    • createHttpClient

      org.eclipse.jetty.client.HttpClient createHttpClient(String consumerName, @Nullable org.eclipse.jetty.util.ssl.SslContextFactory sslContextFactory)
      Creates a new Jetty http client. The returned client is not started yet. You have to start it yourself before using. Don't forget to stop a started client again after its usage. The client lifecycle should be the same as for your service. DO NOT CREATE NEW CLIENTS FOR EACH REQUEST!
      Parameters:
      consumerName - the for identifying the consumer in the Jetty thread pool. Must be between 4 and 20 characters long and must contain only the following characters [a-zA-Z0-9-_]
      sslContextFactory - the SSL factory managing TLS encryption
      Returns:
      the Jetty client
      Throws:
      IllegalArgumentException - if consumerName is invalid
    • getCommonHttpClient

      org.eclipse.jetty.client.HttpClient getCommonHttpClient()
      Returns the shared Jetty http client. You must not call any setter methods or stop() on it. The returned client is already started.
      Returns:
      the shared Jetty http client
    • createHttp2Client

      org.eclipse.jetty.http2.client.HTTP2Client createHttp2Client(String consumerName)
      Creates a new Jetty HTTP/2 client. The returned client is not started yet. You have to start it yourself before using. Don't forget to stop a started client again after its usage. The client lifecycle should be the same as for your service. DO NOT CREATE NEW CLIENTS FOR EACH REQUEST!
      Parameters:
      consumerName - for identifying the consumer in the Jetty thread pool. Must be between 4 and 20 characters long and must contain only the following characters [a-zA-Z0-9-_]
      Returns:
      the Jetty HTTP/2 client
      Throws:
      IllegalArgumentException - if consumerName is invalid
    • createHttp2Client

      org.eclipse.jetty.http2.client.HTTP2Client createHttp2Client(String consumerName, @Nullable org.eclipse.jetty.util.ssl.SslContextFactory sslContextFactory)
      Creates a new Jetty HTTP/2 client. The returned client is not started yet. You have to start it yourself before using. Don't forget to stop a started client again after its usage. The client lifecycle should be the same as for your service. DO NOT CREATE NEW CLIENTS FOR EACH REQUEST!
      Parameters:
      consumerName - for identifying the consumer in the Jetty thread pool. Must be between 4 and 20 characters long and must contain only the following characters [a-zA-Z0-9-_]
      sslContextFactory - the SSL factory managing TLS encryption
      Returns:
      the Jetty HTTP/2 client
      Throws:
      IllegalArgumentException - if consumerName is invalid