[cdi-dev] Do we already have a kind of CDI SE in 1.1+ ?

Antoine Sabot-Durand antoine at sabot-durand.net
Fri Dec 19 06:03:47 EST 2014

Hi guys,

As I said during last meeting I was puzzled by the non use of CDI and CDIProvider to address CDI boot in Java SE.

I just made a small test adding this class to weld-se :

public class WeldSEProvider extends WeldProvider {

    private static boolean firstTime = true;

    public CDI<Object> getCDI() {
        if (firstTime) {
            new Weld().initialize();
            firstTime = false;

        return super.getCDI();


and replaced the content of META-INF/services/javax.enterprise.inject.spi.CDIProvider by my provider


Using this new version of Weld-se in my project Iw as able to boot CDI without implementation classes :

public class Main {

    public static void main(String[] args) throws Exception {
        CDI cdi = CDI.current();
        BeanManager bm = cdi.getBeanManager();



Code is available in my weld fork : https://github.com/antoinesd/weld-core/blob/2.2-SE/environments/se/core/src/main/java/org/jboss/weld/environment/se/WeldSEProvider.java <https://github.com/antoinesd/weld-core/blob/2.2-SE/environments/se/core/src/main/java/org/jboss/weld/environment/se/WeldSEProvider.java>

Similar CDIProvider can be written for OWB as well.

I may have missed something, but I think we can figure out something like that to provide SE support in CDI today, even if it’s not as complete as the one we plan to push in CDI 2.0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20141219/72114d94/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.jboss.org/pipermail/cdi-dev/attachments/20141219/72114d94/attachment.bin 

More information about the cdi-dev mailing list