Package org.a2aproject.sdk.server.util
Class CdiUtils
java.lang.Object
org.a2aproject.sdk.server.util.CdiUtils
CDI utility methods shared across server modules.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @Nullable TgetIfResolvable(@Nullable jakarta.enterprise.inject.Instance<T> instance) Resolves a bean from an optional CDIInstance.static <T> @Nullable TresolveDefaultBean(jakarta.enterprise.inject.Instance<T> allBeans, Class<? extends Annotation> excludeQualifier, @Nullable Class<? extends Annotation> requiredQualifier, String beanTypeName) Finds the single default bean of a given type, excluding beans that carry a specific qualifier and optionally requiring another.
-
Method Details
-
getIfResolvable
public static <T> @Nullable T getIfResolvable(@Nullable jakarta.enterprise.inject.Instance<T> instance) Resolves a bean from an optional CDIInstance.- Type Parameters:
T- the bean type- Parameters:
instance- the CDI instance, may benull- Returns:
- the resolved bean, or
nullif the instance is absent or not uniquely resolvable
-
resolveDefaultBean
public static <T> @Nullable T resolveDefaultBean(jakarta.enterprise.inject.Instance<T> allBeans, Class<? extends Annotation> excludeQualifier, @Nullable Class<? extends Annotation> requiredQualifier, String beanTypeName) Finds the single default bean of a given type, excluding beans that carry a specific qualifier and optionally requiring another. Warns on duplicate defaults and validates that the bean scope is@ApplicationScopedor@Singleton.- Type Parameters:
T- the bean type- Parameters:
allBeans- the CDI instance containing all beans of typeTexcludeQualifier- qualifier whose presence causes a bean to be skippedrequiredQualifier- qualifier that the default bean must carry, ornullto accept any non-excluded beanbeanTypeName- human-readable label used in warning messages (e.g."@ExtendedAgentCard")- Returns:
- the resolved default bean, or
nullif none was found
-