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

Jozef Hartinger jharting at redhat.com
Fri Dec 19 06:24:10 EST 2014


Interesting idea (for CDI 1.2 containers running in SE). As you wrote 
for CDI 2.0 we need much more.

On 12/19/2014 12:03 PM, Antoine Sabot-Durand wrote:
> 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;
>
>     @Override
>     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
>
> org.jboss.weld.environment.se.WeldSEProvider
>
> 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
>
> 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
>
> Antoine

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20141219/865e4038/attachment.html 


More information about the cdi-dev mailing list