About the Reviewer
Sandesh Tattitali is the proud father of two lovely children, his son Rohit and daughter Diya. He has been in the IT industry since 1993. He is currently working as a solutions architect (primarily with J2EE) in a midwest bank. His software programming/development philosophy is captured by the statement "Programming is NOT an art, however there is an art to writing good programs". He is still (after all these years) in the pursuit of the art.
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

NetBeans 6: Matisse Updates

NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed.

Introduction to Groovy Part 3

In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.

Easier Custom Components with Swing Fuse

Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.

Benchmark Analysis: Guice vs Spring

Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.

Building Spring 2 Enterprise Applications



Author(s) Bram Smeets, Seth Ladd
Publisher Apress
PubDate Aug 2007
Reviewer Sandesh Tattitali
Purchase and help Javalobby






Table of Contents






One Minute Review

Positives
  • Pretty decent introduction to Spring for beginners.
  • Informative and useful tips/programming advice spread throughout the book.
  • Lot of code examples.
Negatives
  • In a lot of instances, the reader is referred to other texts, rather than finding an answer in this text itself.
  • There is a lot of good advice spread throughout the book, however, the reader has to go through the text thoroughly to pick those up, rather than those being highlighted in a sidebar or such.
  • The book would have been better if it covered the integration of Spring and an ORM like Hibernate rather than just illustrate how Spring simplifies development using JDBC.

In the reviewer's opinion, the authors have targeted a very narrow segment of the developer community viz. beginners to Spring who are going to be working on a simple web application not involving other frameworks. The reviewer felt that quite a few corners have been cut in order to make the book palatable to this community. In a lot of places, the value of the book was undercut because of adherence to this goal. Maybe there was some fear of an overlap of material vis-a-vis the other Apress Spring books already out in the market.

Overall, however, the book is a decent read, especially for beginners of Spring. Those who have been programming with Spring for a while will not find much new material. On account of the extensive code examples, this is a better resource for programmers who wish to go into Spring using code to understand the framework, rather than programmers who wish to get a general understanding of the framework and the benefits it provides (the reviewer falls into the latter category). The tennis example is a bit weak from a domain point of view (something related to finance, for example, would have been a much better application example). Also, an "All Spring" approach is not so powerful as to what could have been illustrated by using an example that tied together Hibernate, Spring and Struts (for example). Also, it would seem that the book would have been far more beneficial if the authors had waited a couple of months and included a chapter or appendix on Spring 2.5 annotations support.

Sections

Intent & Audience

The goal of the book is to provide an introduction to Spring and via the sample application, illustrate how it can lead to more efficient Java development. It also aims to show the simplicity and consistency of the framework.
The book is intended for Java developers who want to use the Spring framework in their applications. The book assumes a good understanding of Java, JDBC and web containers on part of the reader.

back to top Back to top

Relevance of material

Over the past 2-3 years, a lot of projects have started using Spring as their core framework eschewing the more complex EJB frameworks provided by the application server vendors. That the popularity of Spring is quite high can be gauged from entire conferences addressing all things Spring related e.g. The Spring Experience and also official application server vendor support for the framework e.g. BEA. Spring has the "duality" of being used as a soup to nuts framework solution or used in a best of breed environment. Spring provides modules for all layers of web development or can be used (on account of its modularity) as a layer in an architecture that uses various other frameworks like Struts and Hibernate. Even though the book seems to push for using Spring as a soup to nuts solution framework, it does provide enough information so that the user can get an idea about how Spring can be used for just its Dependency Injection capabilities, for example. There is also a lot of non-Spring "good practices" information spread throughout the pages.

back to top Back to top

Rating

Relevance
Readability
Overall

back to top Back to top

Chapter highlights

1. A Gentle Introduction to the Spring Framework:
Chapter 1 introduces the Spring modules e.g. IOC, AOP, etc. It also gives the reader basic information on the sample application that is the common thread throughout the book. Spring is illustrated via developing code for this sample application. Dependency management using plain Java or JNDI is illustrated and it is shown why they are not as good as the dependency management provided by Spring. Dependency injection is explained and its benefits elaborated upon. There is a comparison of Spring and EJB. The Spring installation process is also touched upon.

