Marius Bogoevici commented on CDI-129:
It might well be that the spec is contradicting. But however we turn this, the fact
remains that there are 2 different scopes needed. 1 Webapplication scope and 1 ear scope.
I think that there's a general agreement on that ;). It just remains to decide which
direction should we head into.
I doubt that the original intention of @ApplicationScoped was for EAR usage! It got added
way later, but the historic evolution of the spec, and the fact that it heavily and easily
integrates with EJBs allows that we just use EJBs for those cases you mentioned. We can
still use EJBs for those things.
Unless we have a clear record that @AppScoped was intended to be used in a way or another,
any discussion about the original intent is purely conjectural. An @ApplicationScoped
singleton and a @Singleton EJB are not even remotely the same thing. I can only read it
clearly from the spec that the intent was to create a scope shared by all the components
of an application. We are discussing now what exactly "application" means, and I
cannot see any reason why would it mean something different than the Java EE
application/module/component breakdown, especially since components outside a "web
application" are called out explicitly.
If we would interpret @ApplicationScoped your way, then it would behave heavily different
depending if the war gets used/tested standalone or as part of an EAR. That sounds just
plain wrong imo.
How different exactly? If you are deploying two WARs as part of the same EAR or
independently you are expected to see differences anyway, starting with the behaviour of
the "java:app" namespace, CDI or not.
Btw, it IS possible to fulfil the the spec. In OWB we handle JMS, and quartzed jobs, etc
as own 'applications' inside the EAR. So they get an own BeanManager and can even
have their own Extensions. See what I mean?
So each EJB is an application by itself, or all EJBs share the same 'application'
context? Because the latter is what the specification requires - see above.
introduce @EnterpriseScoped (or similar)
Project: CDI Specification Issues
Issue Type: Feature Request
Affects Versions: 1.0
Reporter: Mark Struberg
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
There is currently no specified CDI scope for providing a single shared instance for a
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.
For more information on JIRA, see: http://www.atlassian.com/software/jira