<div dir="ltr">Your understanding matches my understanding, and matches what I typically tell people to do (use @PreDestroy).<div><br></div><div>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&#39;t say I&#39;ve tried).</div><div><br></div><div>John<br><br><div class="gmail_quote">On Tue, Apr 28, 2015 at 2:56 PM Mark Struberg &lt;<a href="mailto:struberg@yahoo.de">struberg@yahoo.de</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi!<br>
<br>
The CDI-1.2 spec says in 6.7.3:<br>
<br>
„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. &quot;<br>
<br>
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.<br>
<br>
Means an observer like<br>
<br>
@ApplicationScoped<br>
public class MyBean {<br>
  public void endIt(@Observes @Destroyed(ApplicationScoped.class) endObject) {<br>
    doSomething()<br>
  }<br>
}<br>
<br>
will _never_ get invoked.<br>
Because the bean (and the whole context) will be already killed…<br>
<br>
You can observe this event in a @Singleton scoped bean, but not in an @ApplicationScoped bean.<br>
If you like to do _that_, then simply use a @PreDestroy.<br>
<br>
Do others share this interpretation? Do we need to clarify anything?<br>
<br>
LieGrue,<br>
strub<br>
_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org" target="_blank" onclick="window.open(&#39;https://mail.google.com/mail/?view=cm&amp;tf=1&amp;to=cdi-dev@lists.jboss.org&amp;cc=&amp;bcc=&amp;su=&amp;body=&#39;,&#39;_blank&#39;);return false;">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br>
Note that for all code provided on this list, the provider licenses the code under the Apache License, Version 2 (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">http://www.apache.org/licenses/LICENSE-2.0.html</a>). For all other ideas provided on this list, the provider waives all patent and other intellectual property rights inherent in such information.</blockquote></div></div></div>