Version 2

     

    Integrating Seam and Spring is generally pretty easy.  Here is one way to do it:

     

    Seam in the Presentation Tier, Spring in the Backend

     

    Seam+JSF makes a terrific presentation tier.  Sometimes Spring is preferred over EJB for stateless services in the backend.  Seam can be used in the presentation tier to manage your controllers (JSF managed beans) and conversations.  In this scenario, you can inject the Spring stateless services into your Seam controllers with the Seam @In({mySpringService) annotation.  Since @In supports the expression language, Seam will use the standard variable resolver to look up a bean with the name "mySpringService".  Spring ships with a JSF variable resolver that allows you to reference any Spring managed bean with the EL.  To register the Spring JSF variable resolver, you must add this to your faces-config.xml:

     

    <application>
      <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
    </application>
    

     

    This enables a one-way dependency where Seam components (e.g., the controllers) can have Spring beans injected, but Spring beans cannot have Seam components injected.

     

    It is possible to have Spring recognize JSF managed beans, but I am not sure if that would enable Spring to reference Seam components.  Can anyone add more detail for two-way dependencies from Spring to Seam?