Spring Framework Reference Documentation
4.3.1.BUILD-SNAPSHOT Spring Framework v
Singleton beans with prototype-bean dependencies ............................................ 69
Request, session, global session, application, and WebSocket scopes ................. 70
Initial web configuration ............................................................................ 70
Request scope ......................................................................................... 71
Session scope .......................................................................................... 71
Global session scope ............................................................................... 71
Application scope ..................................................................................... 72
Scoped beans as dependencies ................................................................ 72
Custom scopes ................................................................................................ 74
Creating a custom scope .......................................................................... 74
Using a custom scope .............................................................................. 75
7.6. Customizing the nature of a bean ....................................................................... 76
Lifecycle callbacks ............................................................................................ 76
Initialization callbacks ............................................................................... 77
Destruction callbacks ................................................................................ 77
Default initialization and destroy methods .................................................. 78
Combining lifecycle mechanisms ............................................................... 79
Startup and shutdown callbacks ................................................................ 80
Shutting down the Spring IoC container gracefully in non-web applications
................................................................................................................. 82
ApplicationContextAware and BeanNameAware ................................................. 82
Other Aware interfaces ..................................................................................... 83
7.7. Bean definition inheritance ................................................................................. 84
7.8. Container Extension Points ................................................................................ 86
Customizing beans using a BeanPostProcessor ................................................. 86
Example: Hello World, BeanPostProcessor-style ........................................ 87
Example: The RequiredAnnotationBeanPostProcessor ............................... 89
Customizing configuration metadata with a BeanFactoryPostProcessor ................ 89
Example: the Class name substitution PropertyPlaceholderConfigurer .......... 90
Example: the PropertyOverrideConfigurer .................................................. 91
Customizing instantiation logic with a FactoryBean ............................................. 92
7.9. Annotation-based container configuration ............................................................ 92
@Required ....................................................................................................... 94
@Autowired ..................................................................................................... 94
Fine-tuning annotation-based autowiring with @Primary ..................................... 97
Fine-tuning annotation-based autowiring with qualifiers ....................................... 98
Using generics as autowiring qualifiers ............................................................ 103
CustomAutowireConfigurer .............................................................................. 104
@Resource .................................................................................................... 104
@PostConstruct and @PreDestroy .................................................................. 106
7.10. Classpath scanning and managed components ................................................ 106
@Component and further stereotype annotations ............................................. 106
Meta-annotations ............................................................................................ 107
Automatically detecting classes and registering bean definitions ........................ 108
Using filters to customize scanning .................................................................. 109
Defining bean metadata within components ..................................................... 110
Naming autodetected components ................................................................... 112
Providing a scope for autodetected components ............................................... 113
Providing qualifier metadata with annotations ................................................... 114
7.11. Using JSR 330 Standard Annotations ............................................................. 115