Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-2786

Reception.ALWAYS of an observer method can't be changed within a ProcessObserverMethod event

XMLWordPrintable

      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.

            manovotn Matěj Novotný
            patrick1024 Patrick Speer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: