9 Replies Latest reply on Nov 19, 2007 1:32 PM by Sheng Huang

    About Events (Observer/Observable pattern)

    Richard Leherpeur Novice

      Hello,

      I have a SFSB that I use to hold states in a pageflow. It resides in the conversation scope. Now I have a SLSB that I use to upload files.
      What I try to achieve is that I want to decouple the uploading process from the the conversational flow (as file uploading should not be tigth to that particular flow).
      So in the SFSB I implemented a methods like this:

      @Observer("newUpload")
      public void onUploadEvent() {
       ...
      }
      


      Then the upload method of the upload SLSB calls:

      events.raiseEvent("newUpload");


      after the upload is done.

      The onUploadEvent() methods of the SFSB is called but it is not the instance of the SFSB in the conversation scope. It seems that another SFSB is instantiated and its method called.

      It is not clear in the doc if the Events framework is only for Stateless bean or not. When an event is raised, does the event manager looks up in the differents scopes to find instances of already created components, or just instantiate a new one?

      If I'm not supposed to use the events with a stateful bean, then what would be the best approach to implement the behaviour I descibed?

      Thanks,

      Richard

        • 1. Re: About Events (Observer/Observable pattern)
          Gavin King Master

          In Seam 1.0.x, all events are processed in the same thread and scopes that raised the event. So if you call raiseEvent("foo") , and you have an existing FooListener in the conversation scope, that will be the instance that processes the foo event.


          However, in Seam 1.1, there are raiseAsynchronousEvent() methods which let you process the event in a new thread and scopes.

          • 2. Re: About Events (Observer/Observable pattern)
            Richard Leherpeur Novice

            I just downloaded the lastest build jboss-seam-CVS.20061011 and the Events class has both:

            public void raiseEvent(String type)
            public void raiseAsynchronousEvent(String type)
            And a bunch of other methods as I can see...

            I was using an earlier build (jboss-seam-CVS.20061004) that has only the raiseEvent method and there are differences between the implementation of the two version.

            I have a exception running the jboss-seam-CVS.20061011 build, so I can't test the event anymore, do you have an idea what is going on?

            java.lang.IllegalArgumentException: no such setter method: org.jboss.seam.core.ResourceBundle.bundleName
             at org.jboss.seam.util.Reflections.getSetterMethod(Reflections.java:178)
             at org.jboss.seam.Component.initInitializers(Component.java:326)
             at org.jboss.seam.Component.<init>(Component.java:239)
             at org.jboss.seam.Component.<init>(Component.java:190)
             at org.jboss.seam.init.Initialization.addComponent(Initialization.java:504)
             at org.jboss.seam.init.Initialization.addComponent(Initialization.java:515)
             at org.jboss.seam.init.Initialization.addComponents(Initialization.java:390)
             at org.jboss.seam.init.Initialization.init(Initialization.java:292)
             at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:32)
             at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
             at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
             at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
             at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
             at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
             at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.apache.catalina.core.StandardContext.init(StandardContext.java:5116)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.apache.commons.modeler.BaseModelMBean.invoke(BaseModelMBean.java:503)
             at org.jboss.mx.server.RawDynamicInvoker.invoke(RawDynamicInvoker.java:164)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeployInternal(TomcatDeployer.java:297)
             at org.jboss.web.tomcat.tc5.TomcatDeployer.performDeploy(TomcatDeployer.java:103)
             at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:371)
             at org.jboss.web.WebModule.startModule(WebModule.java:83)
             at org.jboss.web.WebModule.startService(WebModule.java:61)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
             at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
             at $Proxy0.start(Unknown Source)
             at org.jboss.system.ServiceController.start(ServiceController.java:417)
             at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy43.start(Unknown Source)
             at org.jboss.web.AbstractWebContainer.start(AbstractWebContainer.java:466)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
             at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
             at org.jboss.ws.server.WebServiceDeployer.start(WebServiceDeployer.java:117)
             at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
             at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy44.start(Unknown Source)
             at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007)
             at org.jboss.deployment.MainDeployer.start(MainDeployer.java:997)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
             at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy6.deploy(Unknown Source)
             at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
             at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
             at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
             at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
             at $Proxy0.start(Unknown Source)
             at org.jboss.system.ServiceController.start(ServiceController.java:417)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy4.start(Unknown Source)
             at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
             at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1007)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:808)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:771)
             at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:755)
             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
             at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
             at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
             at java.lang.reflect.Method.invoke(Method.java:585)
             at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
             at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
             at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
             at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
             at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
             at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
             at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
             at $Proxy5.deploy(Unknown Source)
             at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
             at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
             at org.jboss.Main.boot(Main.java:200)
             at org.jboss.Main$1.run(Main.java:464)
             at java.lang.Thread.run(Thread.java:595)
            


            • 3. Re: About Events (Observer/Observable pattern)
              Gavin King Master

               

              I was using an earlier build (jboss-seam-CVS.20061004) that has only the raiseEvent method and there are differences between the implementation of the two version.


              There are??!

              no such setter method: org.jboss.seam.core.ResourceBundle.bundle
              Name


              The property is now called "bundleNames" plural, since we now support cascaded resource bundles.

              Probably I should re-add the singular form for backward compatibility.

              • 4. Re: About Events (Observer/Observable pattern)
                Gavin King Master

                I readded the singular property.

                • 5. Re: About Events (Observer/Observable pattern)
                  Sheng Huang Newbie

                  I downloaded the most recent production 2.0.0.GA and the problem is still there.

                  I checked the ResourceBundle class and there is not setter for bundleNames, the error is as follows:
                  java.lang.IllegalArgumentException: no such setter method: org.jboss.seam.core.ResourceBundle.bundleNames

                  Could you take a look and let me know the work-around?

                  Thanks,
                  Sheng

                  • 6. Re: About Events (Observer/Observable pattern)
                    Pete Muir Master

                    Read the migration guide.

                    • 7. Re: About Events (Observer/Observable pattern)
                      Sheng Huang Newbie

                      Good morning Pete,

                      Could you let me know where I can find the migration guide from 2.0.0.BETA1 to 2.0.0.GA? Thank you very much for your help.

                      Best regards,
                      Sheng

                      • 8. Re: About Events (Observer/Observable pattern)
                        Pete Muir Master

                        In your download as /seam2migation.txt

                        • 9. Re: About Events (Observer/Observable pattern)
                          Sheng Huang Newbie

                          Good afternoon Pete,

                          Thanks a lot for the message. I have replaced <core:resource-bundle/> with <core:resource-loader/>
                          as suggested in the seam2migation.txt document, and it works fine now.

                          Thanks,
                          Sheng