[cdi-dev] [JBoss JIRA] (CDI-735) Multiple Java SE Containers
Markus Karg (JIRA)
issues at jboss.org
Mon Sep 3 06:40:00 EDT 2018
Markus Karg created CDI-735:
Summary: Multiple Java SE Containers
Project: CDI Specification Issues
Issue Type: Clarification
Components: Java SE Integration
Affects Versions: 2.0 .Final
Reporter: Markus Karg
CDI 13.1 says: "_An implementation does not need to support multiple calls of SeContainerInitializer.initialize() method when the SeContainer is running._"
If a Java SE application wants to create distinct Containers containing beans from the same JAR library, this effectively means, it MUST create multiple initializers, but the initializers MAY share the same default ClassLoader, OR does that means that each initializer MUST be given a separate ClassLoader, OR does that mean that it is IMPOSSIBLE to create multiple SeContainers at the same time?
The answer to this question is crucial to the further adoption of CDI on Java SE, as applications need to product multiple containers, but do neither want to rely on proprietary features of particular implementations (like Weld) nor could add qualifiers to the source code in case of assembling multiple binary (closed-source) libraries into one single Java SE application. Example: Java SE boots JAX-RS (not Servlet, not EE server) with two distinct applications on different ports. Application A uses Version 1 of a Library, Application B uses Version 2. Version 1 and Version 2 are incompatible. Hence injection into A MUST NOT be Version 2, and injection into B MUST NOT be Version 1. The common bootstrap code which starts up Application A and B in JAX-RS MUST provide distinct containers on the same Java SE VM as Applications A and B are binary JARs (not source code), hence cannot get annotated.
But there is no guarantee in the CDI spec HOW EVERY CDI implementation will handle this case. So effectivey at time of writing such an application CANNOT be written. Hence a clarification is needed.
This message was sent by Atlassian JIRA
More information about the cdi-dev