Actually my test was a little bit broken ;-)
So finally we filed a new Weld issue:
...and I will provide some more Interceptors/CDI integration tests (as a part of CDI
TCK).
Martin
Dne 15.10.2012 16:15, Pete Muir napsal(a):
+1, Y.init() should be the only one called, and once only.
On 12 Oct 2012, at 15:19, JJ Snyder wrote:
> Martin,
> I'm using GlassFish and I tested it with Weld 1.1.4.Final and
> 1.1.9.Final and both give the same results.
>
> I'll create some variations of the method hierarchy and see what I get.
>
> Maybe my test app is laid out incorrectly...Can you send me the test app
> that you used where it works and I'll run it in my env?
>
> JJ
>
> On 10/12/2012 10:05 AM, Martin Kouba wrote:
>> Hi JJ,
>>
>> I believe Y.init() should be invoked and only once. It works for me on
>> AS7 and Weld 1.1.5. What container do you use?
>>
>> See also Interceptors 1.1 spec, chapter "Multiple Callback Interceptor
>> Methods for a Life Cycle Callback Event":
>> "If a lifecycle callback interceptor method is overridden by another
>> method (regardless of whether that method is itself a lifecycle
>> callback interceptor method (of the same or different type)), it will
>> not be invoked."
>>
>> By the way if X.init() wasn't overriden, it would be invoked first
>> (see the same chapter in spec).
>>
>> Martin
>>
>> Dne 11.10.2012 22:53, JJ Snyder napsal(a):
>>> I'm investigating an issue dealing with @PostConstruct...
>>> Suppose I have the following 2 classes:
>>>
>>> public class X {
>>> @PostConstruct
>>> public void init() {
>>> }
>>> }
>>>
>>> public class Y extends X {
>>> @PostConstruct
>>> public void init() {
>>> }
>>> }
>>>
>>> and then in some other class I inject Y:
>>> public class Other {
>>> @Inject Y y;
>>>
>>> public void foo() {
>>> y.doSomething();
>>> }
>>>
>>> According to the specs it's legal to have @PostConstruct defined on both
>>> X and Y. Also because Y defines init() it does not inherit X's init()
>>> method (section 4.2). So when an instance of Y is created which init()
>>> methods should be called for the @PostConstruct? What I am observing is
>>> that Y's init() method is called twice. Is this correct? I can't
find
>>> any examples or any documentation that talks about this specific case.
>>>
>>> thanks,
>>> JJ
>>> _______________________________________________
>>> cdi-dev mailing list
>>> cdi-dev(a)lists.jboss.org
>>>
https://lists.jboss.org/mailman/listinfo/cdi-dev
>>>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/cdi-dev