Interface A2AHttpClientProvider

All Known Implementing Classes:
AndroidA2AHttpClientProvider, CdiA2AHttpClientProvider, JdkA2AHttpClientProvider, VertxA2AHttpClientProvider

public interface A2AHttpClientProvider
Service provider interface for creating A2AHttpClient instances.

Implementations of this interface can be registered via the Java ServiceLoader mechanism. The A2AHttpClientFactory discovers all registered providers, sorts them by descending priority(), and tries each in order, returning the first one whose create() succeeds.

To register a provider, create a file named META-INF/services/org.a2aproject.sdk.client.http.A2AHttpClientProvider containing the fully qualified class name of your provider implementation.

  • Method Details

    • create

      A2AHttpClient create()
      Creates a new instance of an A2AHttpClient.
      Returns:
      a new A2AHttpClient instance
    • createWithSseConfig

      default A2AHttpClient createWithSseConfig(SSEParserConfig sseParserConfig)
      Creates a new instance of an A2AHttpClient with the given SSEParserConfig.

      Providers that support SSE parser configuration should override both this method and supportsSseConfig() to return true. The default implementation ignores sseParserConfig and delegates to create().

      Parameters:
      sseParserConfig - the SSE parser configuration to apply
      Returns:
      a new A2AHttpClient instance
    • supportsSseConfig

      default boolean supportsSseConfig()
      Returns true if this provider honours the SSEParserConfig passed to createWithSseConfig(SSEParserConfig).

      Providers that override createWithSseConfig(SSEParserConfig) to actually apply the configuration must also override this method and return true; the A2AHttpClientFactory.createWithSseConfig(SSEParserConfig) method uses this flag to skip providers that would silently ignore the supplied configuration.

      The default is false, matching the default no-op implementation of createWithSseConfig(SSEParserConfig).

      Returns:
      true if this provider applies the given SSEParserConfig
    • priority

      default int priority()
      Returns the priority of this provider. Higher priority providers are tried first; the first one whose create() succeeds is used.

      Built-in priorities (for reference when choosing a custom value):

      • CdiA2AHttpClient: 200 (CDI-provided bean, when a container and bean are active)
      • AndroidA2AHttpClient: 110 (Android runtime only)
      • VertxA2AHttpClient: 100 (when vertx-web-client is on the classpath)
      • JdkA2AHttpClient: 0 (always available, last resort)
      Returns:
      the priority value (higher is better)
    • name

      String name()
      Returns the name of this provider for logging and debugging purposes.
      Returns:
      the provider name