<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style></head>
<body>
<style>
<!--
.EmailQuote
        {margin-left:1pt;
        padding-left:4pt;
        border-left:#800000 2px solid}
-->
</style><body>Hi,<br>for @Inject there is an order specified in JSR 330. Imho we should specify that same order for @Postconstruct if we have specification for it yet.<br><br>Regards,<br>Arne<br><br><div id="htc_header" style="">----- Reply message -----<br>Von: &quot;Stuart Douglas&quot; &lt;stuart.w.douglas@gmail.com&gt;<br>Datum: Fr., Sep. 30, 2011 23:58<br>Betreff: [cdi-dev] @PostConstruct and @Inject methods in superclasses<br>An: &quot;Mark Struberg&quot; &lt;struberg@yahoo.de&gt;<br>Cc: &quot;cdi-dev&quot; &lt;cdi-dev@lists.jboss.org&gt;<br><br></div></body>
<font size="2"><div class="PlainText"><br>
This is actually covered by the interceptors specification, from memory I am pretty sure the base class method is mean't to be called first, but the spec gives you the full order. <br>
<br>
@Inject methods are called before @PostConstuct (the are called in InjectionTarget.inject, which gets called before InjectionTarget.postConstruct).<br>
<br>
I don't think we specify an order for @Inject methods.<br>
<br>
Stuart<br>
<br>
On 01/10/2011, at 5:47 AM, Mark Struberg wrote:<br>
<br>
&gt; Hi!<br>
&gt; <br>
&gt; JSR-250 common annotations is pretty thin about having @PostConstruct in multiple class hierarchies. It just says that there must only be one single method annotated with @PostConstruct in a class. Thus my question:<br>
&gt; <br>
&gt; If I have <br>
&gt; <br>
&gt; <br>
&gt; public class Animal {<br>
&gt;&nbsp; @PostConstruct<br>
&gt; <br>
&gt;&nbsp; public void doInit() {..}<br>
&gt;&nbsp; ..<br>
&gt; <br>
&gt; }<br>
&gt; <br>
&gt; and <br>
&gt; <br>
&gt;&nbsp; public class Horse extends Animal {<br>
&gt;&nbsp; @PostConstruct<br>
&gt; <br>
&gt;&nbsp; public void doSomeOtherInit() {..}<br>
&gt;&nbsp; ..<br>
&gt; <br>
&gt; }<br>
&gt; <br>
&gt; <br>
&gt; 1.) for a contextual instance of Horse, will Animal#doInit() get executed or only the one from the 'effective' class?<br>
&gt; 2.) if 1.) was yes, then In which order do they get executed? Is this specced somewhere?<br>
&gt; <br>
&gt; 3.) Same scenario with @Inject methods. Do we specify an order?<br>
&gt; <br>
&gt; 4.) Both classes have @Inject methods and @PostConstruct. Again: which order of invocaition?<br>
&gt; <br>
&gt; <br>
&gt; Just that you understand my intention: we had a @PostConstruct method in Horse which did set a 'cached' flag in Animal. Turned out that this was a random generator depending on the intsalled server ;)<br>
&gt; <br>
&gt; <br>
&gt; LieGrue,<br>
&gt; strub<br>
&gt; <br>
&gt; _______________________________________________<br>
&gt; cdi-dev mailing list<br>
&gt; cdi-dev@lists.jboss.org<br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/cdi-dev">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br>
<br>
_______________________________________________<br>
cdi-dev mailing list<br>
cdi-dev@lists.jboss.org<br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
</div></font>
</body>
</html>