Class RDF4JHttpClients

java.lang.Object
org.eclipse.rdf4j.http.client.spi.RDF4JHttpClients

public final class RDF4JHttpClients extends Object
Utility class for obtaining RDF4JHttpClientFactory instances and creating RDF4JHttpClient objects.

Factories are discovered via ServiceLoader. The system property rdf4j.http.client.factory can be used to select a specific factory by name. If multiple factories are found and no preference is set, the "apache5" factory is preferred.

  • Field Details

    • FACTORY_PROPERTY

      public static final String FACTORY_PROPERTY
      System property for selecting a specific HTTP client factory by name.
      See Also:
  • Method Details

    • defaultFactory

      public static RDF4JHttpClientFactory defaultFactory()
      Returns the default RDF4JHttpClientFactory.

      The factory is chosen as follows:

      1. If the system property rdf4j.http.client.factory is set, use the factory with that name.
      2. If a factory named "apache5" is available, prefer it.
      3. Otherwise, use the first factory found.
      Returns:
      the default factory.
      Throws:
      IllegalStateException - if no factory is found on the classpath.
    • factory

      public static RDF4JHttpClientFactory factory(String name)
      Returns the factory with the given name.
      Parameters:
      name - the factory name.
      Returns:
      the matching factory.
      Throws:
      IllegalArgumentException - if no factory with the given name is found.
    • allFactories

      public static List<RDF4JHttpClientFactory> allFactories()
      Returns all available RDF4JHttpClientFactory instances.
      Returns:
      a list of all factories, possibly empty.
    • newDefaultClient

      public static RDF4JHttpClient newDefaultClient()
      Creates a new RDF4JHttpClient using the default factory and default configuration.
      Returns:
      a new client.
    • newDefaultClient

      public static RDF4JHttpClient newDefaultClient(RDF4JHttpClientConfig config)
      Creates a new RDF4JHttpClient using the default factory with the given configuration.
      Parameters:
      config - the client configuration.
      Returns:
      a new client.