[cdi-dev] Easier access to CDI outside of Java EE, easier access to instances

Pete Muir pmuir at redhat.com
Tue Sep 6 18:26:43 EDT 2011

Regarding https://issues.jboss.org/browse/CDI-14, I've created this patch https://github.com/jboss/cdi/pull/43.

This also touches on CDI-26, which is about providing an embedded mode (API for starting CDI) - it covers about 50% of that issue. It doesn't provide a bootstrap API, but it does provide a programmatic API to access the container:


CDI.current().select(MyBean.class).select(new MyQualifierLiteral()).doSomething();

(CDI implements Instance)

I've copied the logic for looking up the current CDI instance from the JPA Persistence class.

Please review, as I know this addresses two much sought after improvement, and I hope that the overall ethos of the approach I've taken you guys like. I suspect there are a couple of rough edges to iron out - specifically, I would like feedback on:

* what happens when multiple CDI providers are located (right now as I straw man I followed JPA's example and returned the first one loaded, not sure if this right)
* Classloading for the providers (Stuart has a comment here)

More information about the cdi-dev mailing list