Michael has posted 1 posts at DZone. View Full User Profile

Beginning Spring 2

  • submit to reddit
Published by: Apress
ISBN: 1590596854

Reviewer Ratings




Buy it now

One Minute Bottom Line

For a beginner trying to ease himself into Java development with Spring, for a manager needing to understand Spring concepts or even for a more experienced developer needing a refresher of Spring concepts, this book will do nicely. It is well-structured, features a good breadth of topics covering all tiers of enterprise Java applications, uses a lot of examples to illustrate the presented concepts and slim enough to be read in its entirety while that new Spring project goes under way.

If you need a single book, however, which will carry you through most aspect of a Spring-based project, I would recommend Craig Walls's Spring in Action. While much thicker, it gives you more theoretical underpinnings, covers material in greater detail and features more engaging and humorous writing style.


Chapter 1. An Introduction to Spring.

The author starts off by giving his interpretation of terms defining the topic of the book explaining to the reader the notion of frameworks, the adjectives "lightweight" and "agile" as they apply to Spring framework, and the two foundation concepts of Spring, Dependency Injection and Aspect-Oriented Programming. The chapter also talks about features available in Spring for Web application development, as well as tools for Spring development such as Maven and Spring IDE Plug-in.

Chapter 2. Presenting the Sample

In this chapter Dave Minter gives the overview of the online timesheet application whose construction is illustrated by the examples throughout the book. He starts with the architectural discussion describing the standard three-tier architecture, followed by a simple specification and several use cases describing typical usage of the application. The remainder of the chapter is dedicated to the basics of Maven used to manage sample application build process.

Chapter 3. The Heart of Spring: Inversion of Control

The discussion of dependency injections starts with its rationale, its benefits and drawbacks, and situations where it is most useful (and those where it is not). The author presents two ways to use dependency injection in Spring - programmatic (since it is rarely used, I found it amusing that the author presented it first) and the more common way - through an XML descriptor. Seeing the verbosity of the programmatic approach made me realize the comparative elegance of XML descriptors (which, in turn look cumbersome compared to Spring 2.5 annotations, which are not covered in this book). Besides standard topics of property and constructor injection and auto-wiring, the chapter mentions usage of namespaces in configuration files. The chapter concludes with very brief discussions of BeanFactory and life-cycle events it makes available, application contexts and resource injection.

Chapter 4. Data Access

The chapters starts with the explanation of the Data Access Object pattern and Spring template classes used to implement DAOs. The two types of data access technologies the author chose to present are JDBC and Hibernate, covering the two ends of the spectrum based on their levels of abstraction. The sections dedicated to those technologies are sufficient to give the reader the flavor of the JDBC- and Hibernate-based data access implementation, but are inadequate as hands-on guides.

Chapter 5. The Service Layer, Transaction Management and AOP

The introduction of AOP makes this chapter the most dense one in the book. I am curious why the author decided to expend much more effort presenting AOP than, for example, Hibernate. While AOP is no doubt a very exiting and revolutionary technology, learning basics of ORM technologies would be more useful in a typical application. The firs part of the chapter is concerned with transactions, their basics, types of transaction managers and ways to configure them using annotations and XML descriptors. The remainder of the chapter, dedicated to Aspect-Oriented Programming, introduces both native Spring support of aspects as well as support for AspectJ annotations. The AOP examples the author presents deal with securing the timesheet application. To give the reader a more in-depth look at AOP constructs, the author complements the declarative approach of using AOP with Spring with a programmatic one by implementing pointcuts as Java classes.

Chapter 6. Web Applications

In the chapter dedicated to the presentation tier, Mr. Minter covers Spring MVC, its integration with Spring Web Flow and two view technologies that can be used in place of Java Server Pages, Velocity and FreeMarker. The Spring MVC section presents such basic concepts as Dispatchers, Controllers, Views and Resolvers and shows how they work together to implement the MVC pattern. The chapter only mentions SimpleFormController and only UrlBasedViewResolver. Validation and exception handling are briefly addressed. The chapter also touches upon the above-mentioned view technologies and Spring tag libraries.

Chapter 7. Security

This is the second section of the book (after the AOP discussion), where the author dedicates more than average amount of material to a single topic. The chapter starts with a brief overview of security in general and Spring (Acegi) Security framework in particular. The presentation of Spring Security frameworks covers two principal subjects - filters and providers. The section on filters covers the notion of filter chaining, and shows an example of filter configuration containing authentication processing, anonymous processing, security interceptor and exception translation filters. If filter configuration is concerned with what to do, providers determine how that processing is to be done. The provider section deals mostly with authentication, specifically through DAO authentication provider, mentioning other providers at the end. The chapter also discusses the mechanisms for applying security decisions programmatically through security JSP tags and security context object as well as the ways to apply security to the middle tier through Acegi annotations.

Chapter 8. Sending E-mail

This entire chapter is dedicated to using email in enterprise applications. The chapter introduces Spring API support for sending text and MIME messages (MailSender and JavaMailSender). Next the author covers the mechanism behind sending plain text messages, progressing to using Velocity for HTML-formatted messages and concluding with a section on attaching images and arbitrary files to HTML mail messages.

Chapter 9. Remoting

Having explained the need for remoting mechanism in the enterprise applications, the author dedicates the remainder of the chapter to the remoting protocols supported by Spring. The first protocol introduced is RMI. The section provides an example of the configuration of an RMI server and implementation of an RMI client in Spring. Next, the chapter moves to the HTTP-based remoting mechanisms represented by Spring HTTP invoker, Hessian and Burlap. The sections on Hessian and Burlap explain how to work around the problem of using Hibernate proxy objects (supporting lazy loading of entities) across the wire. The last section of the chapter dealing with the SOAP protocol presents the examples of JAX-RPC server and client implemented using Apache Axis.

Chapter 10. Testing

The chapter starts with a discourse on the evolution of testing and advantages of automated tests. Following the introduction of concepts of test-driven development, and mock objects, the chapter proceeds with examples of writing tests for most of the functionality explored in the preceding chapters. That covers tests for data access objects and their realizations for JDBC and Hibernate, tests for email components, tests for service and presentation layers. The chapter concludes with discussions of integration testing, web testing and regression testing.


The book concludes with a useful appendix describing the installation and usage of Spring IDE Plug-in for Eclipse whose goal is to automate common Spring configuration tasks.
Published at DZone with permission of its author, Michael Smolyak.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)