Interface A2AHttpClientProvider
- All Known Implementing Classes:
AndroidA2AHttpClientProvider, CdiA2AHttpClientProvider, JdkA2AHttpClientProvider, VertxA2AHttpClientProvider
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 Summary
Modifier and TypeMethodDescriptioncreate()Creates a new instance of an A2AHttpClient.default A2AHttpClientcreateWithSseConfig(SSEParserConfig sseParserConfig) Creates a new instance of an A2AHttpClient with the givenSSEParserConfig.name()Returns the name of this provider for logging and debugging purposes.default intpriority()Returns the priority of this provider.default booleanReturnstrueif this provider honours theSSEParserConfigpassed tocreateWithSseConfig(SSEParserConfig).
-
Method Details
-
create
A2AHttpClient create()Creates a new instance of an A2AHttpClient.- Returns:
- a new A2AHttpClient instance
-
createWithSseConfig
Creates a new instance of an A2AHttpClient with the givenSSEParserConfig.Providers that support SSE parser configuration should override both this method and
supportsSseConfig()to returntrue. The default implementation ignoressseParserConfigand delegates tocreate().- Parameters:
sseParserConfig- the SSE parser configuration to apply- Returns:
- a new A2AHttpClient instance
-
supportsSseConfig
default boolean supportsSseConfig()Returnstrueif this provider honours theSSEParserConfigpassed tocreateWithSseConfig(SSEParserConfig).Providers that override
createWithSseConfig(SSEParserConfig)to actually apply the configuration must also override this method and returntrue; theA2AHttpClientFactory.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 ofcreateWithSseConfig(SSEParserConfig).- Returns:
trueif this provider applies the givenSSEParserConfig
-
priority
default int priority()Returns the priority of this provider. Higher priority providers are tried first; the first one whosecreate()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-clientis 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
-