Spring in Action
Craig Walls and Ryan Breidenbach
  • February 2005
  • ISBN 9781932394351
  • 472 pages

… a great way of explaining Spring topics… I enjoyed the entire book.

Christian Parker, President Adigio Inc.

Spring in Action introduces you to the ideas behind Spring and then quickly launches into a hands-on exploration of the framework. Combining short code snippets and an ongoing example developed throughout the book, it shows you how to build simple and efficient J2EE applications. You will see how to solve persistence problems using the leading open-source tools, and also how to integrate your application with the most popular web frameworks. You will learn how to use Spring to manage the bulk of your infrastructure code so you can focus on what really matters — your critical business needs.

About the Technology

Spring is a fresh breeze blowing over the Java landscape. Based on a design principle called Inversion of Control, Spring is a powerful but lightweight J2EE framework that does not require the use of EJBs. Spring greatly reduces the complexity of using interfaces, and speeds and simplifies your application development. You get the power and robust features of EJB and get to keep the simplicity of the non-enterprise JavaBean.

Table of Contents detailed table of contents



about this book

Part 1 Spring essentials

1. A Spring jump start

1.1. Why Spring?

1.1.1. A day in the life of a J2EE developer

1.1.2. Spring’s pledge

1.2. What is Spring?

1.2.1. Spring modules

1.3. Spring jump start

1.4. Understanding inversion of control

1.4.1. Injecting dependencies

1.4.2. IoC in action

1.4.3. IoC in enterprise applications

1.5. Applying aspect-oriented programming

1.5.1. Introducing AOP

1.5.2. AOP in action

1.5.3. AOP in the enterprise

1.6. Spring alternatives

1.6.1. Comparing Spring to EJB

1.6.2. Considering other lightweight containers

1.6.3. Web frameworks

1.6.4. Persistence frameworks

1.7. Summary

2. Wiring beans

2.1. Containing your beans

2.1.1. Introducing the BeanFactory

2.1.2. Working with an application context

2.1.3. A bean’s life

2.2. Basic wiring

2.2.1. Wiring with XML

2.2.2. Adding a bean

2.2.3. Injecting dependencies via setter methods

2.2.4. Injecting dependencies via constructor

2.3. Autowiring

2.3.1. Handling ambiguities of autowiring

2.3.2. Mixing auto and explicit wiring

2.3.3. Autowiring by default

2.3.4. To autowire or not to autowire

2.4. Working with Spring’s special beans

2.4.1. Postprocessing beans

2.4.2. Postprocessing the bean factory

2.4.3. Externalizing the configuration

2.4.4. Customizing property editors

2.4.5. Resolving text messages

2.4.6. Listening for events

2.4.7. Publishing events

2.4.8. Making beans aware

2.5. Summary

3. Creating aspects

3.1. Introducing AOP

3.1.1. Defining AOP terminology

3.1.2. Spring’s AOP implementation

3.2. Creating advice

3.2.1. Before advice

3.2.2. After advice

3.2.3. Around advice

3.2.4. Throws advice

3.2.5. Introduction advice

3.3. Defining pointcuts

3.3.1. Defining a pointcut in Spring

3.3.2. Understanding advisors

3.3.3. Using Spring’s static pointcuts

3.3.4. Using dynamic pointcuts

3.3.5. Pointcut operations

3.4. Creating introductions

3.4.1. Implementing IntroductionInterceptor

3.4.2. Creating an IntroductionAdvisor

3.4.3. Using introduction advice carefully

3.5. Using ProxyFactoryBean

3.6. Autoproxying

3.6.1. BeanNameAutoProxyCreator

3.6.2. DefaultAdvisorAutoProxy-Creator

3.6.3. Metadata autoproxying

3.7. Summary

Part 2 Spring in the business layer

4. Hitting the database

4.1. Learning Spring’s DAO philosophy

4.1.1. Understanding Spring’s DataAccessException

4.1.2. Working with DataSources

4.1.3. Consistent DAO support

4.2. Using JDBC with Spring

4.2.1. The problem with JDBC code

4.2.2. Using JdbcTemplate

4.2.3. Creating operations as objects

4.2.4. Auto-incrementing keys

4.3. Introducing Spring’s ORM framework support

4.4. Integrating Hibernate with Spring

4.4.1. Hibernate overview

4.4.2. Managing Hibernate resources

4.4.3. Accessing Hibernate through HibernateTemplate

4.4.4. Subclassing HibernateDaoSupport

4.5. Spring and JDO

4.5.1. Configuring JDO

4.5.2. Accessing data with JdoTemplate

4.6. Spring and iBATIS

4.6.1. Setting up SQL Maps

4.6.2. Using SqlMapClientTemplate

4.7. Spring and OJB

4.7.1. Setting up OJB’s PersistenceBroker

4.8. Summary

5. Managing transactions

5.1. Understanding transactions

5.1.1. Explaining transactions in only four words

5.1.2. Understanding Spring’s transaction management support

5.1.3. Introducing Spring’s transaction manager

5.2. Programming transactions in Spring

5.3. Declaring transactions

5.3.1. Understanding transaction attributes

5.3.2. Declaring a simple transaction policy

5.4. Declaring transactions by method name

5.4.1. Using NameMatchTransactionAttributeSource

5.4.2. Shortcutting name-matched transactions

5.5. Declaring transactions with metadata

5.5.1. Sourcing transaction attributes from metadata

5.5.2. Declaring transactions with Commons Attributes

5.6. Trimming down transaction declarations

5.6.1. Inheriting from a parent TransactionProxyFactoryBean

5.6.2. Autoproxying transactions

5.7. Summary

6. Remoting

