Spring - Java/J2EE Application Framework

Reference Documentation

Rod Johnson

Juergen Hoeller

Alef Arendsen

Colin Sampaleanu

Darren Davison

Dmitriy Kopylenko

Thomas Risberg

Mark Pollack

Rob Harrop

Version 1.1.5

Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that each copy contains this Copyright Notice, whether distributed in print or electronically.

(Work in progress)


Table of Contents

Preface
1. Introduction
1.1. Overview
1.2. Usage scenarios
2. Background information
2.1. Inversion of Control / Dependency Injection
3. Beans, BeanFactory and the ApplicationContext
3.1. Introduction
3.2. BeanFactory and BeanDefinitions - the basics
3.2.1. The BeanFactory
3.2.2. The BeanDefinition
3.2.3. The bean class
3.2.3.1. Bean creation via constructor
3.2.3.2. Bean creation via static factory method
3.2.3.3. Bean creation via instance factory method
3.2.4. The bean identifiers (id and name)
3.2.5. To singleton or not to singleton
3.3. Properties, collaborators, autowiring and dependency checking
3.3.1. Setting bean properties and collaborators
3.3.2. Constructor Argument Resolution
3.3.2.1. Constructor Argument Type Matching
3.3.2.2. Constructor Argument Index
3.3.3. Bean properties and constructor arguments detailed
3.3.4. Method Injection
3.3.4.1. Lookup method Injection
3.3.4.2. Arbitrary method replacement
3.3.5. Using depends-on
3.3.6. Autowiring collaborators
3.3.7. Checking for dependencies
3.4. Customizing the nature of a bean
3.4.1. Lifecycle interfaces
3.4.1.1. InitializingBean / init-method
3.4.1.2. DisposableBean / destroy-method
3.4.2. Knowing who you are
3.4.2.1. BeanFactoryAware
3.4.2.2. BeanNameAware
3.4.3. FactoryBean
3.5. Abstract and child bean definitions
3.6. Interacting with the BeanFactory
3.6.1. Obtaining a FactoryBean, not its product
3.7. Customizing beans with BeanPostprocessors
3.8. Customizing bean factories with BeanFactoryPostprocessors
3.8.1. The PropertyPlaceholderConfigurer
3.8.2. The PropertyOverrideConfigurer
3.9. Registering additional custom PropertyEditors
3.10. Introduction to the ApplicationContext
3.11. Added functionality of the ApplicationContext
3.11.1. Using the MessageSource
3.11.2. Propagating events
3.11.3. Using resources within Spring
3.12. Customized behavior in the ApplicationContext
3.12.1. ApplicationContextAware marker interface
3.12.2. The BeanPostProcessor
3.12.3. The BeanFactoryPostProcessor
3.12.4. The PropertyPlaceholderConfigurer
3.13. Registering additional custom PropertyEditors
3.14. Setting a bean property or constructor arg from a property expression
3.15. Setting a bean property or constructor arg from a field value
3.16. Invoking another method and optionally using the return value.
3.17. Importing Bean Definitions from One File Into Another
3.18. Creating an ApplicationContext from a web application
3.19. Glue code and the evil singleton
3.19.1. Using SingletonBeanFactoryLocator and ContextSingletonBeanFactoryLocator
4. PropertyEditors, data binding, validation and the BeanWrapper
4.1. Introduction
4.2. Binding data using the DataBinder
4.3. Bean manipulation and the BeanWrapper
4.3.1. Setting and getting basic and nested properties
4.3.2. Built-in PropertyEditors, converting types
4.3.3. Other features worth mentioning
5. Spring AOP: Aspect Oriented Programming with Spring
5.1. Concepts
5.1.1. AOP concepts
5.1.2. Spring AOP capabilities and goals
5.1.3. AOP Proxies in Spring
5.2. Pointcuts in Spring
5.2.1. Concepts
5.2.2. Operations on pointcuts
5.2.3. Convenience pointcut implementations
5.2.3.1. Static pointcuts
5.2.3.2. Dynamic pointcuts
5.2.4. Pointcut superclasses
5.2.5. Custom pointcuts
5.3. Advice types in Spring
5.3.1. Advice lifecycles
5.3.2. Advice types in Spring
5.3.2.1. Interception around advice
5.3.2.2. Before advice
5.3.2.3. Throws advice
5.3.2.4. After Returning advice
5.3.2.5. Introduction advice
5.4. Advisors in Spring
5.5. Using the ProxyFactoryBean to create AOP proxies
5.5.1. Basics
5.5.2. JavaBean properties
5.5.3. Proxying interfaces
5.5.4. Proxying classes
5.6. Convenient proxy creation
5.6.1. TransactionProxyFactoryBean
5.6.2. EJB proxies
5.7. Concise proxy definitions
5.8. Creating AOP proxies programmatically with the ProxyFactory
5.9. Manipulating advised objects
5.10. Using the "autoproxy" facility
5.10.1. Autoproxy bean definitions
5.10.1.1. BeanNameAutoProxyCreator
5.10.1.2. DefaultAdvisorAutoProxyCreator
5.10.1.3. AbstractAdvisorAutoProxyCreator
5.10.2. Using metadata-driven auto-proxying
5.11. Using TargetSources
5.11.1. Hot swappable target sources
5.11.2. Pooling target sources
5.11.3. Prototype" target sources
5.12. Defining new Advice types
5.13. Further reading and resources
5.14. Roadmap
6. AspectJ Integration
6.1. Overview
6.2. Configuring AspectJ aspects using Spring IoC
6.2.1. "Singleton" aspects
6.2.1.1. Example
6.2.1.2. Ordering issues
6.2.2. Non-singleton aspects
6.2.3. Gotchas
6.3. Using AspectJ pointcuts to target Spring advice
6.4. Spring aspects for AspectJ
7. Transaction management
7.1. The Spring transaction abstraction
7.2. Transaction strategies
7.3. Programmatic transaction management
7.3.1. Using the TransactionTemplate
7.3.2. Using the PlatformTransactionManager
7.4. Declarative transaction management
7.4.1. BeanNameAutoProxyCreator, another declarative approach
7.5. Choosing between programmatic and declarative transaction management
7.6. Do you need an application server for transaction management?
7.7. Common problems
8. Source Level Metadata Support
8.1. Source-level metadata
8.2. Spring's metadata support
8.3. Integration with Jakarta Commons Attributes
8.4. Metadata and Spring AOP autoproxying
8.4.1. Fundamentals
8.4.2. Declarative transaction management
8.4.3. Pooling
8.4.4. Custom metadata
8.5. Using attributes to minimize MVC web tier configuration
8.6. Other uses of metadata attributes
8.7. Adding support for additional metadata APIs
9. DAO support
9.1. Introduction
9.2. Consistent Exception Hierarchy
9.3. Consistent Abstract Classes for DAO Support
10. Data Access using JDBC
10.1. Introduction
10.2. Using the JDBC Core classes to control basic JDBC processing and error handling
10.2.1. JdbcTemplate
10.2.2. DataSource
10.2.3. SQLExceptionTranslator
10.2.4. Executing Statements
10.2.5. Running Queries
10.2.6. Updating the database
10.3. Controlling how we connect to the database
10.3.1. DataSourceUtils
10.3.2. SmartDataSource
10.3.3. AbstractDataSource
10.3.4. SingleConnectionDataSource
10.3.5. DriverManagerDataSource
10.3.6. DataSourceTransactionManager
10.4. Modeling JDBC operations as Java objects
10.4.1. SqlQuery
10.4.2. MappingSqlQuery
10.4.3. SqlUpdate
10.4.4. StoredProcedure
10.4.5. SqlFunction
11. Data Access using O/R Mappers
11.1. Introduction
11.2. Hibernate
11.2.1. Resource Management
11.2.2. Resource Definitions in an Application Context
11.2.3. Inversion of Control: Template and Callback
11.2.4. Applying an AOP Interceptor Instead of a Template
11.2.5. Programmatic Transaction Demarcation
11.2.6. Declarative Transaction Demarcation
11.2.7. Transaction Management Strategies
11.2.8. Container Resources versus Local Resources
11.2.9. Samples
11.3. JDO
11.4. iBATIS
11.4.1. Overview and differences between 1.3.x and 2.0
11.4.2. Setting up the SqlMap
11.4.3. Using SqlMapDaoSupport
11.4.4. Transaction management
12. Web framework
12.1. Introduction to the web framework
12.1.1. Pluggability of MVC implementation
12.1.2. Features of Spring MVC
12.2. The DispatcherServlet
12.3. Controllers
12.3.1. AbstractController and WebContentGenerator
12.3.2. Other simple controllers
12.3.3. The MultiActionController
12.3.4. CommandControllers
12.4. Handler mappings
12.4.1. BeanNameUrlHandlerMapping
12.4.2. SimpleUrlHandlerMapping
12.4.3. Adding HandlerInterceptors
12.5. Views and resolving them
12.5.1. ViewResolvers
12.5.2. Chaining ViewResolvers
12.6. Using locales
12.6.1. AcceptHeaderLocaleResolver
12.6.2. CookieLocaleResolver
12.6.3. SessionLocaleResolver
12.6.4. LocaleChangeInterceptor
12.7. Using themes
12.8. Spring's multipart (fileupload) support
12.8.1. Introduction
12.8.2. Using the MultipartResolver
12.8.3. Handling a fileupload in a form
12.9. Handling exceptions
13. Integrating view technologies
13.1. Introduction
13.2. JSP & JSTL
13.2.1. View resolvers
13.2.2. 'Plain-old' JSPs versus JSTL
13.2.3. Additional tags facilitating development
13.3. Tiles
13.3.1. Dependencies
13.3.2. How to integrate Tiles
13.3.2.1. InternalResourceViewResolver
13.3.2.2. ResourceBundleViewResolver
13.4. Velocity & FreeMarker
13.4.1. Dependencies
13.4.2. Context configuration
13.4.3. Creating templates
13.4.4. Advanced configuration
13.4.4.1. velocity.properties
13.4.4.2. FreeMarker
13.4.5. Bind support and form handling
13.4.5.1. the bind macros
13.4.5.2. simple binding
13.4.5.3. form input generation macros
13.4.5.4. overriding HTML escaping and making tags XHTML compliant
13.5. XSLT
13.5.1. My First Words
13.5.1.1. Bean definitions
13.5.1.2. Standard MVC controller code
13.5.1.3. Convert the model data to XML
13.5.1.4. Defining the view properties
13.5.1.5. Document transformation
13.5.2. Summary
13.6. Document views (PDF/Excel)
13.6.1. Introduction
13.6.2. Configuration and setup
13.6.2.1. Document view definitions
13.6.2.2. Controller code
13.6.2.3. Subclassing for Excel views
13.6.2.4. Subclassing for PDF views
13.7. JasperReports
13.7.1. Dependencies
13.7.2. Configuration
13.7.2.1. Configuring the ViewResolver
13.7.2.2. Configuring the Views
13.7.2.3. About Report Files
13.7.2.4. Using JasperReportsMultiFormatView
13.7.3. Populating the ModelAndView
13.7.4. Working with Sub-Reports
13.7.4.1. Configuring Sub-Report Files
13.7.4.2. Configuring Sub-Report Data Sources
13.7.5. Configuring Exporter Parameters
14. Integrating with other web frameworks
14.1. Introduction
14.2. JavaServer Faces
14.2.1. DelegatingVariableResolver
14.2.2. FacesContextUtils
14.3. Struts
14.3.1. ContextLoaderPlugin
14.3.1.1. DelegatingRequestProcessor
14.3.1.2. DelegatingActionProxy
14.3.2. ActionSupport Classes
14.4. Tapestry
14.4.1. Architecture
14.4.2. Implementation
14.4.2.1. Sample application context
14.4.2.2. Obtaining beans in Tapestry pages
14.4.2.3. Exposing the application context to Tapestry
14.4.2.4. Component definition files
14.4.2.5. Adding abstract accessors
14.4.3. Summary
14.5. WebWork
15. JMS
15.1. Introduction
15.2. Domain unification
15.3. JmsTemplate
15.3.1. ConnectionFactory
15.3.2. Transaction Management
15.3.3. Destination Management
15.4. Using the JmsTemplate
15.4.1. Sending a message
15.4.2. Synchronous Receiving
15.4.3. Using Message Converters
15.4.4. SessionCallback and ProducerCallback
16. Accessing and implementing EJBs
16.1. Accessing EJBs
16.1.1. Concepts
16.1.2. Accessing local SLSBs
16.1.3. Accessing remote SLSBs
16.2. Using Spring convenience EJB implementation classes
17. Remoting and web services using Spring
17.1. Introduction
17.2. Exposing services using RMI
17.2.1. Exporting the service using the RmiServiceExporter
17.2.2. Linking in the service at the client
17.3. Using Hessian or Burlap to remotely call services via HTTP
17.3.1. Wiring up the DispatcherServlet for Hessian
17.3.2. Exposing your beans by using the HessianServiceExporter
17.3.3. Linking in the service on the client
17.3.4. Using Burlap
17.3.5. Applying HTTP basic authentication to a service exposed through Hessian or Burlap
17.4. Exposing services using HTTP invokers
17.4.1. Exposing the service object
17.4.2. Linking in the service at the client
17.5. Web Services
17.5.1. Exposing services using JAX-RPC
17.5.2. Accessing Web Services
17.5.3. Register Bean Mappings
17.5.4. Registering our own Handler
17.6. Auto-detection is not implemented for remote interfaces
17.7. Considerations when choosing a technology
18. Sending Email with Spring mail abstraction layer
18.1. Introduction
18.2. Spring mail abstraction structure
18.3. Using Spring mail abstraction
18.3.1. Pluggable MailSender implementations
18.4. Using the JavaMail MimeMessageHelper
18.4.1. Creating a simple MimeMessage and sending it
18.4.2. Sending attachments and inline resources
19. Scheduling jobs using Quartz or Timer
19.1. Introduction
19.2. Using the OpenSymphony Quartz Scheduler
19.2.1. Using the JobDetailBean
19.2.2. Using the MethodInvokingJobDetailFactoryBean
19.2.3. Wiring up jobs using triggers and the SchedulerFactoryBean
19.3. Using JDK Timer support
19.3.1. Creating custom timers
19.3.2. Using the MethodInvokingTimerTaskFactoryBean
19.3.3. Wrapping up: setting up the tasks using the TimerFactoryBean
20. Testing
20.1. Unit testing
20.2. Integration testing
20.2.1. Context management and caching
20.2.2. Dependency Injection of test class instances
20.2.3. Transaction management
20.2.4. Convenience variables
20.2.5. Example
20.2.6. Running integration tests
A. Spring's beans.dtd