This requires further clarification.
The spec currently says that:
Service providers may have observer methods, which may observe any event, including any container lifecycle event, and
obtain an injected BeanManager reference. If other beans are injected into service providers, non-portable behavior results.
The first part clearly indicates, that it is the observer method who may obtain the BeanManager. However, the second part
If other beans are injected into service providers
suggests the service providers can receive other types of injection (e.g. field injection), which is not allowed by the specification.
The other issue is with the normal observer methods (those not observing a container lifecycle event). Such observer methods can be defined on extension and we should guarantee that if invoked at runtime, they behave the same as observer methods defined on other beans (i.e. injecting any bean is allowed).
Hopefully, this table illustrates the problem better:
This table describes injection guarantee the container should provide for a given type of observer method defined on an Extension in a particular phase |
container lifecycle event observer method |
normal observer method |
container initialization |
BeanManager, injection of other beans non-portable |
BeanManager, injection of other beans non-portable |
runtime |
N/A |
any bean can be injected |
Closing all resolved issues in CDI 1.x