views:

143

answers:

4

I'm currently rebuilding an existing PHP application using Java. I therefore have an existing frontend GUI and an existing database schema that I'm working with.

Here is the technology stack I'm working towards:

  1. jQuery, client-side
  2. Wicket, front-end
  3. Spring, ???
  4. Hibernate, ORM
  5. MySQL, database

Before reading about Spring in both Wicket In Action and the Hibernate documentation, I envisioned wiring the two together through my own business logic. I have experience with JBoss Seam, but am told that Spring is hardly comparable (although the documentation suggests otherwise, IMO). Short of adding a book about Spring to my reading list (I haven't found an appropriate one with good reviews yet), I'm at a loss.

What benefit(s) will Spring provide in this technology stack?

Subjective & optional follow up question: what reference material (book, website, etc) will get me started with the portion of Spring 3 I may utilize?

+2  A: 

Spring, as noted in this review is non-invasive. It just wires your application components. And provides useful classes that make using other frameworks easier (JMS, JPA, etc). Spring doesn't force you to use its classes or interfaces anywhere.

What it handles is the creation of your components (objects), so that you can refer to a class' dependencies, without instantiating them. I.e. you say what your class needs, not how it is obtaining it. This makes the application very flexible.

That's in short - for more, read the linked article. It's not about the latest version, but that doesn't matter.

Bozho
+2  A: 

In addition to dependency injection, Spring offers features like declarative transaction management, simple integration with ORM, aspect-oriented programming support and many other nice things.

For documentation see Spring reference: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html

Aleksey Otrubennikov
+2  A: 

First, you can make your web application without Spring. But Spring will greatly facilitate things. Spring framework is a lightweight, non-invasive. Spring is like a kind of conductor. Among other things Spring helps you in:

  1. To keep your objects loosely coupled. This will make your application more flexible and open to future changes

  2. Powerful support for transactions through the AOP (Aspect Oriented Programming).

  3. Object-relational mapping (ORM) integration module. Spring doesn’t attempt to implement its own ORM solution, but does provide hooks into several popular ORM frameworks, including Hibernate, Java Persistence API, Java Data Objects, and iBATIS SQL Maps. Spring’s Transaction management supports each of these ORM frameworks as well as JDBC.

  4. The Spring MVC framework. Even though Spring integrates with several popular MVC frameworks, it also comes with its own very capable MVC framework that promotes Spring’s loosely coupled techniques in the web layer of an application.

A good book about Srping: Pro Spring

JLBarros
+2  A: 

@Dolph, in the simplest term, think of Spring as your application framework at the highest degree. This "framework" provides several "component buckets" where you can easily plug in different types of implementations. For example, for ORM, you may choose to use Hibernate over JPA or TopLink, for front end, you may choose Wicket over Struts or SpringMVC, and so forth.

The whole beauty of this (besides all the goodies stated in other posts) is it allows you easily swap out any of these implementations easily in the future. So, you can essentially rip out Hibernate one day and replace with TopLink, and it will never cause ripple effect to other components.

Another beauty of using Spring is your code becomes less clutter and has loose dependencies with other classes because you spend less time creating new objects yourself, Spring handles that for you. That said, you will quickly realize how easy for you to test your code because your API to be tested becomes very atomic. This is one primary reason why folks get discouraged in writing testcases, because they quickly realize that in order for them to test one API, they have to construct whole lot of things just to test that. Because of that, the whole process is brittle, imagine if you change that API, you need to reconstruct everything before testing it again.

Pro Spring book is good, mentioned by @JLBarros. I like Spring in Action very much. It is very very easy to read when I first got started with Spring. This is probably one reference book that I read from skin to skin.

limc
I like the *In Action* series, but I wasn't confident in the book after reading the Table of Contents... but then again, I had no idea what I wanted out of Spring, so I didn't know what to look for! The second edition is expected to come out Dec 2010 as well.
Dolph
The In Action by no means have all the details about Spring. For that you need to refer the springsource website directly because they have the most complete documentation I have ever seen. The In Action helps me to get started right away and the explanations are very easy to understand. When I need more info after that, I will dig around springsource.
limc