Spring Reference
Spring Reference
Version 2.5.6
Copyright © 2004-2008 Rod Johnson, Juergen Hoeller, Alef Arendsen, Colin Sampaleanu,
Rob Harrop, Thomas Risberg, Darren Davison, Dmitriy Kopylenko, Mark Pollack, Thierry
Templier, Erwin Vervaet, Portia Tung, Ben Hale, Adrian Colyer, John Lewis, Costin Leau,
Mark Fisher, Sam Brannen, Ramnivas Laddad, Arjen Poutsma
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.
Preface.............................................................................................................................................. .x. v
1.Introduction .................................................................................................................................. .16
1.1.Overview............................................................................................................................. .16
1.2.Usagescenarios ................................................................................................................... .18
2. What's new in Spring 2.0 and 2.5? ................................................................................................. 21
2.1.Introduction ......................................................................................................................... .21
2.2. The Inversion of Control (IoC) container ................................................................................ 21
2.2.1. New bean scopes ........................................................................................................21
2.2.2. Easier XML configuration ...........................................................................................22
2.2.3. Extensible XML authoring ..........................................................................................22
2.2.4.Annotation-drivenconfiguration ..................................................................................22
2.2.5. Autodetecting components in the classpath .................................................................. 22
2.3. Aspect Oriented Programming (AOP) .................................................................................... 23
2.3.1. Easier AOP XML configuration .................................................................................. 23
2.3.2. Support for @AspectJ aspects ..................................................................................... 23
2.3.3. Support for bean name pointcut element ...................................................................... 23
2.3.4. Support for AspectJ load-time weaving ........................................................................ 23
2.4. The Middle Tier ................................................................................................................... .23
2.4.1. Easier configuration of declarative transactions in XML ............................................... 23
2.4.2. Full WebSphere transaction management support ......................................................... 24
2.4.3.JPA .......................................................................................................................... .24
2.4.4.AsynchronousJMS .....................................................................................................24
2.4.5.JDBC ....................................................................................................................... .24
2.5. The Web Tier ....................................................................................................................... .25
2.5.1. Sensible defaulting in Spring MVC ............................................................................. 25
2.5.2.Portletframework .......................................................................................................25
2.5.3.Annotation-basedcontrollers .......................................................................................25
2.5.4. A form tag library for Spring MVC ............................................................................. 25
2.5.5. Tiles 2 support ...........................................................................................................25
2.5.6. JSF 1.2 support ..........................................................................................................26
2.5.7.JAX-WSsupport ........................................................................................................26
2.6.Everythingelse .................................................................................................................... .26
2.6.1. Dynamic language support ..........................................................................................26
2.6.2. Enhanced testing support ............................................................................................26
2.6.3.JMXsupport ............................................................................................................. .26
2.6.4. Deploying a Spring application context as JCA adapter ................................................. 27
2.6.5.Taskscheduling .........................................................................................................27
2.6.6. Java 5 (Tiger) support ................................................................................................. 27
2.7. Migrating to Spring 2.5 .......................................................................................................... 27
2.7.1.Changes .................................................................................................................... .28
2.8. Updated sample applications ..................................................................................................30
2.9.Improveddocumentation .......................................................................................................30
I.CoreTechnologies ........................................................................................................................... .31
3. The IoC container ................................................................................................................. .32
3.1.Introduction ................................................................................................................. .32
3.2. Basics - containers and beans ......................................................................................... 32
3.2.1.Thecontainer .....................................................................................................33
3.2.2. Instantiating a container ......................................................................................34
3.2.3.Thebeans ..........................................................................................................35
3.2.4. Using the container .............................................................................................39
3.3.Dependencies............................................................................................................... .40
3.3.1.Injectingdependencies ........................................................................................40