Top Description Fields Constructors Methods
javax.enterprise.inject.spi

public abstract Class CDI<T>

extends Object
implements Instance<T>
Class Inheritance
All Implemented Interfaces
javax.enterprise.inject.Instance, javax.inject.Provider, java.lang.Iterable
Type Parameters
<T>
type inherited from Instance. Always Object for CDI
Imports
javax.enterprise.inject.Instance, java.util.Collections, .Comparator, .ServiceConfigurationError, .ServiceLoader, .Set, .TreeSet

Provides access to the current container.

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

Authors
Pete Muir, Antoine Sabot-Durand, John D. Ament
Since
1.1

Field Summary

Modifier and TypeField and Description
protected static volatile CDIProvider
protected static volatile Set<CDIProvider>
private static final Object

Constructor Summary

AccessConstructor and Description
public
CDI()

Method Summary

Modifier and TypeMethod and Description
public static CDI<Object>

Returns:

the CDI instance
current
()

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

private static void
public abstract BeanManager

Returns:

the BeanManager
getBeanManager
()

Get the CDI BeanManager for the current context

private static CDIProvider

Returns:

the CDIProvider set by user or retrieved by serviceloader
getCDIProvider
()

Obtain the CDIProvider the user set with setCDIProvider(CDIProvider), or if it wasn't set, use the serviceloader the retrieve the CDIProvider with the highest priority.

public static void
setCDIProvider(CDIProvider
the provider to use
provider
)

Set the CDIProvider to use.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

configuredProviderback to summary
protected static volatile CDIProvider configuredProvider
discoveredProvidersback to summary
protected static volatile Set<CDIProvider> discoveredProviders
lockback to summary
private static final Object lock

Constructor Detail

CDIback to summary
public CDI()

Method Detail

currentback to summary
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:CDI<Object>

the CDI instance

Exceptions
IllegalStateException:
if no CDIProvider is available
findAllProvidersback to summary
private static void findAllProviders()
getBeanManagerback to summary
public abstract BeanManager getBeanManager()

Get the CDI BeanManager for the current context

Returns:BeanManager

the BeanManager

getCDIProviderback to summary
private static CDIProvider getCDIProvider()

Obtain the CDIProvider the user set with setCDIProvider(CDIProvider), or if it wasn't set, use the serviceloader the retrieve the CDIProvider with the highest priority.

Returns:CDIProvider

the CDIProvider set by user or retrieved by serviceloader

setCDIProviderback to summary
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:CDIProvider

the provider to use

Exceptions
IllegalStateException:
if the CDIProvider is already set