6 Replies Latest reply on Apr 19, 2006 2:45 AM by deniss.parhomenko

    Seam Remoting Refactored

    shane.bryzak

      I've checked into CVS a number of changes to the Seam Remoting codebase to make it more consistent with its server-side counterpart. Unfortunately because of these changes it means that if you're using the remoting features of Seam your Javascript code will need some refactoring. Here's a summary:

      1. SeamRemote has been removed, in its place are Seam.Component and Seam.Remoting

      2. To execute a method of a Seam session bean component, use Seam.Component.getInstance("componentName").executeMethod().

      3. To create a new instance of a Seam Entity or JavaBean component use Seam.Component.newInstance("componentName").

      4. To create a new instance of a non-Seam component use Seam.Remoting.createType("fully.qualified.className")

      5. In general, the SeamRemote.doSomething() methods have been replaced with Seam.Remoting.doSomething().

        • 1. Re: Seam Remoting Refactored
          deniss.parhomenko

          is it possible to use @WebRemote with play Java Bean, I try to use it together with Hibenrate (not EJB3)

          @Name("ticketReserveAction")
          @Scope(SESSION)
          @Interceptors(SeamInterceptor.class)
          @LoggedIn
          public class TicketReservAction {
          
          
           @WebRemote
           public String reserveTicket(String name){
           return "reserved";
           }
          
          }





          • 2. Re: Seam Remoting Refactored
            shane.bryzak

            There are two types of client stub that can be generated, "executable" stubs and "type" stubs. Executable stubs are behavioural, and are used to execute methods against your session bean components, while type stubs contain state and represent the types that can be passed in as parameters or returned as a result.

            The type of client stub that is generated depends on the type of your Seam component. If the component is a session bean, then an executable stub will be generated, otherwise if it's an entity or javabean, then a type stub will be generated. In your example, the component type that would be returned by Seam.getComponentType() for your class is JAVA_BEAN (ie, its not a stateless or stateful session bean, nor an entity bean). So the default client stub that would be generated for this is a "type" stub (ie something that can contain state).

            I'll ask Gavin if I should change the rules used to determine the stub type. It wouldn't be difficult to test for the existence of the @WebRemote annotation on any of the bean's methods, and if it exists to create an executable stub instead of a type stub.

            • 3. Re: Seam Remoting Refactored
              gavin.king

              Yes, that sounds good.

              Oh, and copy/paste what you just wrote into the docs ;)

              • 4. Re: Seam Remoting Refactored
                gavin.king

                 

                "deniss.parhomenko" wrote:
                is it possible to use @WebRemote with play Java Bean, I try to use it together with Hibenrate (not EJB3)


                Just be aware that plain JavaBeans don't have managed transactions or role-based security, which means that you would have to deal with those concerns by writing an interceptor.

                • 5. Re: Seam Remoting Refactored
                  shane.bryzak

                  I've checked an update into CVS which will now check JAVA_BEAN components for any methods annotated with @WebRemote. If the annotation is found, then an executable stub will be generated allowing you to use remoting to call the methods of your component.

                  I've also updated the remoting docs with a description of the interface types.

                  • 6. Re: Seam Remoting Refactored
                    deniss.parhomenko

                    Thank you , i'll check it later