Multiple CDI containers per ClassLoader

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple CDI containers per ClassLoader

rinswind
Hi all,

The javax.enterprise.inject.se.SeContainerInitializer seems to allow me to create and use simultaneously multiple CDI containers.
Furthermore I don't seem to be required to setup each one with it's own ClassLoader.
If I create multiple containers over the same ClassLoader, what would it mean to call javax.enterprise.inject.spi.CDI.current() in each one?

Regards,
Todor

_______________________________________________
cdi-dev mailing list
[hidden email]
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.
Reply | Threaded
Open this post in threaded view
|

Re: Multiple CDI containers per ClassLoader

rinswind

On Fri, Sep 8, 2017 at 12:58 PM, Todor Boev <[hidden email]> wrote:
Hi all,

The javax.enterprise.inject.se.SeContainerInitializer seems to allow me to create and use simultaneously multiple CDI containers.
Furthermore I don't seem to be required to setup each one with it's own ClassLoader.
If I create multiple containers over the same ClassLoader, what would it mean to call javax.enterprise.inject.spi.CDI.current() in each one?

Regards,
Todor


_______________________________________________
cdi-dev mailing list
[hidden email]
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.
Reply | Threaded
Open this post in threaded view
|

Re: Multiple CDI containers per ClassLoader

Matej Novotny
Hi

> The javax.enterprise.inject.se .SeContainerInitializer seems to allow me to

It's more like it does not forbid you from doing it.
That means you can try, but it us undefined and up to implementation if they will anyhow handle/support that.

> If I create multiple containers over the same ClassLoader, what would it mean
> to call javax.enterprise.inject.spi.CDI.current() in each one?

What happens when you actually do that is anyone's best guess.
It's again impl specific matter.
In Weld, if we detect more containers, I think we try to determine the caller and if that doesn't help, we give you back the first container reference.
You can browse the code - https://github.com/weld/core/blob/master/environments/se/core/src/main/java/org/jboss/weld/environment/se/WeldSEProvider.java#L59

Matej

----- Original Message -----

> From: "Todor Boev" <[hidden email]>
> To: [hidden email]
> Sent: Friday, September 8, 2017 12:02:43 PM
> Subject: Re: [cdi-dev] Multiple CDI containers per ClassLoader
>
> To clarify:
> http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#provider_se
> Does not forbid such calls.
>
> On Fri, Sep 8, 2017 at 12:58 PM, Todor Boev < [hidden email] > wrote:
>
>
>
> Hi all,
>
> The javax.enterprise.inject.se .SeContainerInitializer seems to allow me to
> create and use simultaneously multiple CDI containers.
> Furthermore I don't seem to be required to setup each one with it's own
> ClassLoader.
> If I create multiple containers over the same ClassLoader, what would it mean
> to call javax.enterprise.inject.spi.CDI.current() in each one?
>
> Regards,
> Todor
>
>
> _______________________________________________
> cdi-dev mailing list
> [hidden email]
> 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.
_______________________________________________
cdi-dev mailing list
[hidden email]
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.
Reply | Threaded
Open this post in threaded view
|

Re: Multiple CDI containers per ClassLoader

Martin Kouba
Also Weld SE bootsrap API allows you to specify a "container id" which
can be used to obtain the correct container instance. See also
org.jboss.weld.environment.se.WeldContainer.instance(String).

Martin

Dne 8.9.2017 v 12:36 Matej Novotny napsal(a):

> Hi
>
>> The javax.enterprise.inject.se .SeContainerInitializer seems to allow me to
>
> It's more like it does not forbid you from doing it.
> That means you can try, but it us undefined and up to implementation if they will anyhow handle/support that.
>
>> If I create multiple containers over the same ClassLoader, what would it mean
>> to call javax.enterprise.inject.spi.CDI.current() in each one?
>
> What happens when you actually do that is anyone's best guess.
> It's again impl specific matter.
> In Weld, if we detect more containers, I think we try to determine the caller and if that doesn't help, we give you back the first container reference.
> You can browse the code - https://github.com/weld/core/blob/master/environments/se/core/src/main/java/org/jboss/weld/environment/se/WeldSEProvider.java#L59
>
> Matej
>
> ----- Original Message -----
>> From: "Todor Boev" <[hidden email]>
>> To: [hidden email]
>> Sent: Friday, September 8, 2017 12:02:43 PM
>> Subject: Re: [cdi-dev] Multiple CDI containers per ClassLoader
>>
>> To clarify:
>> http://docs.jboss.org/cdi/spec/2.0/cdi-spec.html#provider_se
>> Does not forbid such calls.
>>
>> On Fri, Sep 8, 2017 at 12:58 PM, Todor Boev < [hidden email] > wrote:
>>
>>
>>
>> Hi all,
>>
>> The javax.enterprise.inject.se .SeContainerInitializer seems to allow me to
>> create and use simultaneously multiple CDI containers.
>> Furthermore I don't seem to be required to setup each one with it's own
>> ClassLoader.
>> If I create multiple containers over the same ClassLoader, what would it mean
>> to call javax.enterprise.inject.spi.CDI.current() in each one?
>>
>> Regards,
>> Todor
>>
>>
>> _______________________________________________
>> cdi-dev mailing list
>> [hidden email]
>> 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.
> _______________________________________________
> cdi-dev mailing list
> [hidden email]
> 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
Senior Software Engineer
Red Hat, Czech Republic
_______________________________________________
cdi-dev mailing list
[hidden email]
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.