Package jakarta.enterprise.inject.spi
Class CDI<T>
- java.lang.Object
- 
- jakarta.enterprise.inject.spi.CDI<T>
 
- 
- Type Parameters:
- T- type inherited from- Instance. Always Object for CDI
 
 public abstract class CDI<T> extends Object implements Instance<T> Provides access to the current container.CDI implements Instanceand therefore might be used to perform programmatic lookup. If no qualifier is passed toInstance.select(java.lang.annotation.Annotation...)method, the@Defaultqualifier is assumed.- Since:
- 1.1
- Author:
- Pete Muir, Antoine Sabot-Durand, John D. Ament
 
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface jakarta.enterprise.inject.InstanceInstance.Handle<T>
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected static CDIProviderconfiguredProviderprotected static Set<CDIProvider>discoveredProviders
 - 
Constructor SummaryConstructors Constructor Description CDI()
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static CDI<Object>current()Get the CDI instance that provides access to the current container.BeanContainergetBeanContainer()Get the CDIBeanContainerfor the current context.abstract BeanManagergetBeanManager()Get the CDI BeanManager for the current contextstatic voidsetCDIProvider(CDIProvider provider)Set theCDIProviderto use.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface jakarta.enterprise.inject.Instancedestroy, getHandle, handles, handlesStream, isAmbiguous, isResolvable, isUnsatisfied, select, select, select, stream
 - 
Methods inherited from interface java.lang.IterableforEach, iterator, spliterator
 
- 
 
- 
- 
- 
Field Detail- 
discoveredProvidersprotected static volatile Set<CDIProvider> discoveredProviders 
 - 
configuredProviderprotected static volatile CDIProvider configuredProvider 
 
- 
 - 
Method Detail- 
currentpublic static CDI<Object> current() Get the CDI instance that provides access to the current container. If there are no providers available, an IllegalStateExceptionis thrown, otherwise the first provider which can access the container is used.- Returns:
- the CDI instance
- Throws:
- IllegalStateException- if no- CDIProvideris available
 
 - 
setCDIProviderpublic static void setCDIProvider(CDIProvider provider) Set the CDIProviderto use.If a CDIProvideris set using this method, any provider specified as a service provider will not be used.- Parameters:
- provider- the provider to use
- Throws:
- IllegalStateException- if the- CDIProvideris already set
 
 - 
getBeanManagerpublic abstract BeanManager getBeanManager() Get the CDI BeanManager for the current context- Returns:
- the BeanManager
 
 - 
getBeanContainerpublic BeanContainer getBeanContainer() Get the CDIBeanContainerfor the current context. Default implementation just forwards the call togetBeanManager().- Returns:
- the BeanContainer
 
 
- 
 
-