[cdi-dev] [JBoss JIRA] (CDI-75) Clarify what happens to a bean which belongs to inactive when it observes an event

Jens Schumann (JIRA) jira-events at lists.jboss.org
Thu Aug 30 14:17:33 EDT 2012


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

Jens Schumann commented on CDI-75:
----------------------------------

>From my mail to cdi-dev:

Initially I thought it would be a good idea to ignore an observer method
if a scope is not active and notifyObserver is IF_EXISTS. But now I
believe this is partially wrong. Too me there is a difference between

A) the observer bean scope is active without an active bean in scope and
B) the observer bean scope is not active

IF_EXISTS refers to A) only, I believe. Because if IF_EXISTS applies to A)
and B) I am unable to support ALWAYS for active scopes while being ignored
if a scope is not active.

Why would someone need that? Very often we initialize our application
during startup. During startup request and application scope are active. 
Usually a session scoped observer should be ignored during startup.
But at runtime - with an active session scope - I need ALWAYS semantics
for those observers.

So I would vote for:
- ALWAYS observer methods will throw an ContextNotActiveException(?) if
scope is not active.
- IF_EXISTS observer methods will throw an ContextNotActiveException(?) if
scope is not active.
- IF_EXISTS observer methods will be ignored if scope is active but no
active bean is in scope.
- (The newly created) IF_ACTIVE observer method (naming TBD) will be
ignored if scope is inactive. If scope is active it will be treated as
ALWAYS.
- There might be a need for IF_ACTIVE_AND_EXISTS;).

This might break backwards compatibility though.
                
> Clarify what happens to a bean which belongs to inactive when it observes an event
> ----------------------------------------------------------------------------------
>
>                 Key: CDI-75
>                 URL: https://issues.jboss.org/browse/CDI-75
>             Project: CDI Specification Issues
>          Issue Type: Clarification
>          Components: Events
>    Affects Versions: 1.0
>            Reporter: Pete Muir
>            Assignee: Pete Muir
>             Fix For: 1.1.PRD
>
>


--
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