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 via @Tenant("x")-qualified beans that carry neither @ExtendedAgentCard nor @PublicAgentCard. The @PublicAgentCard qualifier must NOT be used on tenant-specific public cards because it would cause CDI ambiguity on injection points requesting the default public card.

Falls back to the default (non-@Tenant) card when the tenant is null, blank, or does not match any registered tenant.

  • 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.

      Returns null by default, signaling the handler to fall back to the default (non-tenant-specific) public agent card injected via @PublicAgentCard. Implementations that manage tenant-specific public cards should return a non-null card for known tenants.

      Specified by:
      resolvePublicCard in interface AgentCardRouter
      Parameters:
      tenant - the tenant identifier, may be null
      Returns:
      the tenant-specific public agent card, or null to fall back to the default public card