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