6.1. Spring remoting overview

6.2. Working with RMI

6.2.1. Wiring RMI services

6.2.2. Exporting RMI services

6.3. Remoting with Hessian and Burlap

6.3.1. Accessing Hessian/Burlap services

6.3.2. Exposing bean functionality with Hessian/Burlap

6.4. Using Http invoker

6.4.1. Accessing services via HTTP

6.4.2. Exposing beans as HTTP Services

6.5. Working with EJBs

6.5.1. Accessing EJBs

6.5.2. Developing Spring-enabled EJBs

6.6. Using JAX-RPC web services

6.6.1. Referencing a web service with JAX-RPC

6.6.2. Wiring a web service in Spring

6.7. Summary

7. Accessing enterprise services

7.1. Retrieving objects from JNDI

7.1.1. Working with conventional JNDI

7.1.2. Proxying JNDI objects

7.2. Sending e-mail

7.3. Scheduling tasks

7.3.1. Scheduling with Java’s Timer

7.3.2. Using the Quartz scheduler

7.3.3. Invoking methods on a schedule

7.4. Sending messages with JMS

7.4.1. Sending messages with JMS templates

7.4.2. Consuming messages

7.4.3. Converting messages

7.5. Summary

Part 3 Spring in the web layer

8. Building the web layer

8.1. Getting started with Spring MVC

8.1.1. A day in the life of a request

8.1.2. Configuring DispatcherServlet

8.1.3. Spring MVC in a nutshell

8.2. Mapping requests to controllers

8.2.1. Mapping URLs to bean names

8.2.2. Using SimpleUrlHandlerMapping

8.2.3. Using metadata to map controllers

8.2.4. Working with multiple handler mappings

8.3. Handling requests with controllers

8.3.1. Writing a simple controller

8.3.2. Processing commands

8.3.3. Processing form submissions

8.3.4. Processing complex forms with wizards

8.3.5. Handling multiple actions in one controller

8.3.6. Working with Throwaway controllers

8.4. Resolving views

8.4.1. Using template views

8.4.2. Resolving view beans

8.4.3. Choosing a view resolver

8.5. Using Spring’s bind tag

8.6. Handling exceptions

8.7. Summary

9. View layer alternatives

9.1. Using Velocity templates

9.1.1. Defining the Velocity view

9.1.2. Configuring the Velocity engine

9.1.3. Resolving Velocity views

9.1.4. Formatting dates and numbers

9.1.5. Exposing request and session attributes

9.1.6. Binding form fields in Velocity

9.2. Working with FreeMarker

9.2.1. Constructing a FreeMarker view

9.2.2. Configuring the FreeMarker engine

9.2.3. Resolving FreeMarker views

9.2.4. Binding form fields in FreeMarker

9.3. Designing page layout with Tiles

9.3.1. Tile views

9.3.2. Tile controllers

9.4. Generating non-HTML output

9.4.1. Producing Excel spreadsheets

9.4.2. Generating PDF documents

9.4.3. Generating other non-HTML files

9.5. Summary

10. Working with other web frameworks

10.1. Working with Jakarta Struts

10.1.1. Registering the Spring plug-in

10.1.2. Implementing Spring-aware Struts actions

10.1.3. Delegating actions

10.2. Working with Tapestry

10.2.1. Replacing the Tapestry Engine

10.2.2. Loading Spring beans into Tapestry pages

10.3. Integrating with JavaServer Faces

10.3.1. Resolving variables

10.3.2. Publishing request handled events

10.4. Integrating with WebWork

10.4.1. WebWork 1

10.4.2. XWork/WebWork2

10.5. Summary

11. Securing Spring applications

11.1. Introducing the Acegi Security System

11.1.1. Security interceptors

11.1.2. Authentication managers

11.1.3. Access decisions managers

11.1.4. Run-as managers

11.2. Managing authentication

11.2.1. Configuring a provider manager

11.2.2. Authenticating against a database

11.2.3. Authenticating against an LDAP repository

11.2.4. Enabling Single Sign-On with Acegi and Yale CAS

11.3. Controlling access

11.3.1. Voting access decisions

11.3.2. Deciding how to vote

11.3.3. Handling voter abstinence

11.4. Securing web applications

11.4.1. Proxying Acegi’s filters

11.4.2. Enforcing web security

11.4.3. Processing a login

11.4.4. Setting up the security context

11.4.5. Ensuring a secure channel

11.4.6. Using the Acegi tag library

11.5. Securing method invocations

11.5.1. Creating a security aspect

11.5.2. Securing methods using metadata

11.6. Summary


Appendix A: Spring setup

A.1. Downloading Spring

A.2. Choosing a distribution

A.3. Setting up your project

A.4. Building with Ant

Appendix B: Spring-related projects

B.1. AppFuse

B.2. Rich Client Project

B.3. Spring.NET


What's inside

  • Persistence using Hibernate, JDO, iBatis, OJB, and JDBC
  • Declarative transactions and transaction management
  • Integration with web frameworks: Struts, WebWork, Tapestry, Velocity
  • Accessing J2EE services such as JMS and EJB
  • Addressing cross-cutting concerns with AOP
  • Enterprise applications best practices

About the authors

Craig Walls is a software developer with over 10 years' experience and co-author of XDoclet in Action. He has sucessfully implemented a number of Spring applications. Craig lives in Denton, Texas. An avid supporter of open source Java technologies, Ryan Breidenbach has been developing Java web applications for the past five years. He lives in Coppell, Texas.

placing your order...

Don't refresh or navigate away from the page.
customers also reading

This book 1-hop 2-hops 3-hops

FREE domestic shipping on three or more pBooks