5 Replies Latest reply on Nov 6, 2008 4:05 PM by chawax

    Seam + EJB on multiple Layers

    nicolasc
      HI everybody!

      I'm designing a new Application in which we plan to use Seam + EJB3 beans. The Application will consist of following layers:

      View (JSF) + Controller (Seam component) + Service (Seam / EJB component) + DAO (EJB component).

      The idea is to let the application know about Seam just till layer 2 (Controller). Service and DAO's should work only with EJB.

      Is this a good approach?

      As far as I know, a purely seam component cannot access an EJB component. Thats why I wanted to make the services (EJB / Seam components). Is it here a work around available for this? (to let the service just be EJB bean and the Controller just seam componetns?).

      Another problem that I'm facing while designing the application, is to set the right Annotations to be used in each case.

      Controller:
      @Name("controllerName")
      @Scope(ScopeType.CONVERSATION)

      Service
      @Stateless
      @Name("serviceName")

      DAO:
      @Stateless

      What do you think about this? Is here a way to avoid using  @Name annotation in the Service layer?.

      Thanks a lot
      Nicolas



        • 1. Re: Seam + EJB on multiple Layers
          nicolasc

          Should I reformulate my Question? To much to read? Please Feedback really needed!

          • 2. Re: Seam + EJB on multiple Layers
            chawax

            Hi,


            I made the same kind of design for the project I work on.
            All components are EJB, stateful ones for JSF backing beans, stateless ones for services. At first time, as you suggest, I used EJB for services and DAO layer. But I finally made them Seam components because I needed to get current user in some of these services and it was a lot easier if all my components were Seam components ! Is there a reason why you want your service and DAO layer to be designed with EJB session beans and not Seam components ?


            About @Name annotation, you can use components.xml file to define your Seam components. I needed to do this because I use a MDA generator (AndroMDA) and it works perfect.


            Olivier

            • 3. Re: Seam + EJB on multiple Layers
              gjeudy

              Have you read about SMPC ? If you keep your DAO layer EJB only then I assume you won't be using SMPC but regular JPA PersistenceContext. I advise against doing that as you will have all sorts of bad behavior like LIEs, detached entities etc..


              Read more about this in Seam reference doc persistence section.

              • 4. Re: Seam + EJB on multiple Layers
                eskape.esk.ngs.ru

                Olivier,


                It is possible to get current users on EJB tier using EJBContext.getCallerPrincipal(), no need using Seam. We have the same approach - Seam is used as web framework only. The main drawback with Seam is that it is not possible using Seam Stateless Beans using JNDI lookups or with @EJB annotation, and this will not allow our third-party vendors to provide additional client (or plugin EJBs).

                • 5. Re: Seam + EJB on multiple Layers
                  chawax

                  egor kolesnikov wrote on Nov 06, 2008 15:39:

                  It is possible to get current users on EJB tier using EJBContext.getCallerPrincipal(), no need using Seam.


                  Well, I never found how to propagate security from Seam to EJB3 layer. I had posted on this forum : http://seamframework.org/Community/SeamAndSecurityContext and as you will see I spent a lot of time with this, tried many solutions but had no success at the end. Moreover for what I understood security propagation is application server specific, and I absolutely need my web application to work on any AS. For these reasons I think Seam was the better solution for me ;)