10 Replies Latest reply on Jul 28, 2011 6:06 PM by Peter Penzov

    Modular application design with Seam 3

    Peter Penzov Newbie

      Hi,
        I'm developing application with Seam 3. I think that the best way to do it is to use modular design.
      And here is the problem:
      If I split the application into modules how are thy going to use one framework. I want to split the modules in different .JAR files.
      Can you give some advice what is the best way to do it and some mistakes I should avoid when I write the code.


      Regards
      Peter

        • 1. Re: Modular application design with Seam 3
          Sebastian Sachtleben Novice

          I have also an application splited in common, core and several modules. I have declared common and core as jar pom and the modules as war poms. Then create a distribution project and use the maven war plugin to overlay all jar and war files to one big war file. I had problems to combine faces-config.xml from several modules so I have switched to annotation based navigation from pretty faces. But beware the overlaying process takes alot of time. My buildtime went up to arround 2 minutes with 10 modules. I'm sure it would be much faster with a single project.

          • 2. Re: Modular application design with Seam 3
            Robert  Anderson Newbie
            I'm doing some experiences with Web Application Bundles (OSGI + CDI + JSF 2). It's very interesting! Is anyone using this combination in real projects?
            • 3. Re: Modular application design with Seam 3
              Peter Penzov Newbie

              Sebastian Sachtleben wrote on Jul 27, 2011 02:33:


              I have also an application splited in common, core and several modules. I have declared common and core as jar pom and the modules as war poms. Then create a distribution project and use the maven war plugin to overlay all jar and war files to one big war file. I had problems to combine faces-config.xml from several modules so I have switched to annotation based navigation from pretty faces. But beware the overlaying process takes alot of time. My buildtime went up to arround 2 minutes with 10 modules. I'm sure it would be much faster with a single project.


              Click HELP for text formatting instructions. Then edit this text and check the preview.


              Hi,
                Would you give us more information how you divide the project into modules.


              Regards
              Peter

              • 4. Re: Modular application design with Seam 3
                Peter Penzov Newbie

                Question to all members:
                Can you give me advice how to develop simple modular application with Seam 3?

                • 5. Re: Modular application design with Seam 3
                  Sebastian Sachtleben Novice

                  I have a parent pom file in the root which has packing type pom with several modules:


                       <groupId>groupId</groupId>
                       <artifactId>parent</artifactId>
                       <packaging>pom</packaging>
                       <version>1.0.0-SNAPSHOT</version>
                       ...
                       <modules>
                            <module>common</module>
                            <module>core</module>
                            <module>modules</module>
                            <module>distribution</module>
                       </modules>
                       ...
                  



                  Common and Core pom xmls are declared as packing type jar. The modules pom xml is again packing type pom and includes a list with all modules like the parent pom.
                  Each module has a pom file packing as war file.


                  The distribution merges all modules together by depending on common, core and each module:


                       <parent>
                            <groupId>groupId</groupId>
                            <artifactId>parent</artifactId>
                            <version>1.0.0-SNAPSHOT</version>
                            <relativePath>../pom.xml</relativePath>
                       </parent>
                       <groupId>groupId</groupId>
                       <artifactId>distribution</artifactId>
                       <packaging>war</packaging>
                       <version>1.0.0-SNAPSHOT</version>
                       ...
                       <dependencies>
                            <dependency>
                                 <groupId>groupId</groupId>
                                 <artifactId>common</artifactId>
                            </dependency>
                            <dependency>
                                 <groupId>groupId</groupId>
                                 <artifactId>core</artifactId>
                            </dependency>
                            ...
                       </dependencies>



                  I'm using maven-antrun-plugin to publish the war file to my jboss after compiling is done.


                  The folder structure looks like this:


                  - common
                       - src
                       - pom.xml
                  - core
                       - src
                       - pom.xml
                  - modules
                       - login
                            - src
                            - pom.xml
                       - contact
                            - src
                            - pom.xml
                       - pom.xml
                  - distribution
                       - pom.xml
                  - pom.xml





                  But this has nothing to do with Seam 3 - its about maven build architecture.

                  • 6. Re: Modular application design with Seam 3
                    Peter Penzov Newbie

                    Ok this is made on Maven level. What do you do at the application level and Seam 3 level?
                    I suppose that you create different java packages for each module. Then you declare the classes in them as private in order to keep the access restricted. How do you configure witch java package in which war file to go.
                    Sorry for the newbie questions. I highly appreciate any help.


                    Regards
                    Peter

                    • 7. Re: Modular application design with Seam 3
                      Sebastian Sachtleben Novice

                      Nothing special on Seam 3 level. Well my distribution pom xml puts all together to one war file. If you want to use a class from one module in another you just need to add a maven dependency with scope provided and you are ready to go.


                      Do you want to use ear and each module should be an own war file? Not sure about that handling.

                      • 8. Re: Modular application design with Seam 3
                        Peter Penzov Newbie

                        What about the performance? When the application is divided into modules I suppose that this doesn't make it slow.


                        Is it possible to update the modules when the application is in production state? For example just copy/paste the new module into his own directory?


                        • 9. Re: Modular application design with Seam 3
                          Robert  Anderson Newbie
                          Peter,

                          Modular application development/build (Sebastian's approach) != Modular application development/deployment

                          Look this screencast:

                          http://blogs.oracle.com/arungupta/entry/screencast_32_osgi_enabled_java

                          On this way you can install/update/remove modules in runtime.
                          • 10. Re: Modular application design with Seam 3
                            Peter Penzov Newbie

                            Thank you! Very valuable information.


                            Regards
                            Peter