[
https://issues.jboss.org/browse/CDI-109?page=com.atlassian.jira.plugin.sy...
]
Mark Struberg commented on CDI-109:
-----------------------------------
11.5. "Container lifecycle events defines" that system events work like normal
@Observes methods. For a normal @Observes method, you can have additional parameters which
get injected by the container:
void clearCaches(@Observes CredentialsChangedEvent cce, BeanManager bm, User usr) {...}
In this example, the bm and usr instances will get injected by the container.
See 10.4.2. "Declaring an observer method":
"In addition to the event parameter, observer methods may declare additional
parameters, which may declare qualifiers. These additional parameters are injection
points."
But for Extensions, the only beans which can get injected are actually the builtin ones
which already initialized. All other custom class beans are just not yet available for
injection at the time the container gets bootstrapped. In fact, I wonder if it even makes
sense to inject the BeanManager...
Invalid beans should not be injectable into extensions
------------------------------------------------------
Key: CDI-109
URL:
https://issues.jboss.org/browse/CDI-109
Project: CDI Specification Issues
Issue Type: Feature Request
Affects Versions: 1.0
Reporter: John Ament
Fix For: 1.1 (Proposed)
Currently, you can inject beans that may not be ready yet into the extension's call
back methods. As an example, I can inject something application scoped like this in to an
extension, but it should really be throwing a definition exception (or similar):
public void handleABD(@Observes AfterBeanDiscovery abd, MyApplicationScopedBean masb) {
}
Pete had noted that really the only safe thing to inject, other than the observed call
back, is the bean manager.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira