5 Replies Latest reply on Aug 2, 2009 6:06 PM by phantasmo

    Calling Seam components from a desktop app

    phantasmo

      Is it possible to call non-EJB Seam components from a Java SE desktop app? If yes, what Seam features would be supported?
      If there's some reading material on this, a pointer would be greatly appreciated.


      P.S.
      I did some googling but couldn't really find an answer... I did find some other great Seam related reads, though.

        • 1. Re: Calling Seam components from a desktop app
          swd847

          The easiest way would be to use web services.


          If this is not an option what protocol did you have in mind?

          • 2. Re: Calling Seam components from a desktop app
            phantasmo

            At first, I thought it might be possible to call Seam components in the same way you call EJBs from Java SE (is that JRMP?), but I guess that's not an option.


            It was a hypothetical question though, I haven't started implementing anything yet.


            Thanks for the advice though :)

            • 3. Re: Calling Seam components from a desktop app
              swd847

              There are other ways to do it, but web services are by far the easiest. You could for example use RMI but you have to start the seam app before making any calls, something like:


              Lifecycle.beginCall();
              MyComponent c = (MyComponent)Component.getInstance("myComponent");
              c.doStuff();
              Lifecycle.endCall();
              



              Doing it like this means you wont have access to the session and conversation scopes (although you probably could if you wrote some kind of manager that uses mock HttpSession objects to provide the session scope).

              • 4. Re: Calling Seam components from a desktop app
                fernando_jmt

                I have a Seam application working with a dual interface, one web (non-EJB) and one desktop (lunched from JWS). What I would suggest you is to use the RESTful webservices support Seam has bundled, it made the things so easy, you can reuse your components, you can use the same authentication and authorization mechanisn, conversations, and so on.


                You just have to decide how to preserve your http session in the client if your application is session aware. In my case I asked the user for a login (before entering the application), then I preserved the session and invoked the services in that way. BTW, RESTEasy has a wonderful and easy way to consume your webservices.


                HTH.

                • 5. Re: Calling Seam components from a desktop app
                  phantasmo

                  Ok, thanks guys, you've been very helpful!