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

Pete Muir pmuir at redhat.com
Fri Dec 19 06:14:55 EST 2014


I think the main reason we wanted to split it was due to not confusing the use cases of booting CDI and accessing the CDI container.

> On 19 Dec 2014, at 11:03, Antoine Sabot-Durand <antoine at sabot-durand.net> 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 <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/2dab1cab/attachment-0001.html 


More information about the cdi-dev mailing list