Class CdiAgentCardRouter

java.lang.Object
org.a2aproject.sdk.extras.multitenancy.CdiAgentCardRouter
All Implemented Interfaces:
AgentCardRouter

@ApplicationScoped public class CdiAgentCardRouter extends Object implements AgentCardRouter
CDI-based AgentCardRouter that resolves tenant-specific AgentCard beans.

Extended cards are resolved via @Tenant("x") @ExtendedAgentCard-qualified beans. Tenant-specific public cards are resolved by matching beans that carry the @Tenant("x") qualifier and either:

  • carry @PublicAgentCard (preferred — these cards are resolved before bare tenant cards, even if they also carry @ExtendedAgentCard), or
  • carry neither @ExtendedAgentCard nor @PublicAgentCard (bare tenant card).
Using @Tenant("x") @PublicAgentCard on a tenant-specific bean is safe because both the router's default-card lookup and the transport handler injection points use CdiUtils.resolveDefault(Instance) to exclude @Tenant-qualified beans when resolving the default card.

Returns the default public card from resolvePublicCard(String) when the tenant is null or blank. Returns null when a non-blank tenant does not match any registered tenant — the caller treats that as a 404.

  • Constructor Details

    • CdiAgentCardRouter

      public CdiAgentCardRouter()
  • Method Details

    • resolveExtendedCard

      public @Nullable AgentCard resolveExtendedCard(@Nullable String tenant)
      Description copied from interface: AgentCardRouter
      Resolves the extended AgentCard for the given tenant.
      Specified by:
      resolveExtendedCard in interface AgentCardRouter
      Parameters:
      tenant - the tenant identifier, may be null
      Returns:
      the resolved extended agent card, or null if none is configured
    • resolvePublicCard

      public @Nullable AgentCard resolvePublicCard(@Nullable String tenant)
      Description copied from interface: AgentCardRouter
      Resolves the public AgentCard for the given tenant.

      Implementations should return the default public card when tenant is null or blank, the tenant-specific card when a match is found, and null when a non-blank tenant has no matching card — the caller treats that as HTTP 404.

      The default implementation returns null (no public-card routing configured).

      Specified by:
      resolvePublicCard in interface AgentCardRouter
      Parameters:
      tenant - the tenant identifier, may be null
      Returns:
      the public agent card, or null if a non-blank tenant is unknown