iii
Spring Bean Life Cycle .................................................................... 30
Initialization callbacks ................................................................................ 30
Destruction callbacks .................................................................................. 31
Example .................................................................................................... 31
Default initialization and destroy methods .................................................... 33
Spring Bean Post Processors .............................................................. 34
Example .................................................................................................... 34
Spring Bean Definition Inheritance ...................................................... 37
Example .................................................................................................... 37
Bean Definition Template ........................................................................... 40
Spring Dependency Injection ............................................................. 41
Constructor-based Dependency Injection ...................................................... 42
Example .................................................................................................... 42
Constructor arguments resolution ................................................................. 44
Setter-based Dependency Injection ............................................................... 45
Example .................................................................................................... 45
XML Configuration using p-namespace ........................................................ 47
Spring Injecting Inner Beans ............................................................. 49
Example .................................................................................................... 49
Spring Injecting Collection ................................................................ 52
Example .................................................................................................... 52
Injecting Bean References ........................................................................... 55
Injecting null and empty string values ........................................................... 56
Spring Beans Auto-Wiring................................................................. 57
Autowiring Modes...................................................................................... 57
Limitations with autowiring......................................................................... 58
Spring Autowiring 'byName' ....................................................................... 58
Spring Autowiring 'byType' ......................................................................... 60
Spring Autowiring by Constructor ............................................................... 63
Spring Annotation Based Configuration ................................................. 66
Spring @Required Annotation ..................................................................... 67
Example .................................................................................................... 67
Spring @Autowired Annotation ................................................................... 69
@Autowired on Setter Methods ................................................................... 69
Example .................................................................................................... 69
@Autowired on Properties .......................................................................... 71
@Autowired on Constructors ...................................................................... 72
@Autowired with (required=false) option ..................................................... 73