Java Reference
In-Depth Information
Accessing the non contexual instance of a bean
This version also added the ability to inject and execute lifecycle callbacks of un-
managed instances of beans. The following code demonstrates how to inject and
execute lifecycle callbacks of non contexual instances of the bean Student :
Unmanaged<Student> unmanagedBean =
UnmanagedInstance<Student> beanInstance
Student foo
// Usage of the injected bean
Accessing the current CDI container
The CDI Specification 1.1 has added the ability to access the current CDI container
programmatically and perform some operations. The following code demonstrates
how to access a CDI container to explicitly destroy a context object:
CDI container = CDI.current();
Destroying CDI bean instances explicitly
the AlterableContext interface, which contains the void destroy ( Contextu-
al<?> contextual ) method. Extensions should implement this interface instead
of the Context interface.
Search WWH ::

Custom Search