[cdi-dev] [JBoss JIRA] (CDI-129) Clarify behaviour of @ApplicationScoped in EARs
Stuart Douglas (JIRA)
jira-events at lists.jboss.org
Mon Oct 22 18:42:02 EDT 2012
[ https://issues.jboss.org/browse/CDI-129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12728481#comment-12728481 ]
Stuart Douglas commented on CDI-129:
I think the real problem here is that there are two different use cases, in some cases the developer may view each war in an ear as a completely separate app, in other cases they are considered to be part of a single app.
A potentially simple way to resolve this would be to make this configurable. In beans.xml of a war you could do something like:
This would mean that the war would be treated as an separate CDI deployment, with its own scopes, extensions and beans. Bean discovery would still pick up shared beans and extensions from shared modules, however extensions will have a new instance created specifically for this deployment.
Conceptually this is the same as just bootstrapping CDI twice, once for the isolated sub deployment, and once for 'everything else'. In practice a CDI impl could probably share some of the state internally, to reduce the overhead of two different CDI startups.
As far as I can see this solves all the problems:
1) no dynamic wiring
2) User can choose if application scoped works the Weld way or the OWB way, depending on their use case
3) It is mostly backwards compatible, although OWB users would have to add a single line of xml to each war
> 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
More information about the cdi-dev