[
https://issues.jboss.org/browse/CDI-129?page=com.atlassian.jira.plugin.sy...
]
Mark Struberg commented on CDI-129:
-----------------------------------
Do you have the code somewhere? What I observed in JBossAS and Glassfish is that the
WebApp which touches the shared MailService the first time will do all the injection based
on the active beans in this very webapp. Regardless if the resolved Bean<X> is
visible in the other webapps or not. This is not only wrong but might in some cases even
create the obvious NoClassDefFound and similar (great candidate: serialisation time).
Of course one could argue this is an impl bug, but otoh how to implement that correctly?
And now we are back to the 3 listed ways to do it:
1.) injecting only other beans of the shaed-lib and completely ignore anything defined in
the webapps. Jozefs way is technically valid, but a no-go from a user perspective imo as
it would lead to having different contextual instances for the same injection points
across your application.
2.) restricting @Specializes and @Alternatives to only shared libs. This is technically
valid as well but this restriction is certainly not covered by the spec.
3.) make @ApplicationScoped 1 per WAR and thus remove the problem with scopes over
multiple isolation levels. All our classloader slices would always see exactly 1 well
defined scenario. We should nonetheless think about any scope broader than 1 per war in
CDI-1.1, but for CDI-1.0 it would perfectly work (And to repeat again: this is also what
is explicitly stated in the spec 2.4.1).
Clarify behaviour of @ApplicationScoped in EARs
-----------------------------------------------
Key: CDI-129
URL:
https://issues.jboss.org/browse/CDI-129
Project: CDI Specification Issues
Issue Type: Clarification
Components: Contexts
Affects Versions: 1.0
Reporter: Mark Struberg
Assignee: Pete Muir
Fix For: 1.1 (Proposed)
Since @ApplicationScoped currently is defined in 6.5.2 as to be 'like in the Servlet
specification' this means that you will get a new instance for every WebApplication
(WAR file).
There is currently no specified CDI scope for providing a single shared instance for a
whole EAR.
We could (ab-)use @Singleton for that, but this is currently not well defined at all.
Alternatively we could introduce an own new annotation like @EnterpriseScoped or likes.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see:
http://www.atlassian.com/software/jira