[cdi-dev] Do we already have a kind of CDI SE in 1.1+ ?
Antoine Sabot-Durand
antoine at sabot-durand.net
Sat Dec 20 11:35:03 EST 2014
> Le 19 déc. 2014 à 23:48, Mark Struberg <struberg at yahoo.de> a écrit :
>
> This is nowhere near portable as far as I can see.
That’s probably why it took me 5 minutes to port it successfully to OpenWebBeans 1.5.0 ;)
look at the modified file : https://github.com/antoinesd/openwebbeans/blob/1.5.0-with-se/webbeans-impl/src/main/java/org/apache/webbeans/container/OwbCDIProvider.java
It probably needs something nicer to detect if OWB is running in SE or EE but the idea is here
> And we had container specific hacks since day 1 so to say…
I’m not talking about container. After having added specific part in each implementation, we have the same way to start CDI
I demonstrated that CDI 1.1+ this piece of code could boot CDI in SE if the implementation has what is required
Look at new version of OWB standalone-sample:
https://github.com/antoinesd/openwebbeans/blob/1.5.0-with-se/samples/standalone-sample/src/main/java/org/apache/webbeans/se/sample/Boot.java
No more import of OWB specific classes and yet it runs.
> Or maybe I don't get it? How would that work in OWB?
> Would it even work in older Weld versions (1.2.x)?
Of course not because Weld 1.2 -> CDI 1.0. I’m talking about CDI 1.1 and 1.2 as it is written in this email subject.
Of course there are limitation especially regarding shutdown. But it is portable way of booting CDI at spec level. Could be interesting to addd this trick to our simple and communicate on it to say that portable CDI support for SE is already here.
We’ll provide a better support in CDI 2.0 but in the meantime this can be useful.
Antoine
>
> LieGrue,
> strub
>
>
>
> On Friday, 19 December 2014, 12:45, Antoine Sabot-Durand <antoine at sabot-durand.net> wrote:
>
>
>>
>>
>> Of course Jozef: We need something more controllable in CDI 2.0. But it can be a basic alternative that works right now in CDI 1.2.
>>
>> Antoine Sabot-Durand
>>
>> Le 19 déc. 2014 à 12:24, Jozef Hartinger <jharting at redhat.com> a écrit :
>>
>>
>> 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
>>
>>
>> _______________________________________________
>> cdi-dev mailing list
>> cdi-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>
>> Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.
>>
>>
-------------- 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/20141220/6a7e247e/attachment-0001.bin
More information about the cdi-dev
mailing list