File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring in the business layer

 
Padma Prasad
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused. some articles say that Spring is similar to struts and is here to replace struts in web tier. and few say that Spring can be used in business tier with struts in web tier. Which is true? Can I use Spring in place of EJB's in business layer?

is this design possible?

Struts(Web tier) + Spring(Business layer) + Hibernate(Persistence layer)

Thanks in advance,

Angel
 
Steven Bell
Ranch Hand
Posts: 1071
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In short, yes.

Spring has several components that can be used with other Spring components, with other frameworks, or standalone. If you use Hibernate as your backend Spring can deal with transaction managment for you, and there are other benefits, but I'm not really an expert here. Once you have that you can use JSP, JSF, Sevlets, Struts, Spring, Tapestry, ect... for the frontend.

I believe you can also use Spring with JDO, EJB's, and some other persistence layers, as well as standalone, on the backend.

Spring was designed to be very flexible and modular.
 
arnel nicolas
Ranch Hand
Posts: 149
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes sir, in addition to that you can use Spring as an AOP Framework. You can use it as your ORM or it can work with other ORM like Hibernate. You can also use it in building your web layer and for your view layer as an alternative to Struts or you can use it to work with Struts. You can also use it in managing your transaction that can work with different platform like JTA, Hibernate, JDBC and etc.
 
Ryan Breidenbach
author
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use it as your ORM or it can work with other ORM like Hibernate.

Not to be picky, but... Spring does not have its own ORM framework. It provides a framework that makes it much easier to work with JDBC, as well as integration with several ORM tools, such as Hibernate, JDO, iBATIS and OJB.

You can use it as your ORM or it can work with other ORM like Hibernate. You can also use it in building your web layer and for your view layer as an alternative to Struts or you can use it to work with Struts.

Just to be clear, Spring does not provide its own view technology. It does integrate with other view technologies like JSP, Tapestry and Velocity. It also provides Spring tags for easier integration.
 
David Harkness
Ranch Hand
Posts: 1646
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ryan Breidenbach:
Spring does not provide its own view technology.
I thought Spring MVC was a complete web framework. If not, is it merely missing the presentation layer (view in MVC) for which you can use any number of templating libraries?

Rod covered it only briefly in his book Professional Development Without Drinking the Kool-Aid -- er, I mean Without EJB -- but I was under the impression it was complete on its own.
 
Axel Janssen
Ranch Hand
Posts: 2166
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think in this discussion definitions of view technology and MVC framework are mixed.
If I understand correctly, Struts doesn't offer a genuine view technology neither. You use a view technology like jsp, jsf, tapestry or velocity in a MVC framework to tell the browser how to render a view. And you know that. Its just a definitions overflow.
[ April 30, 2005: Message edited by: Axel Janssen ]
 
David Harkness
Ranch Hand
Posts: 1646
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right, of course. For the past several years I've been using Struts with an in-house XML + XSL -> HTML view layer. I'm pretty burnt out and it didn't even occur to me that Struts doesn't have its own view technology. Thanks for the correction.

So I guess Spring MVC is equivalent to Struts as far as the roles they play.
 
An Huiqiang
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Angel Hafer:

Struts(Web tier) + Spring(Business layer) + Hibernate(Persistence layer)
Angel


My project is using this model.
But i think it is not the best.
Now i am studying jsf.
Maybe jsp+spring+hibernate is better.

 
Padma Prasad
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so, Struts + Spring + Hibernate is not good combination? I have been reading about them a lot.

This scares me.
 
James Carman
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fear not. It's perfectly okay to use Spring with Struts and Hibernate.
 
Craig Walls
author
Ranch Hand
Posts: 363
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Carman:
Fear not. It's perfectly okay to use Spring with Struts and Hibernate.


Sure, Struts/Spring/Hibernate is a fine way to develop an application. I think the reason some people dismiss this combination is that Struts 1.x (as we know it) is a dead/sick/dying project. There's nothing wrong with it, but there are better options available nowadays.

My favorite stack is Tapestry/Spring/Hibernate, but I also see some merit in JSF/Spring/Hibernate. I've also developed several apps using SpringMVC/Spring/Hibernate. To each his own.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic