0% found this document useful (0 votes)
54 views

Spring Reference

Spring framework - reference document may be copied for your own use and distribution to others. Spring framework 2.5 introduces The Inversion of Control (ioc) container. New bean scopes, Easier XML configuration and annotation-driven configuration.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Spring Reference

Spring framework - reference document may be copied for your own use and distribution to others. Spring framework 2.5 introduces The Inversion of Control (ioc) container. New bean scopes, Easier XML configuration and annotation-driven configuration.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

The Spring Framework - Reference Documentation

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

Spring Framework (2.5.6) ii


The Spring Framework - Reference Documentation

3.3.2. Dependencies and configuration in detail ............................................................. 45


3.3.3.Using depends-on ..............................................................................................54
3.3.4.Lazily-instantiatedbeans .....................................................................................54
3.3.5.Autowiringcollaborators ....................................................................................55
3.3.6. Checking for dependencies ..................................................................................57
3.3.7.MethodInjection ................................................................................................58
3.4.Beanscopes ................................................................................................................. .61
3.4.1. The singleton scope ............................................................................................62
3.4.2. The prototype scope ...........................................................................................63
3.4.3. Singleton beans with prototype-bean dependencies ............................................... 64
3.4.4. The other scopes .................................................................................................64
3.4.5.Customscopes ...................................................................................................68
3.5. Customizing the nature of a bean .................................................................................... 70
3.5.1.Lifecyclecallbacks .............................................................................................70
3.5.2. Knowing who you are ......................................................................................... 74
3.6. Bean definition inheritance ............................................................................................76
3.7. Container extension points .............................................................................................77
3.7.1. Customizing beans using BeanPostProcessors .................................................... 78
3.7.2. Customizing configuration metadata with BeanFactoryPostProcessors ............... 80
3.7.3. Customizing instantiation logic using FactoryBeans ............................................ 83
3.8.The ApplicationContext ..............................................................................................84
3.8.1. BeanFactory or ApplicationContext? ................................................................84
3.8.2. Internationalization using MessageSources ..........................................................85
3.8.3.Events .............................................................................................................. .88
3.8.4. Convenient access to low-level resources ............................................................. 89
3.8.5. Convenient ApplicationContext instantiation for web applications ...................... 90
3.9. Glue code and the evil singleton ..................................................................................... 91
3.10. Deploying a Spring ApplicationContext as a J2EE RAR file .......................................... 91
3.11.Annotation-basedconfiguration ....................................................................................92
3.11.1.@Required ........................................................................................................93
3.11.2.@Autowired ......................................................................................................93
3.11.3. Fine-tuning annotation-based autowiring with qualifiers ..................................... 95
3.11.4.CustomAutowireConfigurer .............................................................................99
3.11.5.@Resource ........................................................................................................100
3.11.6. @PostConstruct and @PreDestroy ....................................................................101
3.12. Classpath scanning for managed components ................................................................ 102
3.12.1. @Component and further stereotype annotations ................................................... 102
3.12.2.Auto-detectingcomponents ...............................................................................102
3.12.3. Using filters to customize scanning .................................................................... 103
3.12.4. Naming autodetected components ......................................................................104
3.12.5. Providing a scope for autodetected components .................................................. 105
3.12.6. Providing qualifier metadata with annotations .................................................... 105
3.13. Registering a LoadTimeWeaver .....................................................................................106
4.Resources .............................................................................................................................. .107
4.1.Introduction ................................................................................................................. .107
4.2. The Resource interface ..................................................................................................107
4.3. Built-in Resource implementations ................................................................................108
4.3.1.UrlResource ......................................................................................................108
4.3.2.ClassPathResource ...........................................................................................108
4.3.3.FileSystemResource ..........................................................................................109
4.3.4.ServletContextResource ...................................................................................109
4.3.5.InputStreamResource ........................................................................................109

Spring Framework (2.5.6) iii

You might also like