XDR XDR - 3 months ago 60
Java Question

How to programmatically inject a Java CDI managed bean into a local variable in a static method

How can I programmatically inject a Java CDI 1.1+ managed bean into a local variable in a static method?

XDR XDR
Answer

To inject an instance of class C:

javax.enterprise.inject.spi.CDI.current().select(C.class).get()

This is available in CDI 1.1+

Comments