-
Bug
-
Resolution: Done
-
Major
-
5.1.2.Final
-
None
I have an own Extension and would like to change the Reception of an observer method from ALWAYS to IF_EXISTS. Therefore I have an observer method in my Extension with the following signature:
public void processObserverMethods(@Observes final ProcessObserverMethod<MyEvent, ?> processObserverMethod)
To change the Reception I use ObserverMethodConfigurator obtained by ProcessObserverMethod.configureObserverMethod():
processObserverMethod.configureObserverMethod().reception(Reception.IF_EXISTS);
Unfortunately this doesn't work and beans that don't exist are created and their observer method is executed.
As far as I have analyzed this behaviour, it seems like the reason is the implementation of the method org.jboss.weld.event.ObserverMethodImpl.sendEvent(T):
Using the ObserverMethodConfigurator an instance of org.jboss.weld.bootstrap.events.configurator.ObserverMethodConfiguratorImpl.ImmutableObserverMethod<T> gets created which delegates the call of its notify method to the instance of the original ObserverMethodImpl. The notify method of ObserverMethodImpl calls ObserverMethodImpl.sendEvent. The sendEvent method however uses it's own reception variable (!=ImmutableObserverMethod.reception) to deceide if it's necessay to create the receiver if it does not exist.