Spring Live
Spring Live
Chapter Summaries
This book is written for Java developers familiar with web frameworks. Its
main purpose is for Java developers to learn Spring and evaluate it against
other frameworks. One of my hopes is to compare Spring to other web frameworks,
or at least show how it can be integrated with other frameworks (i.e. Struts,
WebWork, maybe even Tapestry down the road). This book will contain a usable
sample application that includes Spring code to wire DAOs and Services
together. The book does have a bit of a Struts perspective to it as I have been
a Struts developer for almost three years and Struts is the most popular web
framework today. It is only natural that I use my experience in my writing.
Chapter 1: Introducing Spring covers the basics of Spring,
how it came to be and why it’s getting so much press and rave reviews. It
compares the traditional way of resolving dependencies (binding interfaces to
implementations using a Factory Pattern) and how Spring does it all in XML. It
also briefly covers how it simplifies the Hibernate API.
Chapter 2: Spring Quick Start Tutorial is a tutorial on how to write a
simple Spring web application using the Struts MVC framework for the front end,
Spring for the middle-tier glue, and Hibernate for the back end. In Chapter 4,
this application will be refactored to use the Spring MVC framework.
Chapter 3: The BeanFactory and How It Works. The BeanFactory represents the
heart of Spring, so it’s important to know how it works. This chapter explains
how bean definitions are written, their properties, dependencies, and
autowiring. It also explains the logic behind making singleton beans versus
prototypes. Then it delves into Inversion of Control, how it works, and the
simplicity it brings. This chapter dissects the Lifecyle of a bean in the BeanFactory
to show how it works. This chapter also inspects the applicationContext.xml
file for the MyUsers application created in Chapter 2.
Chapter 4: Spring’s MVC Framework describes the many features of
Spring’s MVC framework. It shows you how to replace the Struts layer in MyUsers
with Spring. It covers the DispatcherServlet, various Controllers, Handler
Mappings, View Resolvers, Validation and Internationalization. It also briefly
covers Spring’s JSP Tags.
Chapter 5: Advanced MVC covers advanced topics in web
frameworks, particularly validation and page decoration.It shows the user how
to use Tiles or SiteMesh to decorate a web application. It also explains how
the Spring framework handles validation, and shows examples of using it in the
web business layers. Finally, it explains a strategy for handling exceptions in
the controllers, how to upload files and how to send e-mail.
Chapter 6: View Options covers the view options in
Spring’s MVC architecture. At the time of this writing, the options are JSP,
Velocity, FreeMarker, XSLT, PDF and Excel. This chapter aims to become a
reference for configuring all Spring-supported views. It also contains a brief
overview how each view works and compares constructing a page in MyUsers with
each option. Additionally, it focuses on internationalization for each view
option.
Chapter 7: Persistence Strategies. Hibernate is quickly becoming a
popular choice for persistence in Java applications, but sometimes it doesn’t
fit. If you have an existing database schema, or even pre-written SQL, sometimes
it’s better to use JDBC or iBATIS (which supports externalized SQL in XML
files). This chapter refactors the MyUsers application to support both JDBC and
iBATIS as persistence framework options. It also
implements the UserDAO using JDO and OJB to showcase Spring's excellent
support for these frameworks.
Chapter 8: Testing Spring Applications explains how to use test-driven
development to create high-quality, well-tested, Spring-based applications. You
will learn how to test your components using tools like EasyMock, jMock and
DBUnit. For the Controllers, you will learn how to use Cactus for in-container
testing, and Spring Mocks for out-of-container testing. Lastly, you will learn
how to use jWebUnit and Canoo's WebTest for testing the web interface.
Chapter 9: AOP. Aspect Oriented Programming has received a
lot of hype in the Java community in the last year. What is AOP and how can it
help you in your applications? This chapter will cover the basics of AOP and give
some useful examples of how AOP might help you.
Chapter 10: Transactions. Transactions are an important
part of J2EE, allowing you to view several database calls as one and roll them
back if they don’t all succeed. One of the most highlighted features of EJBs is
declarative transactions. This chapter demonstrates how Spring simplifies using
declarative and programmatic transactions.
Chapter 11: Web Framework Integration. Spring has its own web
framework, but it also integrates well with other frameworks. This allows you
to leverage your existing knowledge and still use Spring to manage your
business objects and data layer. This chapter explores Spring integration with
four popular web frameworks: JSF, Struts, Tapestry and WebWork.
Appendix A: Examples and References includes explicit examples of
JSF, Tapestry, and WebWork integration.
方向:分布式系统设计