1 Reply Latest reply on Jun 26, 2011 7:52 AM by Leo van den berg

    raiseAsynchronousEvent not propagating parameters using Components.xml?

    Daniel Hoult Newbie

      Hello,


      I have an event being raised from a stateless bean:


      Events.instance().raiseAsynchronousEvent('myProcessComplete', processId);
      



      this works fine when I use the @Observer annotation to implement the handler:




      @Name('myProcessObserver')
      @Stateless
      public class MyProcessObserverImpl implements MyProcessObserver{
          @Observer('myProcessComplete')
          public void doSomething(Integer processId){
              // do something here
          }
      }
      



      What I'm needing to do is have some flexibility in what observers get called so I am tring to implement by using the components.xml file:




          <event type='myProcessComplete'>
              <action execute='#{myProcessObserver.doSomething}' />
          </event>
      




      I want to do this so I can easily configure some different handlers in the configuration file instead of having to make code changes:




          <event type='myProcessComplete'>
              <action execute='#{myProcessObserver.doSomething}' />
              <action execute='#{myOtherProcessObserver.doSomething}' />
          </event>
      




      When I run this I get javax.el.MethodNotFoundException for the doSomething method. It is looking for a method signature without any method parameters.
      How can I use this type of configuration and still propagate the event parameters?


      I tried doing this:




          <event type='myProcessComplete'>
              <action execute='#{myProcessObserver.doSomething(processId)}' />
          </event>
      


      and it got around the MethodNotFoundException and actually called the correct method - except the processId was null.


      Any help would be greatly appreciated


      Thanks


      Unfortunately we're still using Seam 2.0.1 - we have plans to update, but I can't go down this road just yet.

        • 1. Re: raiseAsynchronousEvent not propagating parameters using Components.xml?
          Leo van den berg Master

          Hi,


          as far as I know, calling the events yourself is the only way to include additional parameters. Raing an event in components.xml is basically the same as the RaiseEvent annotation: No parameters are allowed. If you think it over a bit, you'll see that processId needs to be resolved somewehere.


          IMHO adding events in components.xml is basically the same as writing your own code: You need to rebuild to add it to your application. What you want is a flexible Event driven application. Look at Drools, it has support for such a model.


          Leo