Spring Framework Documentation (5.3.10)
Core | IoC Container, Events, Resources, i18n, Validation, Data Binding, Type Conversion, SpEL, AOP. |
1. The IoC Container
1.1. Introduction to the Spring IoC Container and Beans(Spring IoC容器和bean简介)
1.2. Container Overview (容器概览)
1.6. Customizing the Nature of a Bean (自定义bean的性质)
1.6.1. Lifecycle Callbacks 生命周期回调
1.6.1.1. Initialization Callbacks 初始化回调
1.6.1.2. Destruction Callbacks 销毁回调
1.6.1.3. Default Initialization and Destroy Methods默认初始化和销毁方法
1.6.1.4. Combining Lifecycle Mechanisms (合并生命周期机制)
1.6.1.5. Startup and Shutdown Callbacks 启动和停止回调
1.6.1.6. Shutting Down the Spring IoC Container Gracefully in Non-Web Applications 在非web应用程序优雅地关闭Spr
1.6.2. ApplicationContextAware and BeanNameAware
1.6.3. Other Aware Interfaces 其它Aware接口
1.7. Bean Definition Inheritance(Bean定义继承)
1.8. Container Extension Points (容器扩展点)
下载此文档精编完整版
No. | 内容 | 下载地址 | 文档内容目录 |
1 | 中英双语精编版 第一部分 | PDF下载 | 内容目录 |
2 | 中英双语精编版 第二部分 | PDF下载 | 内容目录 |
3 | 中文精编版 第一部分 | PDF下载 | 内容目录 |
4 | 中文精编版 第二部分 | PDF下载 | 内容目录 |
更多章节内容,请点击查看: Core Technologies
1.6.3. Other Aware Interfaces 其它Aware接口
Besides ApplicationContextAware and BeanNameAware (discussed earlier), Spring offers a wide range of Aware callback interfaces that let beans indicate to the container that they require a certain infrastructure dependency. As a general rule, the name indicates the dependency type. The following table summarizes the most important Aware interfaces:
除了ApplicationContextAware 和BeanNameAware (前面讨论过)之外,Spring还提供了广泛的Aware回调接口,让bean向容器指示它们需要特定基础设施依赖项。一般来说,名称表示依赖项类型。下表总结了最重要的Aware接口:
Table 4. Aware interfaces | ||
Name | Injected Dependency | Explained in… |
ApplicationContextAware | Declaring ApplicationContext. | |
ApplicationEventPublisherAware | Event publisher of the enclosing ApplicationContext. | |
BeanClassLoaderAware | Class loader used to load the bean classes. | |
BeanFactoryAware | Declaring BeanFactory. | |
BeanNameAware | Name of the declaring bean. | |
LoadTimeWeaverAware | Defined weaver for processing class definition at load time. | |
MessageSourceAware | Configured strategy for resolving messages (with support for parametrization and internationalization). | |
NotificationPublisherAware | Spring JMX notification publisher. | |
ResourceLoaderAware | Configured loader for low-level access to resources. | |
ServletConfigAware | Current ServletConfig the container runs in. Valid only in a web-aware Spring ApplicationContext. | |
ServletContextAware | Current ServletContext the container runs in. Valid only in a web-aware Spring ApplicationContext. |
Note again that using these interfaces ties your code to the Spring API and does not follow the Inversion of Control style. As a result, we recommend them for infrastructure beans that require programmatic access to the container.
Table 4. Aware 接口 | ||
Name | 注入的依赖 | 解释 |
ApplicationContextAware | 声明ApplicationContext。 | |
ApplicationEventPublisherAware | 包含的ApplicationContext的事件发布者。 | |
BeanClassLoaderAware | 用于加载bean类的类装入器。 | |
BeanFactoryAware | 声明BeanFactory。 | |
BeanNameAware | 声明bean的名称。 | |
LoadTimeWeaverAware | 已定义用于在加载时处理类定义的织入器。 | |
MessageSourceAware | 配置用于解析消息的策略(支持参数化和国际化)。 | |
NotificationPublisherAware | Spring JMX通知发布方。 | |
ResourceLoaderAware | 配置的用于底层访问资源的加载程序。 | |
ServletConfigAware | 容器运行所在的当前ServletConfig。仅在支持web的Spring ApplicationContext上下文中有效。 | |
ServletContextAware | 容器运行所在的当前ServletContext。仅在支持web的Spring ApplicationContext上下文中有效。 |
再次注意,使用这些接口会将代码绑定到Spring API,而不会遵循控制反转样式。因此,对于需要对容器进行编程访问的基础设施bean,我们建议使用它们。