<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 01/10/2011, at 7:47 PM, Mark Struberg wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Oki found it there:<br><blockquote type="cite">most general superclass first.<br></blockquote>of course the interceptors_spec_1_1 only defines this for 'Lifycycle interceptors' <br></div></blockquote><div><br></div><div>The spec is not very clear on this point, but @PostConstruct methods on a bean are considered lifecycle interceptors. There is actually a fair bit of deviation between CDI and the interceptors and Managed bean spec on some points: </div><div><br></div><div>- CDI beans don't support interceptor methods on the beans themselves (at least Weld does not, the interceptors spec allows you to have an @AroundInvoke method on the managed bean itself).</div><div>- @Resource @Psersitence* @EJB etc annotation of CDI managed beans do not create JNDI bindings like they are supposed to according to the EE platform spec.</div><div><br></div><div>As far as I know no one actually really uses these 'features' anyway, but it is a deviation from the spec that we should probably clarify.</div><div><br></div><div>Stuart</div><div><br></div><br><blockquote type="cite"><div><br>But what about my example 4, the shared @Inject method + @PostConstruct case?<br>Do we need to invoke all superclass injection first? thus do all @Inject fields + @Inject methods + @PostConstruct first, then the one from the Horse class?<br>Could we also specify that all @Inject methods needs to get called before @PostConstruct?<br></div></blockquote><blockquote type="cite"><div><font class="Apple-style-span" color="#000000"><br></font>txs and LieGrue,<br>strub<br><br>--- On Fri, 9/30/11, Stuart Douglas <<a href="mailto:stuart.w.douglas@gmail.com">stuart.w.douglas@gmail.com</a>> wrote:<br><br><blockquote type="cite">From: Stuart Douglas <<a href="mailto:stuart.w.douglas@gmail.com">stuart.w.douglas@gmail.com</a>><br></blockquote><blockquote type="cite">Subject: Re: [cdi-dev] @PostConstruct and @Inject methods in superclasses<br></blockquote><blockquote type="cite">To: "Mark Struberg" <<a href="mailto:struberg@yahoo.de">struberg@yahoo.de</a>><br></blockquote><blockquote type="cite">Cc: "cdi-dev" <<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a>><br></blockquote><blockquote type="cite">Date: Friday, September 30, 2011, 9:58 PM<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">This is actually covered by the interceptors specification,<br></blockquote><blockquote type="cite">from memory I am pretty sure the base class method is mean't<br></blockquote><blockquote type="cite">to be called first, but the spec gives you the full order. <br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">@Inject methods are called before @PostConstuct (the are<br></blockquote><blockquote type="cite">called in InjectionTarget.inject, which gets called before<br></blockquote><blockquote type="cite">InjectionTarget.postConstruct).<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I don't think we specify an order for @Inject methods.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Stuart<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">On 01/10/2011, at 5:47 AM, Mark Struberg wrote:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><blockquote type="cite">Hi!<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">JSR-250 common annotations is pretty thin about having<br></blockquote></blockquote><blockquote type="cite">@PostConstruct in multiple class hierarchies. It just says<br></blockquote><blockquote type="cite">that there must only be one single method annotated with<br></blockquote><blockquote type="cite">@PostConstruct in a class. Thus my question:<br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">If I have <br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">public class Animal {<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> @PostConstruct<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> public void doInit() {..}<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> ..<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">}<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">and <br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> public class Horse extends Animal {<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> @PostConstruct<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> public void doSomeOtherInit() {..}<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"> ..<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">}<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">1.) for a contextual instance of Horse, will<br></blockquote></blockquote><blockquote type="cite">Animal#doInit() get executed or only the one from the<br></blockquote><blockquote type="cite">'effective' class?<br></blockquote><blockquote type="cite"><blockquote type="cite">2.) if 1.) was yes, then In which order do they get<br></blockquote></blockquote><blockquote type="cite">executed? Is this specced somewhere?<br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">3.) Same scenario with @Inject methods. Do we specify<br></blockquote></blockquote><blockquote type="cite">an order?<br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">4.) Both classes have @Inject methods and<br></blockquote></blockquote><blockquote type="cite">@PostConstruct. Again: which order of invocaition?<br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">Just that you understand my intention: we had a<br></blockquote></blockquote><blockquote type="cite">@PostConstruct method in Horse which did set a 'cached' flag<br></blockquote><blockquote type="cite">in Animal. Turned out that this was a random generator<br></blockquote><blockquote type="cite">depending on the intsalled server ;)<br></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">LieGrue,<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">strub<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">_______________________________________________<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">cdi-dev mailing list<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><a href="https://lists.jboss.org/mailman/listinfo/cdi-dev">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br></blockquote></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote></div></blockquote></div><br></body></html>