[cdi-dev] Scoped CDI Events?

Pete Muir pmuir at redhat.com
Wed Aug 29 09:14:50 EDT 2012


Agreed. Do you want to reopen the issue?

On 29 Aug 2012, at 13:46, Martin Kouba wrote:

> Jens: yes, it works. No exception, event is not delivered.
> 
> I also found existing issue:
> https://issues.jboss.org/browse/CDI-75
> 
> So this is partially clarified already ;-)
> 
> Anyway I suggest to clarify the spec part too (not only javadoc). And also mention this in "10.5. Observer notification".
> 
> Pete WDYT?
> 
> Martin
> 
> Dne 29.8.2012 14:21, Pete Muir napsal(a):
>> 
>> On 29 Aug 2012, at 13:18, Jens Schumann wrote:
>> 
>>> Martin: what happens in Weld when the scope is not active and notifyObserver is IF_EXISTS? Still an Exception?
>>> 
>>> I tried to disable the current OWB warnings for non active scopes by declaring IF_EXISTS. Didn't work. Initially it seemed to be logical to me. Right now I am not sure about that.
>> 
>> I'm pretty sure *that* should work. If it doesn't/requires clarification, please file a spec issue. At least, we need a TCK test.
>> 
>>> 
>>> Jens
>>> 
>>> 
>>> On 29.08.2012, at 13:56, "Pete Muir" <pmuir at redhat.com> wrote:
>>> 
>>>> This is an interesting one :-)
>>>> 
>>>> On 29 Aug 2012, at 12:10, Martin Kouba wrote:
>>>> 
>>>>> 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! :-)
>>>>> 
>>>>> M
>>>>> 
>>>>> Dne 29.8.2012 12:43, Martin Kouba napsal(a):
>>>>>> No. It will be delivered to any matching observer method - belongs to an enabled bean, the event object is assignable to the observed event type and the observer method has all the event qualifiers (CDI 1.0). In CDI 1.1 qualifier matching rules will likely change: "The observer method has no event qualifiers or has a subset of the event qualifiers".
>>>>>> 
>>>>>> (see 10.2. Observer resolution)
>>>>>> 
>>>>>> Martin
>>>>>> 
>>>>>> Dne 29.8.2012 12:32, Adam Bien napsal(a):
>>>>>>> HI Martin,
>>>>>>> 
>>>>>>> sure. But will the unmanaged payload be delivered only to observers belonging to the same scope as the sender?
>>>>>>> 
>>>>>>> I didn't found any mention in the spec about that...
>>>>>>> 
>>>>>>> thanks,
>>>>>>> 
>>>>>>> adam
>>>>>>> On 29.08.2012, at 12:14, Martin Kouba <mkouba at redhat.com> wrote:
>>>>>>> 
>>>>>>>> Hi Adam, Arne,
>>>>>>>> 
>>>>>>>> The built-in Event bean is not stateless, it's @Dependent. The event payload - the event object - is really not managed and thus not scoped (and should not be IMHO). I also think the event object should be immutable since the order in which observer methods are called is not defined...
>>>>>>>> 
>>>>>>>> Martin
>>>>>>>> 
>>>>>>>> 
>>>>>>>> Dne 29.8.2012 12:06, Arne Limburg napsal(a):
>>>>>>>>> Hi Adam,
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> Are you talking about the injected Event object or about the payload?
>>>>>>>>> The Event object is stateless so the scope does not matter.
>>>>>>>>> And the payload is not managed at all.
>>>>>>>>> So, I'm afraid, I can't see your issue here?
>>>>>>>>> Could you provide a use case for a scoped event?
>>>>>>>>> 
>>>>>>>>> Cheers,
>>>>>>>>> Arne
>>>>>>>>> 
>>>>>>>>> Am 29.08.12 11:49 schrieb "Adam Bien" unter <abien at adam-bien.com>:
>>>>>>>>> 
>>>>>>>>>> Hi *,
>>>>>>>>>> 
>>>>>>>>>> I didn't found in the CDI 1.0 spec a mention of the scope of CDI events.
>>>>>>>>>> There is also no mention of scopes in the Observer Resolution section.
>>>>>>>>>> 
>>>>>>>>>> Are CDI events scoped?
>>>>>>>>>> 
>>>>>>>>>> Does observer resolution depend on the scope of the injected Event
>>>>>>>>>> instance?
>>>>>>>>>> 
>>>>>>>>>> Should we refine/clarify that in the CDI 1.1 spec?
>>>>>>>>>> 
>>>>>>>>>> I didn't found an explicit mail in the archives either,
>>>>>>>>>> 
>>>>>>>>>> thanks and sorry in case the issue is already resolved,
>>>>>>>>>> 
>>>>>>>>>> adam
>>>>>>>>>> _______________________________________________
>>>>>>>>>> cdi-dev mailing list
>>>>>>>>>> cdi-dev at lists.jboss.org
>>>>>>>>>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>>>>>>>> 
>>>>>>>>> 
>>>>>>>>> _______________________________________________
>>>>>>>>> cdi-dev mailing list
>>>>>>>>> cdi-dev at lists.jboss.org
>>>>>>>>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>>>>>>>> 
>>>>>>>> 
>>>>>>>> --
>>>>>>>> Martin Kouba
>>>>>>>> JBoss Quality Assurance Engineer
>>>>>>>> CDI TCK lead
>>>>>>>> E-mail: mkouba at redhat.com
>>>>>>>> Web: www.cz.redhat.com
>>>>>>>> Red Hat Czech s.r.o., Purkyňova 99/71, 612 45, Brno, Czech Republic
>>>>>>>> _______________________________________________
>>>>>>>> cdi-dev mailing list
>>>>>>>> cdi-dev at lists.jboss.org
>>>>>>>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>>>>>> 
>>>>>>> workshops.adam-bien.com
>>>>>>> blog.adam-bien.com
>>>>>>> about.adam-bien.com
>>>>>>> 
>>>>>>> Author of:
>>>>>>> "Real World Java EE Night Hacks", "Real World Java EE Patterns--Rethinking Best Practices"
>>>>>>> 
>>>>>> _______________________________________________
>>>>>> cdi-dev mailing list
>>>>>> cdi-dev at lists.jboss.org
>>>>>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>>>>> 
>>>>> _______________________________________________
>>>>> cdi-dev mailing list
>>>>> cdi-dev at lists.jboss.org
>>>>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>>> 
>>>> 
>>>> _______________________________________________
>>>> cdi-dev mailing list
>>>> cdi-dev at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>> 




More information about the cdi-dev mailing list