[cdi-dev] Multiple CDI containers per ClassLoader

Matej Novotny manovotn at redhat.com
Fri Sep 8 06:36:28 EDT 2017


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" <rinsvind at gmail.com>
> To: cdi-dev at lists.jboss.org
> 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 < rinsvind at gmail.com > 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
> 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.


More information about the cdi-dev mailing list