There is no need to refer to the interceptors spec to understand this. But the discussions about the interceptors spec is interesting :-)
But what about my example 4, the shared @Inject method + @PostConstruct case?
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?
Could we also specify that all @Inject methods needs to get called before @PostConstruct?
JSR-330 says that injected fields happen before methods, and always superclass-first i.e.
class X extends Y { ... }
any injected field in Y, followed by any injected method in Y followed by any injected field in X followed by any injected method in X.
CDI then covers the @PostConstruct in 5.5.2 of the CDI spec.
The container must ensure that:
•
Initializer methods declared by a class X in the type hierarchy of the bean are called after all injected fields declared by X or by superclasses of X have been initialized, and after all Java EE component environment resource dependencies declared by X or by superclasses of X have been injected.
•
Any @PostConstruct callback declared by a class X in the type hierarchy of the bean is called after all initializer meth- ods declared by X or by superclasses of X have been called, after all injected fields declared by X or by superclasses of X have been initialized, and after all Java EE component environment resource dependencies declared by X or by su- perclasses of X have been injected.
Thus,
You can be assured that the @PostConstruct for Y happens after injection, and the same for X. However you can't be certain that the @PostConstruct for Y happens before the injection for X.
Do we need to clarify this? I'm not sure we do? If we do, why?