[cdi-dev] Extensions and spec-related observer method injection points question
Laird Nelson
ljnelson at gmail.com
Thu Feb 16 17:11:41 EST 2017
This section (
http://docs.jboss.org/cdi/spec/2.0-PFD/cdi-spec.html#init_events) says: "If
other beans [other than the BeanManager] are injected into an [portable]
extension’s observer methods, non-portable behavior results."
Rephrased: a portable extension's observer methods must have a minimum of
one parameter (the event being observed) and a maximum of two parameters
(that plus the BeanManager), and none other if you want to stay truly
portable.
For true container lifecycle events, I understand this (you don't have
beans to inject yet). But given that a bean must be provided by the
container for a portable extension (
http://docs.jboss.org/cdi/spec/2.0-PFD/cdi-spec.html#init_events), wouldn't
it be reasonable to permit extra injection points in a portable extension's
*non*-container-lifecycle-event-observing observer methods?
Concretely, I'd like to do this:
// In my portable extension
private static final void doSomethingAtStartup(@Observes
@Initialized(ApplicationScoped.class) final Object event, final Frobnicator
someBean) {
someBean.doSomething();
}
...but that would seem to be in violation of the specification. Could
someone kindly explain why?
Thanks,
Best,
Laird
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/cdi-dev/attachments/20170216/fe966fee/attachment.html
More information about the cdi-dev
mailing list