views:

705

answers:

4

What role is Spring taking in Struts + Spring + Hibernate?

+12  A: 

Spring provides many different "modules" and different programmers will use different parts of Spring.

However, commonly in this sort of stack, you will see Spring being used as a provider of

  • An inversion of control container for dependency injection
  • An abstraction to Hibernate called "HibernateTemplate"
  • Framework classes for simplifying Aspect Oriented Programming
  • Transaction support, often "declaratively" via the IoC container and AOP.
Cheekysoft
+1  A: 

Please, don't call it SSH. SSH means something very precise in terms of networking, and your web applications are in a close enough domain that it will produce more confusion than communication efficiency.

florin
Thank you for your advice!
JSON
This isn't an answer. Leave a comment next time.
noah
+1  A: 

Well, Hibernate handles the persistence part, JSP handles your GUI, Struts controls the flow between pages/actions/etc, and Spring can manage all your beans which contain the main business logic, instead of using EJB. Plus it can simplify the coding of your Hibernate DAO's and transaction managing. Instead of having to code your Locator to obtain some EJB through JNDI and all that stuff, you can just get the Spring ApplicationContext and ask for the bean you need. All the beans defined in Spring can be interconnected. If you have to connect one of your beans to an external EJB through JNDI you can even do so without any code (Spring offers a JNDI proxy object which obtains the reference you give it and returns it as an object with the interface you specify). This can help you simplify unit testing of all those beans and change the config without recoding anything; you can use one of Spring's PlatformTransactionManagers to manage a DataSource or point it to a J2EE container's JTA manager; define your own pooled DataSource or use your container's DataSource published through JNDI, etc.

Chochos
A: 

can i connect struts1.2 with spring how ?

raj k singh