您的位置:首页 > 编程语言 > Java开发

专业英语笔记:Spring框架

2018-02-20 10:47 495 查看
Now we're learning Spring.
The best way to learn Spring is to study its official documentation.
The current version is Spring 4.3.6 RELEASE. 发布版
For example, Spring 5.0.1.M1 里程碑版 (M——Milestone)
Spring框架官方开发文档http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/



Look at the Authors! It's a long list, and so many people have made contributions to the development of Spring Framework.


















The whole document contains eight parts.
Let's take a look at the overview of the Spring Framework.
1. Getting Started with Spring
1. 开始Spring
This reference guide provides detailed information about the Spring Framework. It provides comprehensive documentation for all features, as well as some background about the underlying concepts (such as "Dependency Injection") that Spring has embraced.
这本参考指南提供关于Spring框架的详细信息。它为Spring所有功能提供全面的文档资料,还提供了Spring框架包含的基础概念(比如“依赖注入”)。
2. Introduction to the Spring Framework
2、Spring框架简介
The Spring Framework is a Java platform that provides comprehensive infrastructure support for developing Java applications. Spring handles the infrastructure so you can focus on your application.
Spring框架是一个Java平台,为开发Java应用程序提供全面的基础设施支持。Spring搞定基础设施,因此你能关注你的应用。
2.1 Dependency Injection and Inversion of Control
2.1 依赖注入和控制反转
A Java application — a loose term that runs the gamut from constrained, embedded applications to n-tier, server-side enterprise applications — typically consists of objects that collaborate to form the application proper. Thus the objects in an application have dependencies on each other.

一个Java应用——一个宽泛的术语,范围从有限制的、嵌入式的应用到n层架构、服务器端企业级应用——一般都包含了相互协作的对象来形成适当的应用程序。因此,一个应用程序里的对象是相互依赖的。
附注:不管小应用还是大应用,都包含了相互依赖的对象。
The Spring Framework Inversion of Control (IoC) component addresses this concern by providing a formalized means of composing disparate components into a fully working application ready for use. The Spring Framework codifies formalized design patterns as first-class objects that you can integrate into your own application(s). Numerous organizations and institutions use the Spring Framework in this manner to engineer robust, maintainable applications.
Spring框架的控制反转组件解决这个关注点,通过提供一个形式化的手段,将分离的组件整合成一个可以使用的应用程序。Spring框架将形式化的设计模式代码化成一流的对象,你可以将这些对象整合到你的应用程序里。无数的组织机构都在以这种方式使用Spring框架来创建健壮的、可维护的应用。
附注:一句话,Spring框架提供了一个生产Bean的工厂。不需要我们程序员自己去创建那个生成Bean的工厂了。
2.2 Modules
2.2 模块
The Spring Framework consists of features organized into about 20 modules. These modules are grouped into Core Container, Data Access/Integration, Web, AOP (Aspect Oriented Programming), Instrumentation, Messaging, and Test, as shown in the following diagram.
Spring框架包含的功能组成了大约20个模块。这些模块分成以下几组:核心容器、数据访问/集成、Web、AOP(面向切面编程)、工具、消息机制、测试等等。


通过Spring概述,我们了解了Spring可以帮助我们更好地管理我们对象。通过它提供的控制反转容器来实现。
Let's jump to Chapter 7 of this documentation.




这两个包是Spring框架IoC容器的基础。BeanFactory接口提供了一个高级配置机制,能够管理各种类型的对象,而ApplicationContext是BeanFactory的子接口。它更容易集成AOP功能、消息资源处理(用于国际化)、事件发布、以及与应用层相关的容器,例如WebApplicationContext。
我们上两次框架课里涉及到两个应用容器。






Let's see the class hierarchy of ClassPathXmlApplicationContext.






It's a long long way from the BeanFactory interface to the ClassPathXmlApplicationContext class and AnnotationConfigApplicationContext class.
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 7.16, “The BeanFactory”.
简而言之,BeanFactory接口提供了配置框架与基本功能,ApplicationContext接口增加了更多与企业相关的功能。ApplicationContext接口是BeanFactory接口的完全超集,在这一章我们专门用它来描述Spring框架的IoC容器。要了解更多关于BeanFactory接口而不是ApplicationContext接口的信息,参看7.16节——BeanFactory接口。
7.2 Container overview
7.2 容器概述
The interface org.springframework.context.ApplicationContext represents the Spring IoC container and is responsible for instantiating, configuring, and assembling the aforementioned beans. The container gets its instructions on what objects to instantiate, configure, and assemble by reading configuration metadata. The configuration metadata is represented in XML, Java annotations, or Java code. It allows you to express the objects that compose your application and the rich interdependencies between such objects.
org.springframework.context.ApplicationContext接口代表了Spring的IoC容器,负责前面提到的Bean的实例化、配置以及装配。容器通过读取配置元数据来获取它的关于什么对象要实例化、配置以及装配。配置元数据有三种表示方式:XML配置方式、Java注解方式、Java代码配置方式。Spring容器允许你表达构成你的应用程序的对象以及那些对象之间丰富的相互依赖关系。
Several implementations of the ApplicationContext interface are supplied out-of-the-box with Spring. In standalone applications it is common to create an instance of ClassPathXmlApplicationContext or FileSystemXmlApplicationContext. While XML has been the traditional format for defining configuration metadata you can instruct the container to use Java annotations or code as the metadata format by providing a small amount of XML configuration to declaratively enable support for these additional metadata formats.
Spring提供了ApplicationContext接口的几个开箱即用的实现类。在独立运行的应用里,创建ClassPathXmlApplicationContext或FileSystemXmlApplicationContext的实例是很常见的。当XML已经成为定义配置元数据的传统格式时,通过提供少量的XML配置来声明式地启用对这些附加元数据格式的支持,你可以指示容器使用Java注解或代码作为元数据格式。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: