Package jakarta.enterprise.inject.spi
Class CDI<T>
java.lang.Object
jakarta.enterprise.inject.spi.CDI<T>
- Type Parameters:
T- type inherited fromInstance. Always Object for CDI
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static CDIProviderprotected static Set<CDIProvider> private static final Object -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleancurrent()Get the CDI instance that provides access to the current container.private static voidabstract BeanManagerGet the CDI BeanManager for the current contextprivate static CDIProviderObtain theCDIProviderthe user set withsetCDIProvider(CDIProvider)or the last returnedCDIProviderif it returns valid CDI container.static voidsetCDIProvider(CDIProvider provider) Set theCDIProviderto use.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface jakarta.enterprise.inject.Instance
destroy, isAmbiguous, isResolvable, isUnsatisfied, select, select, select, streamMethods inherited from interface java.lang.Iterable
forEach, iterator, spliteratorMethods inherited from interface jakarta.inject.Provider
get
-
Field Details
-
lock
-
discoveredProviders
-
configuredProvider
-
-
Constructor Details
-
CDI
public CDI()
-
-
Method Details
-
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 noCDIProvideris available
-
getCDIProvider
Obtain theCDIProviderthe user set withsetCDIProvider(CDIProvider)or the last returnedCDIProviderif it returns valid CDI container. Otherwise use the serviceloader to retrieve theCDIProviderwith the highest priority.- Returns:
- the
CDIProviderset by user or retrieved by serviceloader
-
checkProvider
-
setCDIProvider
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 theCDIProvideris already set
-
findAllProviders
private static void findAllProviders() -
getBeanManager
Get the CDI BeanManager for the current context- Returns:
- the BeanManager
-