0

I have following Project Structure:

  • Shared Frameworkproject (plain java maven, includes all Business, DAO logic and Models) with 90% Singletons
  • JSF-Application which uses the Frameworkproject and just adds Managedbeans and views which consume the business logic (no maven)

see an example at another question: JSF Singleton Services/DAO/.. vs ApplicationScope

Now I want to refactore the Frameworkproject to be Spring-compatible to be able to use dependency injection in all other related projects.

So this also affects the JSF 2.0 Application and therefore I have some Questions as I was not able to get things to work until hours of attempts:

  • Is this a proper way to build a new architecture (JSF with Spring) - are they fully compatible or is some part not 100% working after that
  • Can I just use @Autowired in Session/ViewScoped-ManagedBeans for my @Service-Classes of the Frameworkproject? Do I need a setter like ManagedProperties in JSF as well?
  • Do I need a applicationContext.xml in both projects or only in one (where the component-scan is defined)
  • I just want to make the application multi-user-"able" together with spring. If thats not a good way to achieve this, I am happy to know.
  • what is the minimal working set of spring-configuration in my Projects to get things to work (I don't need Spring-MVC and stuff like that because I have jSF)
Community
  • 1
  • 1
Niko
  • 1,054
  • 5
  • 25
  • 52
  • it is in general a good idea to use JSF and Spring together? or is it recommended to either stick at JSF or Spring (with MVC and so on)? – Niko Jun 21 '16 at 17:19
  • Spring has its mechanisms to allow you integrate with JSF, however, if you let JSF create its own beans, you will be required to look up for the Spring context specifically: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/web-integration.html#jsf-facescontextutils For my current project, which is based in Spring Boot, what I do is let Spring manage everything, annotating the managed beans with `@Component` and adding a custom view scope which emulates the JSF one. Then, make JSF access the beans using `SpringBeanFacesELResolver` and use them as if it was plain JSF. – Aritz Jun 22 '16 at 10:07

0 Answers0