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
- Author:
- Pete Muir, Antoine Sabot-Durand, John D. Ament
-
Nested Class Summary
Nested classes/interfaces inherited from interface jakarta.enterprise.inject.Instance
Instance.Handle<T>
-
Field Summary
Modifier and TypeFieldDescriptionprotected static CDIProvider
CDIProvider
set by user or retrieved by service loaderprotected static Set<CDIProvider>
The set of discovered CDIProviders -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncurrent()
Get the CDI instance that provides access to the current container.Get the CDIBeanContainer
for the current context.abstract BeanManager
Get the CDI BeanManager for the current contextstatic void
setCDIProvider
(CDIProvider provider) Set theCDIProvider
to use.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface jakarta.enterprise.inject.Instance
destroy, getHandle, handles, handlesStream, isAmbiguous, isResolvable, isUnsatisfied, select, select, select, stream
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Field Details
-
discoveredProviders
The set of discovered CDIProviders -
configuredProvider
CDIProvider
set by user or retrieved by service loader
-
-
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
IllegalStateException
is thrown, otherwise the first provider which can access the container is used.- Returns:
- the CDI instance
- Throws:
IllegalStateException
- if noCDIProvider
is available
-
setCDIProvider
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
Get the CDI BeanManager for the current context- Returns:
- the
BeanManager
-
getBeanContainer
Get the CDIBeanContainer
for the current context. Default implementation just forwards the call togetBeanManager()
.- Returns:
- the
BeanContainer
-