[cdi-dev] @Destroyed(ApplicationScoped.class)

Romain Manni-Bucau rmannibucau at gmail.com
Tue Apr 28 16:14:23 EDT 2015


Tcks check this event is "accessible" which is important otherwise it is
just useless

What is not well defined is integration with other parts of ee.
 Le 28 avr. 2015 21:00, "John D. Ament" <john.d.ament at gmail.com> a écrit :

> Your understanding matches my understanding, and matches what I typically
> tell people to do (use @PreDestroy).
>
> I think this is more of a use case for lower scopes, or for a dependent
> bean (which I would imagine would receive this event, though I can't say
> I've tried).
>
> John
>
> On Tue, Apr 28, 2015 at 2:56 PM Mark Struberg <struberg at yahoo.de> wrote:
>
>> Hi!
>>
>> The CDI-1.2 spec says in 6.7.3:
>>
>> „An event with qualifier @Initialized(ApplicationScoped.class) is fired
>> when the application context is initialized and an event with qualifier
>> @Destroyed(ApplicationScoped.class) is fired when the application is
>> destroyed. "
>>
>> Now from the pure wording („IS initialized“, „IS destroyed“) I’d say that
>> both events must be fired _after_ the state is reached. Means _after_ the
>> context got initialized and _after_ the context got destroyed.
>>
>> Means an observer like
>>
>> @ApplicationScoped
>> public class MyBean {
>>   public void endIt(@Observes @Destroyed(ApplicationScoped.class)
>> endObject) {
>>     doSomething()
>>   }
>> }
>>
>> will _never_ get invoked.
>> Because the bean (and the whole context) will be already killed…
>>
>> You can observe this event in a @Singleton scoped bean, but not in an
>> @ApplicationScoped bean.
>> If you like to do _that_, then simply use a @PreDestroy.
>>
>> Do others share this interpretation? Do we need to clarify anything?
>>
>> LieGrue,
>> strub
>> _______________________________________________
>> cdi-dev mailing list
>> cdi-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/cdi-dev
>>
>> Note that for all code provided on this list, the provider licenses the
>> code under the Apache License, Version 2 (
>> http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
>> provided on this list, the provider waives all patent and other
>> intellectual property rights inherent in such information.
>
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/cdi-dev
>
> Note that for all code provided on this list, the provider licenses the
> code under the Apache License, Version 2 (
> http://www.apache.org/licenses/LICENSE-2.0.html). For all other ideas
> provided on this list, the provider waives all patent and other
> intellectual property rights inherent in such information.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20150428/5b4a7ead/attachment.html 


More information about the cdi-dev mailing list