Package javax.enterprise.inject.spi
Class CDI<T>
- java.lang.Object
-
- javax.enterprise.inject.spi.CDI<T>
-
- Type Parameters:
T- type inherited fromInstance. Always Object for CDI
- All Implemented Interfaces:
java.lang.Iterable<T>,Instance<T>,javax.inject.Provider<T>
public abstract class CDI<T> extends java.lang.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 @Default qualifier is assumed.- Since:
- 1.1
-
-
Field Summary
Fields Modifier and Type Field Description protected static CDIProviderconfiguredProviderprotected static java.util.Set<CDIProvider>discoveredProvidersprivate static java.lang.Objectlock
-
Constructor Summary
Constructors Constructor Description CDI()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static CDI<java.lang.Object>current()Get the CDI instance that provides access to the current container.private static voidfindAllProviders()abstract BeanManagergetBeanManager()Get the CDI BeanManager for the current contextprivate static CDIProvidergetCDIProvider()Obtain theCDIProviderthe user set withsetCDIProvider(CDIProvider), or if it wasn't set, use the serviceloader the retrieve theCDIProviderwith the highest priority.static voidsetCDIProvider(CDIProvider provider)Set theCDIProviderto use.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.enterprise.inject.Instance
destroy, isAmbiguous, isResolvable, isUnsatisfied, select, select, select, stream
-
-
-
-
Field Detail
-
lock
private static final java.lang.Object lock
-
discoveredProviders
protected static volatile java.util.Set<CDIProvider> discoveredProviders
-
configuredProvider
protected static volatile CDIProvider configuredProvider
-
-
Method Detail
-
current
public static CDI<java.lang.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:
java.lang.IllegalStateException- if noCDIProvideris available
-
getCDIProvider
private static CDIProvider getCDIProvider()
Obtain theCDIProviderthe user set withsetCDIProvider(CDIProvider), or if it wasn't set, use the serviceloader the retrieve theCDIProviderwith the highest priority.- Returns:
- the
CDIProviderset by user or retrieved by serviceloader
-
setCDIProvider
public 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:
java.lang.IllegalStateException- if theCDIProvideris already set
-
findAllProviders
private static void findAllProviders()
-
getBeanManager
public abstract BeanManager getBeanManager()
Get the CDI BeanManager for the current context- Returns:
- the BeanManager
-
-