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