1.6.3. Other Aware Interfaces 其它Aware接口

 Spring Framework Documentation (5.3.10)

Core

IoC Container, Events, Resources, i18n, Validation, Data Binding, Type Conversion, SpEL, AOP.

   Core Technologies

1. The IoC Container

1.1. Introduction to the Spring IoC Container and Beans(Spring IoC容器和bean简介)

1.2. Container Overview (容器概览)

1.3. Bean Overview (Bean概览)

1.4. Dependencies(依赖)

1.5. Bean Scopes(Bean作用域)

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.

ApplicationContextAware and BeanNameAware

ApplicationEventPublisherAware

Event publisher of the enclosing ApplicationContext.

Additional Capabilities of the ApplicationContext

BeanClassLoaderAware

Class loader used to load the bean classes.

Instantiating Beans

BeanFactoryAware

Declaring BeanFactory.

ApplicationContextAware and BeanNameAware

BeanNameAware

Name of the declaring bean.

ApplicationContextAware and BeanNameAware

LoadTimeWeaverAware

Defined weaver for processing class definition at load time.

Load-time Weaving with AspectJ in the Spring Framework

MessageSourceAware

Configured strategy for resolving messages (with support for parametrization and internationalization).

Additional Capabilities of the ApplicationContext

NotificationPublisherAware

Spring JMX notification publisher.

Notifications

ResourceLoaderAware

Configured loader for low-level access to resources.

Resources

ServletConfigAware

Current ServletConfig the container runs in. Valid only in a web-aware Spring ApplicationContext.

Spring MVC

ServletContextAware

Current ServletContext the container runs in. Valid only in a web-aware Spring ApplicationContext.

Spring MVC

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

ApplicationContextAware and BeanNameAware

ApplicationEventPublisherAware

包含的ApplicationContext的事件发布者。

Additional Capabilities of the ApplicationContext

BeanClassLoaderAware

用于加载bean类的类装入器。

Instantiating Beans

BeanFactoryAware

声明BeanFactory

ApplicationContextAware and BeanNameAware

BeanNameAware

声明bean的名称。

ApplicationContextAware and BeanNameAware

LoadTimeWeaverAware

已定义用于在加载时处理类定义的织入器。

Load-time Weaving with AspectJ in the Spring Framework

MessageSourceAware

配置用于解析消息的策略(支持参数化和国际化)。

Additional Capabilities of the ApplicationContext

NotificationPublisherAware

Spring JMX通知发布方。

Notifications

ResourceLoaderAware

配置的用于底层访问资源的加载程序。

Resources

ServletConfigAware

容器运行所在的当前ServletConfig。仅在支持webSpring ApplicationContext上下文中有效。

Spring MVC

ServletContextAware

容器运行所在的当前ServletContext。仅在支持webSpring ApplicationContext上下文中有效。

Spring MVC

再次注意,使用这些接口会将代码绑定到Spring API,而不会遵循控制反转样式。因此,对于需要对容器进行编程访问的基础设施bean,我们建议使用它们。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月满闲庭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值