To correct myself - if the Instance instance is cached, the following snippet will work:
CDI<Object> cdi = CDI.current();
|
// Foo is dependent bean
|
Foo foo = cdi.select(Foo.class).get();
|
cdi.destroy(foo);
|
However, caching of CDI instances is required for the following scenario:
// Foo is dependent bean
|
Foo foo = CDI.current().select(Foo.class).get();
|
CDI.current().destroy(foo);
|
|