[cdi-dev] [JBoss JIRA] Commented: (CDI-129) introduce @EnterpriseScoped (or similar)
Jens Schumann (JIRA)
jira-events at lists.jboss.org
Wed May 18 03:58:01 EDT 2011
[ https://issues.jboss.org/browse/CDI-129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12602853#comment-12602853 ]
Jens Schumann commented on CDI-129:
Mark, while it's true that application servers such as JBoss 4 ship with almost no isolation the Java EE 6 spec somewhat clarified what is portable and what is not. See 8.3 - Class Loading Requirements.
Still no word what happens if a class or resource is deployed more than one time within a portable “shared context”. You are right that the servlet spec covers this topic. However it is a recommendation only (parent last delegation). In combination with the “may have access” paragraphs specified in 8.3.1-8.3.3 Java EE 6 spec I believe there is only one safe route to go:
No matter which scope CDI declares for a "global application scope" application developers/assemblers should be aware that section 8.3 “portable class loading requirements” applies. Additionally there is simply no guarantee for a global application wide scope “...if [...] beans from different archives are visible at the same time”, mainly because of the “may have access” paragraphs mentioned above.
Therefore I would follow Marius suggestion and “[...] add a clause indicating that non-portability is an issue here if the beans from different archives are visible at the same time” while providing a packaging recommendation for a portable .ear solution. From my understanding the Java EE 6 spec supports this option.
Having said that I believe that @ApplicationScoped can be used for .war or .ear usage;).
> introduce @EnterpriseScoped (or similar)
> Key: CDI-129
> URL: https://issues.jboss.org/browse/CDI-129
> Project: CDI Specification Issues
> Issue Type: Feature Request
> Components: Contexts
> 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 (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.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the cdi-dev