Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
2Activity
0 of .
Results for:
No results containing your search query
P. 1
Spring Reference

Spring Reference

Ratings: (0)|Views: 11|Likes:
Published by api-3748459

More info:

Published by: api-3748459 on Oct 15, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/18/2014

pdf

text

original

2.0.5

Copyright \u00a9 2004-2007 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,
Rick Evans

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................................................................................................................................................ xiv
1. Introduction..................................................................................................................................15
1.1. Overview............................................................................................................................. 15
1.2. Usage scenarios.................................................................................................................... 17
2. What's new in Spring 2.0?.............................................................................................................20
2.1. Introduction......................................................................................................................... 20

2.2. The Inversion of Control (IoC) container............................................................................... 20
2.2.1. Easier XML configuration.......................................................................................... 20
2.2.2. New bean scopes....................................................................................................... 20
2.2.3. Extensible XML authoring......................................................................................... 21
2.3. Aspect Oriented Programming (AOP).................................................................................... 21
2.3.1. Easier AOP XML configuration................................................................................. 21
2.3.2. Support for @AspectJ aspects.................................................................................... 21
2.4. The Middle Tier................................................................................................................... 21
2.4.1. Easier configuration of declarative transactions in XML.............................................. 22

2.4.2. JPA.......................................................................................................................... 22 2.4.3. Asynchronous JMS.................................................................................................... 22 2.4.4. JDBC........................................................................................................................ 22

2.5. The Web Tier....................................................................................................................... 22 2.5.1. A form tag library for Spring MVC............................................................................. 22 2.5.2. Sensible defaulting in Spring MVC............................................................................. 23 2.5.3. Portlet framework...................................................................................................... 23

2.6. Everything else.................................................................................................................... 23 2.6.1. Dynamic language support......................................................................................... 23 2.6.2. JMX......................................................................................................................... 23 2.6.3. Task scheduling......................................................................................................... 23 2.6.4. Java 5 (Tiger) support................................................................................................ 23

2.7. Migrating to Spring 2.0......................................................................................................... 24

2.7.1. Changes.................................................................................................................... 24 2.8. Updated sample applications................................................................................................. 25 2.9. Improved documentation...................................................................................................... 25

I. Core Technologies........................................................................................................................... 27
3. The IoC container.................................................................................................................28
3.1. Introduction................................................................................................................. 28

3.2. Basics - containers and beans........................................................................................ 28 3.2.1. The container.................................................................................................... 28 3.2.2. Instantiating a container..................................................................................... 30 3.2.3. The beans.......................................................................................................... 31 3.2.4. Using the container............................................................................................ 35

3.3. Dependencies............................................................................................................... 36 3.3.1. Injecting dependencies....................................................................................... 36 3.3.2. Constructor Argument Resolution....................................................................... 40 3.3.3. Bean properties and constructor arguments detailed............................................. 42 3.3.4. Usingdepends-on............................................................................................. 50 3.3.5. Lazily-instantiated beans.................................................................................... 51 3.3.6. Autowiring collaborators.................................................................................... 51 3.3.7. Checking for dependencies................................................................................. 53 3.3.8. Method Injection............................................................................................... 54

3.4. Bean scopes................................................................................................................. 57 3.4.1. The singleton scope........................................................................................... 57 3.4.2. The prototype scope........................................................................................... 58 3.4.3. The other scopes................................................................................................ 60

Spring Framework (2.0.5)
ii
3.4.4. Custom scopes.................................................................................................. 63
3.5. Customizing the nature of a bean................................................................................... 65
3.5.1. Lifecycle interfaces........................................................................................... 65

3.5.2. Knowing who you are........................................................................................ 69
3.6. Bean definition inheritance........................................................................................... 70
3.7. Container extension points............................................................................................ 72
3.7.1. Customizing beans usingBeanPostProcessors................................................... 72
3.7.2. Customizing configuration metadata withBeanFactoryPostProcessors............... 74
3.7.3. Customizing instantiation logic usingFactoryBeans............................................ 77

3.8. TheApplicationContext............................................................................................. 78 3.8.1. Internationalization usingMessageSources......................................................... 78 3.8.2. Events............................................................................................................... 81 3.8.3. Convenient access to low-level resources............................................................ 82 3.8.4. ConvenientApplicationContext instantiation for web applications..................... 83

3.9. Glue code and the evil singleton.................................................................................... 84
3.9.1. Using the Singleton-helper classes...................................................................... 84
4. Resources..............................................................................................................................85
4.1. Introduction................................................................................................................. 85
4.2. TheResource interface................................................................................................. 85

4.3. Built-inResource implementations............................................................................... 86 4.3.1.UrlResource..................................................................................................... 86 4.3.2.ClassPathResource........................................................................................... 86 4.3.3.FileSystemResource......................................................................................... 87 4.3.4.ServletContextResource.................................................................................. 87 4.3.5.InputStreamResource....................................................................................... 87 4.3.6.ByteArrayResource........................................................................................... 87

4.4. TheResourceLoader.................................................................................................... 87
4.5. TheResourceLoaderAware interface............................................................................. 88

4.6.Resources as dependencies........................................................................................... 89
4.7. Application contexts andResource paths....................................................................... 89
4.7.1. Constructing application contexts....................................................................... 89
4.7.2. Wildcards in application context constructor resource paths................................. 90
4.7.3.FileSystemResource caveats............................................................................. 92

5. Validation, Data-binding, theBeanWrapper, andPropertyEditors.........................................94
5.1. Introduction................................................................................................................. 94

5.2. Validation using Spring'sValidator interface................................................................ 94
5.3. Resolving codes to error messages................................................................................. 96
5.4. Bean manipulation and theBeanWrapper........................................................................ 96
5.4.1. Setting and getting basic and nested properties.................................................... 96
5.4.2. Built-in PropertyEditor implementations............................................................. 98

6. Aspect Oriented Programming with Spring..........................................................................102

6.1. Introduction................................................................................................................. 102 6.1.1. AOP concepts................................................................................................... 102 6.1.2. Spring AOP capabilities and goals...................................................................... 104 6.1.3. AOP Proxies..................................................................................................... 105

6.2. @AspectJ support........................................................................................................ 105 6.2.1. Enabling @AspectJ Support............................................................................... 105 6.2.2. Declaring an aspect............................................................................................ 106 6.2.3. Declaring a pointcut........................................................................................... 106 6.2.4. Declaring advice................................................................................................ 111 6.2.5. Introductions..................................................................................................... 117 6.2.6. Aspect instantiation models................................................................................ 118

The Spring Framework - Reference Documentation
Spring Framework (2.0.5)
iii

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->