[cdi-dev] It seems we missed a point in CDIProvider enhancement

Mark Struberg struberg at yahoo.de
Thu May 14 04:36:24 EDT 2015


That usecase is imo not really valid. Such a testing framework would need a ClassLoader isolation to work. Just create a child UrlClassLoader with your test project in and be done. Otherwise you would get into a total mess with static fields etc. It simply makes no sense in my opinion and propagates bad practice. 


>  think the fact that there’s no specific use case doesn’t mean we should forbid this.
If it requires the impls to do all kind of mad stuff then we at least should not require it. 



LieGrue,
strub


> Am 14.05.2015 um 09:23 schrieb Martin Kouba <mkouba at redhat.com>:
> 
> Just quoting Jozef from the referenced Weld 3.0.0.Alpha8 announcement:
> 
> "One possible use-case this enables is for a library or framework (e.g. a testing framework) to use an embedded instance of Weld internally for its own needs (dependency injection, events, extensibility). This instance would not interfere with the Weld instance used by the application."
> 
> I think the fact that there's no specific use case doesn't mean we should forbid this.
> 
> Martin
> 
> Dne 14.5.2015 v 09:12 Mark Struberg napsal(a):
>> I still don’t get it what running multiple CDI container on the SAME ClassLoader/Thread should be for?
>> What’s the use case?
>> 
>> LieGrue,
>> strub
>> 
>> 
>>> Am 14.05.2015 um 08:11 schrieb Martin Kouba <mkouba at redhat.com>:
>>> 
>>> Hi Antoine,
>>> 
>>> Weld SE 3.0.0.Alpha8 [1] (which allows to start multiple independent
>>> Weld instances) has a special CDIProvider implementation [2]:
>>> 
>>> * if there's exactly one container running, return this container
>>> * if there are multiple containers running, log an INFO message and
>>> attempt to identify the container by the calling class:
>>> ** if there is only one container aware of the class, return this container
>>> ** otherwise return the first container initialized
>>> 
>>> Martin
>>> 
>>> [1]
>>> http://weld.cdi-spec.org/news/2015/04/21/weld-300Alpha8/
>>> 
>>> [2]
>>> https://github.com/weld/core/blob/master/environments/se/core/src/main/java/org/jboss/weld/environment/se/WeldSEProvider.java
>>> 
>>> 
>>> Dne 13.5.2015 v 19:08 Antoine Sabot-Durand napsal(a):
>>>> Hi all,
>>>> 
>>>> While cleaning Javadoc in CDIProvider, I realized that getCDI() method description is not compatible with the multiple container initialization we allowed in the API.
>>>> 
>>>> While running in Java EE getCDI() retuns the current container which is fine since there’s only one, but what do we expect from it when running in SE?
>>>> 
>>>> I thought of 2 simple solutions for EDR1:
>>>> 
>>>> 1) make getCDI() return the last CDI object initialized by the CDIProvider
>>>> 2) Forbid getCDI() in SE
>>>> 
>>>> Of course there’s always the solution of moving the code outside CDIProvider, but it’s less simple…
>>>> 
>>>> Wdyt,
>>>> 
>>>> 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.
>>>> 
>>> 
>>> --
>>> Martin Kouba
>>> Software Engineer
>>> Red Hat, Czech Republic
>>> _______________________________________________
>>> 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.
>> 
> 
> -- 
> Martin Kouba
> Software Engineer
> Red Hat, Czech Republic




More information about the cdi-dev mailing list