[cdi-dev] AfterBeanDiscovery in the light of CDI-392
Martin Kouba
mkouba at redhat.com
Wed Apr 16 07:08:55 EDT 2014
Hi all,
I see an inconsistency between the resolution of CDI-392 and the current
wording of "11.5.3. AfterBeanDiscovery event".
addBean(): "Fires an event of type ProcessBean containing the given Bean
and then registers the Bean with the container, thereby making it
available for injection into other beans. The given Bean may implement
Interceptor or Decorator."
On the other hand BeanManager.getBeans() javadoc:
"Note that when called during invocation of an AfterBeanDiscovery event
observer, this method will only return beans discovered by the container
before the AfterBeanDiscovery event is fired."
It seems ProcessBean should be fired and the bean should be registred
when addBean() is called BUT in the same time it should not be available
via BeanManager.getBeans() until all AfterBeanDiscovery observers are
processed.
The same applies to observer methods.
Weld 2.2.0.Final delays the ProcessBean/registration until all
AfterBeanDiscovery observers are processed (note that it's not backwards
compatible). I believe this is correct. If so, the AfterBeanDiscovery
event description should be clarified. Otherwise the RI must be changed
(and I'm afraid it wouldn't be that trivial).
--
Martin Kouba
Software Engineer
Red Hat, Czech Republic
More information about the cdi-dev
mailing list