1.1. Introduction to the Spring IoC Container and Beans

目录

下一节 1.2. Container Overview

Core Technologies

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

参考手册的这个部分覆盖了所有整合在Spring 框架中的技术。

absolutely
英 [ˈæbsəluːtli]   美 [ˈæbsəluːtli]  
adv.
(强调真实无误)绝对地,完全地;绝对不;完全没有;极其

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框架,这个框架在概念上更容易理解,
并且成功地满足了80%的JAVA企业级应用的AOP需要。

Foremost
英 [ˈfɔːməʊst]   美 [ˈfɔːrmoʊst]  
福士得;最重要的;福莫斯特;最初的;最重要
amongst
英 [əˈmʌŋst]   美 [əˈmʌŋst]  
prep.同 among;(表示范围)在…之内;(表示位置)处在…中
thorough
英 [ˈθʌrə]   美 [ˈθɜːroʊ]  
adj.彻底的;完全的;深入的;细致的;仔细周到;工作缜密;十足的;彻头彻尾的;完完全全的

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

This chapter covers Spring’s Inversion of Control (IoC) container.

这个章节覆盖了Spring的控制反转IoC容器内容。

1.1. Introduction to the Spring IoC Container and Beans


1.1. Spring IoC容器和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) 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)。一组对象
可以通过这个机制定义它们的依赖关系(即,与它们一起使用的其他对象),在这个机制中,仅通过
以下方式:1.构造器参数;2.加载到工厂方法的参数;3.在对象被构造后或者从工厂方法返回后设置
到对象实例的属性。当容器创建bean之后,它完成了这些依赖的注入。这个过程从根本上讲是通过
使用类的直接构造或诸如服务器定位模式的机制来控制其依赖项的实例化 或位置的Bean本身的逆过
程(因此被称为控制反转)。

principle
英 [ˈprɪnsəpl]   美 [ˈprɪnsəpl]  
n.道德原则;行为准则;规范;法则;原则;<u>原理</u>;观念;(行动、思想的)理由,信条
whereby
英 [weəˈbaɪ]   美 [werˈbaɪ]  
adv.凭此;借以;由于
Example:In a just society there must be a system whereby people can seek redress through the courts
【在一个公正的社会中,一定会有一套人们可以通过法庭寻求赔偿的体制。】

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.
这个句子结构有点复杂,主干应该是 It is a process whereby objects define their dependencies 【通过这个过程,我们可以定义对象的依赖关系】
后面的 only through....修饰 process,through包括3种类型, 最后的 after it is ... 修饰 修饰 object instance

补充知识:服务器定位模式 (ServiceLocator pattern)的UML图
markdown
from:
https://www.cnblogs.com/davidwang456/p/4455841.html
https://www.cnblogs.com/gaochundong/archive/2013/04/12/service_locator_pattern.html

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.
beans/context是 Spring框架IoC容器的基础包。BeanFactory接口提供了先进的配置机制来管理任何类型的对象。ApplicationContext是 BeanFactory的子接口,它增加了以下特性:
1.更加简单地整合Spring AOP特性;
2.Message资源的处理(用于国际化支持);
3.事务处理的发布;
4.应用层特例如用于web应用的WebApplicationContext;

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.


简单来说,BeanFacotory接口提供了配置的框架和基本的功能,ApplicationConext增加了更多的
企业特性功能。ApplicationContext是BeanFactory的完整超集,在本章中专门用来对Spring的IoC
容器的描述。更多关于使用BeanFactory而不是ApplicationContext的信息,请参见BeanFactory。

exclusively
英 [ɪkˈskluːsɪvli]   美 [ɪkˈskluːsɪvli]  
adv.排他地;独占地;专有地;完全地

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仅仅是你应用里面众
多对象中的一个。Bean及其之间的依赖关系反映在被容器使用的配置元数据中。

reflected
出现13次
英 [rɪˈflektɪd]   美 [rɪˈflektɪd]  
v.反映;映出(影像);反射(声、光、热等);显示,表明,表达(事物的自然属性或人们的态度、情感等)

In Spring, the objects that form the backbone of your application and that are managed
by the Spring IoC container are called beans
这个句子主干 the objects ... are called beans【...的对象被称为beans】
that... 后面的两部分都用来修饰 objects,表示只有这种类型的对象才能称为beans

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值