5 Replies Latest reply on Jul 29, 2009 12:43 AM by asookazian

    Seam components as EJBs in the web tier

    javanaute

      Hello All,


      I have a seam based web application with the business tier developped as an EJB JAR.


      All my seam components in the web tier are simply annotated with @Name(..) and they all call session beans that reside in the business tier.


      My question is two fold :



      1. Can i make my seam components which are in the web tier become Session EJBs and can i set this in a configuration file instead of using annotations (Am thinking about ejb-jar.xml) ? What i actually want is to be able to take advantage of the EJB 3 interceptor stuff (with @ArroundInvoke etc)




      1. Does seam have a mechanism for hooking into components method calls (To do AOP stuff) -Am not talking about lifecycle methods here which works fine-



      Thanks for any reply and thanks all for the great job you did.

        • 1. Re: Seam components as EJBs in the web tier
          asookazian

          1) as per JSR220, you can override annotations with xml configs in ejb-jar.xml.  Or use ejb-jar.xml configs without annotations at all.  either way.


          2) there is no AOP framework in Seam per se (like AspectJ, etc.); Seam uses interceptors and raiseevent/observe pattern.  provide an example or use case.

          • 2. Re: Seam components as EJBs in the web tier
            javanaute

            Thanks David for your reply,


            1) as per JSR220, you can override annotations with xml configs in ejb-jar.xml. Or use ejb-jar.xml configs without annotations at all. either way.


            Ok about this, at least in the EJB JAR. What about in the web tier (Am deploying to a war). This was my question :


            Can i make my seam components which are in the web tier become Session EJBs and can i set this in a configuration file instead of using annotations (Am thinking about ejb-jar.xml) ? What i actually want is to be able to take advantage of the EJB 3 interceptor stuff (with @ArroundInvoke etc)


            2) there is no AOP framework in Seam per se (like AspectJ, etc.); Seam uses interceptors and raiseevent/observe pattern. provide an example or use case.


            My question was :


            Does seam have a mechanism for hooking into components method calls (To do AOP stuff) -Am not talking about lifecycle methods here which works fine-


            Am asking about wether there are intercepting mechanisms for method calls such as those of EJBs (Defined with @Interceptors(..)).

            • 3. Re: Seam components as EJBs in the web tier
              asookazian

              1) you can easily convert any JavaBean to a sesison bean.  Typically it's just a matter of implementing a local interface and adding @Stateful or @Stateless annotation at the class level.  If you don't want to use annotations, you add the appropriate meta-data in ejb-jar.xml (see JSR200 for details).


              2) yes, read this section of 6.11. Seam interceptors of Seam 2.1.2 ref doc.

              • 4. Re: Seam components as EJBs in the web tier
                javanaute

                Thanks again Arbi (And not David .. Sorry),


                Your answer was really very helpful .. I also had a look at the JSR which contains a lot of helpful informations ..

                • 5. Re: Seam components as EJBs in the web tier
                  asookazian

                  A helpful alternative to JSR220 (yes, specs are typically dry/tedious to read!) is EJB in Action, very good book...