[cdi-dev] [JBoss JIRA] (CDI-129) Clarify behaviour of @ApplicationScoped in EARs

Mark Struberg (JIRA) jira-events at lists.jboss.org
Mon Oct 22 08:54:01 EDT 2012


    [ https://issues.jboss.org/browse/CDI-129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12728358#comment-12728358 ] 

Mark Struberg commented on CDI-129:
-----------------------------------

that is exactly the problem: BOTH ways are not fully covered in CDI1.0! See CDI-18 where the EG already agreed that BDA and 5.1 is moot and needs to get redefined. Also

{quote}
2.4 Scopes:
Java EE components such as servlets, EJBs and JavaBeans do not have a well-defined scope. ...
singletons, such as EJB singleton beans, whose *state is shared between all clients*,
...
Scoped objects, by contrast, exist in a well-defined lifecycle context:
their state is automatically shared by clients that *execute in the same context*.

{quote}

Actually your interpretation of the spec would exactly fit the aforementioned EJB @Singleton. And in the same paragraph this is explicitly ruled out.

Also please note that your interpretation would have the result that firing a CDI event from an @ApplicationScoped bean in a shared lib would NOT reach any bean defined in any WAR file! There is no way to do that with your interpretation.

Again: all that ONLY happens if you need to deal with scopes > 1 per 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 mailing list