Class CDI<T>

java.lang.Object
jakarta.enterprise.inject.spi.CDI<T>
Type Parameters:
T - type inherited from Instance. Always Object for CDI
All Implemented Interfaces:
Instance<T>, Provider<T>, Iterable<T>

public abstract class CDI<T> extends Object implements Instance<T>
Provides access to the current container.

CDI implements Instance and therefore might be used to perform programmatic lookup. If no qualifier is passed to Instance.select(java.lang.annotation.Annotation...) method, the @Default qualifier is assumed.

Since:
1.1
Author:
Pete Muir, Antoine Sabot-Durand, John D. Ament
  • Field Details Link icon

    • discoveredProviders Link icon

      protected static volatile Set<CDIProvider> discoveredProviders
    • configuredProvider Link icon

      protected static volatile CDIProvider configuredProvider
  • Constructor Details Link icon

    • CDI Link icon

      public CDI()
  • Method Details Link icon

    • current Link icon

      public static CDI<Object> current()

      Get the CDI instance that provides access to the current container.

      If there are no providers available, an IllegalStateException is thrown, otherwise the first provider which can access the container is used.

      Returns:
      the CDI instance
      Throws:
      IllegalStateException - if no CDIProvider is available
    • setCDIProvider Link icon

      public static void setCDIProvider(CDIProvider provider)

      Set the CDIProvider to use.

      If a CDIProvider is set using this method, any provider specified as a service provider will not be used.

      Parameters:
      provider - the provider to use
      Throws:
      IllegalArgumentException - if the provided argument is null
    • getBeanManager Link icon

      public abstract BeanManager getBeanManager()
      Get the CDI BeanManager for the current context
      Returns:
      the BeanManager
    • getBeanContainer Link icon

      public BeanContainer getBeanContainer()
      Get the CDI BeanContainer for the current context. Default implementation just forwards the call to getBeanManager().
      Returns:
      the BeanContainer