10 Replies Latest reply on Jan 7, 2008 5:39 AM by jagin

    How to create layered Seam application

      Hi,

      I found very interesting presentation at http://www.jugpadova.it/files/IntroductionJBossSeam.pdf about how to create Seam application with layers like domain, persistence, application (aka service) and controller.
      Example can be found here http://www.jugpadova.it/files/IntroJBossSeam_ExampleProject.zip

      I would like to know what do you think about this concept.

      Regards

      Jarek

        • 1. Re: How to create layered Seam application
          kukeltje

          I'm not an expert (and did not read the document in detail since most was a plain intro to seam), but wasn't (isn't) one of the goals of seam to get rid to this overly layered designs?

          • 2. Re: How to create layered Seam application

             

            "kukeltje" wrote:
            I'm not an expert (and did not read the document in detail since most was a plain intro to seam), but wasn't (isn't) one of the goals of seam to get rid to this overly layered designs?


            For simple web application it's ok to have only model and actions but it's get more complicated with wider application where the business functions a called from many action/controller components or are called outside of the Seam.

            What about database access, when you want to get the same data from different places. It's nice to have persistent layer where you get all database function in one place.

            And the talk goes one :]

            • 3. Re: How to create layered Seam application
              pmuir

               

              "kukeltje" wrote:
              I'm not an expert (and did not read the document in detail since most was a plain intro to seam), but wasn't (isn't) one of the goals of seam to get rid to this overly layered designs?


              +1, this is completely over the top layering. To summarize, this tutorial suggests:

              Entities
              DAOs
              Services
              Actions
              Presentation Layer

              which is totally unnecessary (especially both an action and service layer!). At least it doesn't suggest using DTOs ;)

              My approach would be to start with a single layer, and if you find yourself reimplementing functionality, factor out *that functionality* into a separate layer.

              e web application it's ok to have only model and actions but it's get more complicated with wider application where the business functions a called from many action/controller components or are called outside of the Seam.


              So, then factor out what you need to into a agnostic layer, and then call to that from Seam and your other app. Btw Seam supports EJB remote calls and WS calls.

              What about database access, when you want to get the same data from different places. It's nice to have persistent layer where you get all database function in one place.


              Err, the entity manager and named queries? Or, take a look at the Seam Application Framework - none of this layering nonsense and all your CRUD and queries in one place :)

              • 4. Re: How to create layered Seam application

                Hmm... I'm from Appfuse framework school where we have all this layers (MVC pattern) so that's why I was looking for a like solution in Jboss Seam.

                It looks like the way of using Jboss Seam is a bit different.

                Thanks

                Jarek

                • 5. Re: How to create layered Seam application
                  amitev

                  In what situation it is better to create more-layered app?

                  • 6. Re: How to create layered Seam application
                    nickarls

                     

                    "amitev" wrote:
                    In what situation it is better to create more-layered app?


                    Job security. If you are the only one who can modify the code, you are safe ;-)


                    • 7. Re: How to create layered Seam application
                      pmuir

                       

                      where we have all this layers (MVC pattern)


                      I don't think this is really the MVC pattern - the name gives away the layers MVC dsecribes - Model, View and Controller (no Service layer, no action layer, no DAO layer).

                      • 8. Re: How to create layered Seam application
                        nickarls

                        Owning a copy of Alur, Crupi & Malks "Core J2EE Patterns" myself, I was at first surprised by Seams heretic ways but I then started to realize the many of the patterns are trying to solve problems that really aren't there anymore.

                        Sure, you can look up your abstract factory through a service locator but what's the *real* use in that? Enjoy your classes, the time for interfaces and factories are when you really have two or more implementations of the same logic etc.

                        • 9. Re: How to create layered Seam application
                          amitev

                          In the sample project they don't use SMPC. They user @PersistenceContext and the dao's are application scope. No conversation usage at all - the "good" old stateless session facade.

                          • 10. Re: How to create layered Seam application

                            Becouse EJB3 is a new topic for me i've started to think that layering is out of date for this technology and start to search something about this on the google.

                            I found some very interesting articles where people have the same dilema about layering an application:



                            So it seems that it is a wide topic and the matter of your application and its requirements.