Spring 5.0.0框架介绍_中英文对照_3.1

文章作者:Tyan
博客:noahsnail.com

Part II. Core Technologies

This part of the reference documentation covers all of those 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企业级开发中成功了解决了AOP需求中80%的关键点。

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实现)。

  • Chapter 3, The IoC container
  • Chapter 4, Resources
  • Chapter 5, Validation, Data Binding, and Type Conversion
  • Chapter 6, Spring Expression Language (SpEL)
  • Chapter 7, Aspect Oriented Programming with Spring
  • Chapter 8, Spring AOP APIs

3. The IoC container

3.1 Introduction to the Spring IoC container and beans

This chapter covers the Spring Framework implementation of the Inversion of Control (IoC) principle. 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 (IoC), 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也被称为依赖注入(DI)。它是一个处理过程,凭借对象之间依赖关系,也就是和它们一起工作的其它对象,只能通过构造函数参数,传递参数给工厂方法,在构造完成或工厂方法返回的对象实例之后再设置对象实例的属性。当创建bean时容器再将这些依赖对象注入进去。这个过程从根本上颠倒了bean本身通过直接构建类或通过一种机制例如服务定位模式来控制依赖对象的实例化或定位,因此命名为控制反转(IoC)。

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; and application-layer specific contexts such as the WebApplicationContext for use in web applications.

org.springframework.beansorg.springframework.context包是Spring框架控制反转容器的基础。BeanFactory接口提供了一种能管理任何类型对象的高级配置机制。ApplicationContextBeanFactory的一个子接口。ApplicationContext增加了更容易集成Spring AOP功能;消息资源处理(用在国际化中),事件发布;应用层特定上下文例如WebApplicationContext在web应用中的使用。

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, refer to Section 3.16, “The BeanFactory”.

总之,BeanFactory提供了配置框架和基本功能,ApplicationContext增加了更多企业专用的功能。ApplicationContextBeanFactory的一个全面超集,在这章仅仅是用来描述Spring的IoC容器。关于用BeanFactory代替ApplicationContext的更多信息请参考3.16小节”The 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和它们之间的依赖关系,通过容器使用的配置元数据可以反映出来。

如果有收获,可以请我喝杯咖啡!