Module agentforge4j.bootstrap
Package com.agentforge4j.bootstrap
Class ServiceLoaderToolProviderFactory
java.lang.Object
com.agentforge4j.bootstrap.ServiceLoaderToolProviderFactory
- All Implemented Interfaces:
ToolProviderFactory
ToolProviderFactory that routes each IntegrationDefinition to the
IntegrationToolProviderFactory contribution matching its IntegrationType.
discover(ObjectMapper, SecretResolver, HttpEgressGuard) loads contributions via ServiceLoader (mirroring
DefaultLlmClientResolver's LlmClientFactory discovery), so provider modules such as
agentforge4j-mcp plug in by being on the classpath — this module declares no concrete provider dependency.
Two contributions claiming the same type fail construction; a definition whose type has no contribution fails
create(com.agentforge4j.core.spi.integration.IntegrationDefinition) naming the type and the missing module.
-
Constructor Summary
ConstructorsConstructorDescriptionServiceLoaderToolProviderFactory(Collection<IntegrationToolProviderFactory> contributions, com.fasterxml.jackson.databind.ObjectMapper objectMapper, SecretResolver secretResolver, HttpEgressGuard egressGuard) Creates an aggregator over explicit contributions (typically used in tests). -
Method Summary
Modifier and TypeMethodDescriptioncreate(IntegrationDefinition definition) Builds the tool provider for an integration.discover(com.fasterxml.jackson.databind.ObjectMapper objectMapper, SecretResolver secretResolver, HttpEgressGuard egressGuard) DiscoversIntegrationToolProviderFactorycontributions on the classpath.
-
Constructor Details
-
ServiceLoaderToolProviderFactory
public ServiceLoaderToolProviderFactory(Collection<IntegrationToolProviderFactory> contributions, com.fasterxml.jackson.databind.ObjectMapper objectMapper, SecretResolver secretResolver, HttpEgressGuard egressGuard) Creates an aggregator over explicit contributions (typically used in tests).- Parameters:
contributions- no null elements, at most one contribution perIntegrationTypeobjectMapper- the single shared Jackson mapper threaded into each contribution; must not benullsecretResolver- the secret-reference resolver threaded into each contribution; must not benullegressGuard- the outbound-egress guard threaded into each contribution; must not benull- Throws:
IllegalStateException- if two contributions claim the same type
-
-
Method Details
-
discover
public static ServiceLoaderToolProviderFactory discover(com.fasterxml.jackson.databind.ObjectMapper objectMapper, SecretResolver secretResolver, HttpEgressGuard egressGuard) DiscoversIntegrationToolProviderFactorycontributions on the classpath.An empty result is not an error: the aggregator only fails when asked to realise a definition whose type has no contribution.
- Parameters:
objectMapper- the single shared Jackson mapper threaded into each contribution; must not benullsecretResolver- the secret-reference resolver threaded into each contribution; must not benullegressGuard- the outbound-egress guard threaded into each contribution; must not benull- Returns:
- aggregator over all discovered contributions
-
create
Description copied from interface:ToolProviderFactoryBuilds the tool provider for an integration.- Specified by:
createin interfaceToolProviderFactory- Parameters:
definition- the integration to realise- Returns:
- a tool provider exposing the integration's capabilities
-