[cdi-dev] CDI-75 clarifications - was: Scoped CDI Events?
pmuir at redhat.com
Thu Aug 30 11:22:44 EDT 2012
This is a good idea, please put it on the issue :-)
On 30 Aug 2012, at 10:20, Jens Schumann wrote:
> Am 29.08.12 13:10 schrieb "Martin Kouba" unter <mkouba at redhat.com>:
>> This reminds me that the spec should clarify the case when the context of
>> the bean declaring the observer is not active. Currently in RI (Weld) you
>> get ContextNotActiveException. Which is logical although probably not the
>> best from the user point of view.
>> I will file an issue. Thanks for the tip! :-)
> Maybe it should be handled in https://issues.jboss.org/browse/CDI-75 too.
> 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
> - There might be a need for IF_ACTIVE_AND_EXISTS;).
> This might break backwards compatibility though.
>  We do that manually but would love to see @Startup/@PostConstruct
> support with active application and request scopes.
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
More information about the cdi-dev