JAVA

SpringFramework翻译_2Core Technolo

2018-10-10  本文已影响18人  YannisChen_2017
spring.jpg

Core Technologies(核心技术)

Version 5.1.0.RELEASE

This part of the reference documentation covers all the technologies that are absolutely integral to the Spring Framework.

参考文档的这一部分涵盖了Spring框架中不可或缺的所有技术。

Foremost amongst these is the Spring Framework’s Inversion of Control (IoC) container. A thorough treatment of the Spring Framework’s IoC container is closely followed by comprehensive coverage of Spring’s Aspect-Oriented Programming (AOP) technologies. The Spring Framework has its own AOP framework, which is conceptually easy to understand and which successfully addresses the 80% sweet spot of AOP requirements in Java enterprise programming.

在Spring框架中最重要的是控制反转(IoC)容器。对Spring框架的IoC容器进行彻底的探究之后,紧接着是对Spring面向切面编程(AOP)技术的全面覆盖。Spring框架有自己的AOP框架,它在概念上更容易理解,并且成功地解决了Java企业编程中80%的AOP需求。

Coverage of Spring’s integration with AspectJ (currently the richest — in terms of features — and certainly most mature AOP implementation in the Java enterprise space) is also provided.

本文还介绍了Spring与AspectJ的集成(就特性而言,目前是最丰富的,当然也是Java企业空间中最成熟的AOP实现)。

1. The IoC Container(IOC容器)

This chapter covers Spring’s Inversion of Control (IoC) container.
本章介绍Spring的IoC容器。

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

This chapter covers the Spring Framework implementation of the Inversion of Control (IoC) principle. (See Inversion of Control.) IoC is also known as dependency injection (DI). It is a process whereby objects define their dependencies (that is, the other objects they work with) only through constructor arguments, arguments to a factory method, or properties that are set on the object instance after it is constructed or returned from a factory method. The container then injects those dependencies when it creates the bean. This process is fundamentally the inverse (hence the name, Inversion of Control) of the bean itself controlling the instantiation or location of its dependencies by using direct construction of classes or a mechanism such as the Service Locator pattern.

本章介绍了Spring框架实现IoC的原理(参见控制反转/控制倒置)。IoC也称为依赖注入(dependency injection, DI)。在这个过程中,对象仅通过构造函数参数、工厂方法的参数或对象实例在构造或从工厂方法返回后设置的属性来定义它们的依赖关系(也就是说,和它们一起工作的其他对象)。然后容器在创建bean时注入这些依赖项。这个过程基本上是bean本身的逆过程,它通过使用类或服务定位器模式等机制的直接构造来控制依赖项的实例化或位置(这就是控制饭反转)。

The org.springframework.beans and org.springframework.context packages are the basis for Spring Framework’s IoC container. The BeanFactory interface provides an advanced configuration mechanism capable of managing any type of object. ApplicationContext is a sub-interface of BeanFactory. It adds: * Easier integration with Spring’s AOP features * Message resource handling (for use in internationalization) * Event publication * Application-layer specific contexts such as the WebApplicationContext for use in web applications.

The org.springframework.beans和org.springframework.context packages包是Spring框架的IoC容器的基础。BeanFactory接口提供能够管理任何类型对象的高级配置机制。ApplicationContext是BeanFactory的子接口。它还增加了:

In short, the BeanFactory provides the configuration framework and basic functionality, and the ApplicationContext adds more enterprise-specific functionality. The ApplicationContext is a complete superset of the BeanFactory and is used exclusively in this chapter in descriptions of Spring’s IoC container. For more information on using the BeanFactory instead of the ApplicationContext, see The BeanFactory.

简而言之,BeanFactory提供了配置框架和基本功能,而ApplicationContext添加了更多企业特定的功能。ApplicationContext是BeanFactory的一个完整超集,在本章中专门用于描述Spring的IoC容器。有关使用BeanFactory而不是ApplicationContext的更多信息,请参阅BeanFactory。

In Spring, the objects that form the backbone of your application and that are managed by the Spring IoC container are called beans. A bean is an object that is instantiated, assembled, and otherwise managed by a Spring IoC container. Otherwise, a bean is simply one of many objects in your application. Beans, and the dependencies among them, are reflected in the configuration metadata used by a container.

在Spring中,构成应用程序主干并由Spring IoC容器管理的对象称为beans。bean是由Spring IoC容器实例化、组装和以其他方式管理的对象。另外,bean只是应用程序中的众多对象之一。Beans及其之间的依赖关系反映在容器使用的配置元数据中。

https://docs.spring.io/spring-framework/docs/current/spring-framework-reference/core.html

上一篇下一篇

猜你喜欢

热点阅读