'Pro Spring' Book Review
- By Matt Stephens
A few years back, we began to see the backlash against heavyweight Java frameworks for enterprise applications, particularly around Enterprise JavaBeans (EJB).
Out of this backlash, there emerged the concept of lightweight app frameworks, the most promising of which is Spring. I’ve written about Spring here before, but to sum up, it’s a server-side technology which builds on J2EE and allows you to tie together various APIs and technologies using a single framework. Unlike EJB, and MVC web frameworks like Struts, Spring puts you in control. Your Java beans don’t have to extend any framework-specific classes; and it uses modern design concepts like Inversion of Control (IoC) and Aspect Oriented Programming (AOP) to help keep your codebase lean and maintainable.
Often, the success of a product can be measured by the number of books available for it. It’s a measure of the level of industry excitement (and probable future acceptance) surrounding it. And sure enough, Spring has its fair share of new books, both released and in the works. So far, the best of the bunch is Pro Spring (Apress, 2005) by Rob Harrop and Jan Machacek.
With a product like Spring, which covers so many different areas of development – and draws in lots of modern new programming concepts – there’s bound to be a learning curve. Luckily, Pro Spring provides a good introduction to the different parts of Spring. The book walks you through the basics, including how to download the product and set it up, and writing the inevitable Hello World app. It then provides a good explanation of IoC, including the different types of IoC; and explores the workings of the BeanFactory, which is kind of the “core” of the whole product.
Then there’s about 90 pages on AOP with Spring (all good stuff), followed by a satisfyingly detailed explanation of the different data access options available (strangely, no coverage of JDO though). This includes a good level of detail about how to use Spring’s JDBC support, which is important because not everyone is going to want to have to learn “yet another” O:R mapping framework (Hibernate, iBatis etc) when often, simply mapping JDBC result sets to your domain classes is going to be good enough.
There’s also some good material on middle-tier concerns such as transaction management, JNDI, how to use Spring with EJB (if you really need to!), job scheduling, mail support, and various flavors of remoting (e.g. using web services with JAXRPC).
Pro Spring provides more information than other Spring books on writing web applications with Spring, which is good because it’s likely that the majority of developers will be using Spring to write web apps. The main focus is on using JSP for the front-end, but there’s also plenty there about using Struts for the front-end – particularly useful if you’re moving from Struts and need a migration path.
The one really important area which Pro Spring skimps on is web security – a topic which should be the central focus of any web application; so it seems strange that they skipped it, aside from a passing reference to the emerging Acegi Security product, which is designed specifically for Spring.
All in all, this is the best of the Spring books available so far, and at 800 pages is also very comprehensive. If you want a book on Spring which does a bit more handholding than the (mostly excellent) on-line documentation, this is the one to go for.