2. The Core Container:
Chapter 2 touches upon the core container which is essentially a factory that uses configuration files to assemble the application. A whole slew of Spring components are explored. The reader gets a good understanding of how a bean is defined to be a singleton or a prototype and its lifecycle. Setter and Constructor injection is discussed as is the property editor. The ApplicationContext type is explained in detail as it is a component that gets used quite often in Spring applications.

3. Aspect Oriented Programming:
After discussion how traditional OO applications can be extended via using inheritance or the Observer or Decorator patterns, the limitations of OO and the benefits of AOP are touched upon. We learn how classic Spring AOP allows us to create and configure cross cutting concerns using pointcuts and advices.

4. Spring AOP 2.0:
Chapter 4 provides a very comprehensive coverage of Spring AOP 2.0. Starting off with a discussion of AspectJ and use of annotations in the latest version, it moves onto the configuration of aspects in Spring. It covers the various advice types illustrating via simple examples how and where each of them can be used. The usage of AOP XML tags as opposed to annotations is also touched upon in this chapter. The power of pointcuts is illustrated by showing various mechanisms that cab be used for declaring pointcuts e.g. all methods of class with specific annotation, all methods with specific name, selecting methods via classes, packages and inheritance, etc.

5. Introduction to Data Access:
This chapter gives a good introduction to the issues encountered while using JDBC to connect to the database from your Java web application. The information in this section should be a must read for any new developer who is going to start off with JDBC programming in a web application environment. This is followed by a brief introduction to the Spring solution to the data access problem. Setting up datasources and connections pools in Spring is shown.
Even though most of this chapter covers non-Spring related material, it illustrates one of the stronger points of this book which is the objective evaluation of issues that exist in enterprise application development and the way that Spring solves them. Even from a non-Spring perspective this information is invaluable.

6. Persistence with JDBC:
This chapter continues where chapter 5 leaves off. The JdbcTemplate class is covered in detail. The various callbacks provided by Spring are laid out and the usage of RowMapper to bind database column values to object attributes is shown. We are also shown how to work with stored procedures, SQL batches and LOBs in Spring. A brief description of new Spring 2.0 features including the SimpleJdbcTemplate and simplified JNDI datasource lookups rounds up the chapter.

7. Transaction Management:
A brief introduction to the ACID properties of transactions is followed by a detailed dive into transaction management in Spring. One of the major pluses of EJB technology is the extent to which it simplifies transaction management and Spring does an equally good job in that respect. The different kinds of transaction managers in Spring are listed to illustrate Spring's integrability with various data-access frameworks e.g. Hibernate, JPA, JDO, etc. We are shown how transactions are demarcated at both the class level and the method level using XML configuration and annotations (since Spring 1.2). The chapter concludes with an introduction to the simplified transaction demarcation introduced with Spring 2.0.

8. Spring MVC:
An overview of Web application architecture is followed by a description of the Spring MVC architecture. The various components of Spring MVC are introduced. The configuration details for a Spring MVC application are detailed viz. changes to web.xml. This is followed by a sample Spring MVC application that covers three simple use cases. Not only does the application illustrate Spring MVC, it also goes over some of the material from the earlier chapters to illustrate how everything ties in together to form a complete web application. Technical aspects like handling simple form data, data validation and pagination are included as part of the sample application use cases.

9. View Technologies:
This chapter takes a deeper look at the ViewResolver component and its various implementations, including those for enabling the use of Velocity and FreeMarker in your web application. Examples also cover the use of XSLT, Excel and PDF as views. The chapter ends with a listing of various Spring 2.0 form tags. The web pages illustrated are developed using JSP/JSTL in chapter 8, so it allows the reader to compare and contrast the view technologies.

10. Testing:
The last chapter starts off with a brief introduction to testing, unit testing, integration testing and Test Driven Development (TDD). Testing examples are illustrated via Junit and EasyMock. Why the authors did not choose to illustrate Junit examples using Junit 4 is perplexing. A simple example illustrates how once can Spring support for integration testing. The chapter closes out with a brief listing of Spring mock classes.

back to top Back to top

Appendix. Installing Eclipse Web Tools Platform:
The appendix illustrates (with a lot of screenshots), the process of installing Eclipse WTP. Even though the authors make the point that WTP simplifies the development of a Web application using Spring, it seems a bit weird that they chose the install process to be illustrated. This is one appendix that is definitely a waste of space.

back to top Back to top

Resources