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.
| Author(s) | Bram Smeets, Seth Ladd |
|---|---|
| Publisher | Apress |
| PubDate | Aug 2007 |
| Reviewer | Sandesh Tattitali |
![]() |
Purchase and help Javalobby |
|
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.
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.
| Relevance | |
|---|---|
| Readability | |
| Overall | |
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.
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.