Spring模块分析

一、Overview of Spring Framework

  The Spring Framework is a lightweight(轻量级的) solution(解决方案) and a potential(潜在的) one-stop-shop for building yourenterprise-ready applications(企业级应用程序). However, Spring is modular(模块化的), allowing you to use only those parts that you need, without having to bring in the rest. You can use the IoC container(容器), with any web framework on top, but you can also use only the Hibernate integration code or the JDBC abstraction layer. The Spring Framework supports declarative transaction management, remote access to yourlogic through RMI or web services, and various options for persisting your data. It offers a full-featuredMVC framework, and enables you to integrate AOP transparently into your software.

  Spring框架是一个轻量级的解决方案和一个潜在的一站式构建您的企业级应用程序。Spring是模块化的,允许您只使用您需要的那些部件,而不用添加剩余部分。您可以在任何web框架上使用IoC容器,但你也只能使用Hibernate integration code 或者 JDBC abstraction layer。Spring Framework支持声明式事务管理,通过RMI或web服务来远程访问您的logic, and various options for persisting your data。它提供了全功能的MVC framework,使您能够透明的将AOP集成到您的程序中。

1.1 Getting Started with 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.

  reference guide(参考指南)提供关于Spring框架的详细信息。它提供了所有功能的全面文档,以及Spring所包含的基本概念(如“依赖注入”)的一些背景。
  If you are just getting started with Spring, you may want to begin using the Spring Framework by creating a Spring Boot based application.Spring Boot provides a quick (and opinionated) way to create a production-ready Spring based application. It is based on the Spring Framework, favors convention over configuration, and is designed to get you up and running as quickly as possible.
  如果您刚开始使用Spring,您可能希望通过创建Spring Boot应用程序开始使用Spring框架。Spring Boot提供了一个快速的方式来创建一个production-ready Spring应用程序。它是基于Spring框架,约定高于配置,并旨在让你能尽可能快的运行。
  You can use start.spring.io to generate a basic project or follow one of the"Getting Started" guides like theGetting Started Building a RESTful Web Service one. As well as being easier to digest, these guides are very task focused, and most of them are based on Spring Boot. They also cover other projects from the Spring portfolio that you might want to consider when solving a particular problem.

1.2 Introduction to the Spring Framework

  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 enables you to build applications from "plain old Java objects" (POJOs) and to apply enterprise services non-invasively to POJOs. This capability applies to the Java SE programming model and to full and partial Java EE.  
  Examples of how you, as an application developer, can benefit from the Spring platform:

  • Make a Java method execute in a database transaction without having to deal with transaction APIs.
  • Make a local Java method a remote procedure without having to deal with remote APIs.
  • Make a local Java method a management operation without having to deal with JMX APIs.
  • Make a local Java method a message handler without having to deal with JMS APIs.

1.3 Dependency Injection(依赖注入) and Inversion of Control(控制反转)

  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.

  Although the Java platform provides a wealth of application development functionality, it lacks the means to organize the basic building blocks into a coherent whole, leaving that task to architects and developers. Although you can use design patterns such as Factory, Abstract Factory, Builder, Decorator, and Service Locator to compose the various classes and object instances that make up an application, these patterns are simply that: best practices given a name, with a description of what the pattern does, where to apply it, the problems it addresses, and so forth. Patterns are formalized best practices that you must implement yourself in your application.
  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.

二、Modules(模块)

  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(Aspect Oriented Programming),Instrumentation, Messaging, and Test,如下图所示:

  The following sections list the available modules for each feature along with their artifact names and the topics they cover. Artifact names correlate to artifact IDs used inDependency Management tools.

2.1 Core Container(核心容器)

  The Core Container consists of the spring-core, spring-beans, spring-context, spring-context-support, and spring-expression (Spring Expression Language) modules.

  核心容器由spring-core, spring-beans, spring-context, spring-context-support, spring-expression (Spring Expression Language)模块组成。

  The spring-core and spring-beans modules provide the fundamental parts of the framework, including the IoC and Dependency Injection features. The BeanFactory is a sophisticated implementation of the factory pattern. It removes the need for programmatic singletons and allows you to decouple the configuration and specification of dependencies from your actual program logic.

  spring-core和spring-beans模块提供了框架的基本部分,包含IoC(控制反转)和依赖注入。BeanFactory 是工厂模式的一个复杂的实现。 It removes the need for programmatic singletons and allows you to decouple the configuration and specification of dependencies from your actual program logic.

  The Context (spring-context) module builds on the solid base provided by theCore and Beans modules: it is a means to access objects in a framework-style manner that is similar to a JNDI registry. The Context module inherits its features from the Beans module and adds support for internationalization (using, for example, resource bundles), event propagation, resource loading, and the transparent creation of contexts by, for example, a Servlet container. The Context module also supports Java EE features such as EJB, JMX, and basic remoting. TheApplicationContext interface is the focal point of the Context module. spring-context-support provides support for integrating common third-party libraries into a Spring application context for caching (EhCache, Guava, JCache), mailing (JavaMail), scheduling (CommonJ, Quartz) and template engines (FreeMarker, JasperReports, Velocity).

  Context (spring-context)模块是基于Core and Beans 模块基础之上:它是一种以框架式方式访问对象的方法,类似于一个JNDI注册。Context模块继承了Bean模块的特性并增加对国际化的支持(using, for example, resource bundles),event propagation,resource loading,and the transparent creation of contexts by a Servlet container。Context模块也支持JavaEE特性例如EJB、JMX和basic remoting。ApplicationContext接口是Context 模块的重点。spring-context-support支持将通用第三方类库集成到Spring application context ,例如:caching (EhCache, Guava, JCache), mailing (JavaMail), scheduling (CommonJ, Quartz) and template engines (FreeMarker, JasperReports, Velocity).

  The spring-expression module provides a powerful Expression Language for querying and manipulating an object graph at runtime. It is an extension of the unified expression language (unified EL) as specified in the JSP 2.1 specification.The language supports setting and getting property values, property assignment, method invocation, accessing the content of arrays, collections and indexers, logical and arithmetic operators, named variables, and retrieval of objects by name from Spring’s IoC container. It also supports list projection and selection as well as common list aggregations.(这部分感觉翻译的有点出入)

  spring-expression模块提供了一个强大的Expression Language 用来在运行时查询和操作对象图。它是在JSP 2.1规范中指定的统一表达式语言(unified EL)的扩展。该语言支持设置和获取属性值,属性赋值,方法调用,访问数组的内容,集合和索引器、逻辑和算术运算,变量命名,并且可以从Spring的IoC容器通过名称检索对象。它还支持列表的投影和选择,以及常见的列表聚合。

2.2 AOP and Instrumentation

  The spring-aop module provides an AOP Alliance-compliant aspect-oriented programming implementation allowing you to define, for example, method interceptors and pointcuts to cleanly decouple code that implements functionality that should be separated. Using source-level metadata functionality, you can also incorporate behavioral information into your code, in a manner similar to that of .NET attributes.

  spring-aop模块提供一个遵守统一AOP规则的的面向切面编程的实现允许你定义,例如,方法拦截器和切入点从而更好地将你的代码解耦,类似于.NET attributes。

  The separate spring-aspects module provides integration with AspectJ.

  独立的spring-aspects模块提供了与AspectJ的集成。

  The spring-instrument module provides class instrumentation support and classloader implementations to be used in certain application servers. Thespring-instrument-tomcat module contains Spring’s instrumentation agent for Tomcat.

  spring-instrument 模块提供了在普通应用服务器中使用到的类设备支持和加载器实现。spring-instrument-tomcat模块包含了Spring的Tomcat设备代理。

2.3 Messaging

  Spring Framework 4 includes a spring-messaging module with key abstractions from the Spring Integration project such asMessage, MessageChannel, MessageHandler, and others to serve as a foundation for messaging-based applications. The module also includes a set of annotations for mapping messages to methods, similar to the Spring MVC annotation based programming model.

  Spring Framework 4包含了一个spring-messaging模块,它对Spring集成项目Message、MessageChannel和MessageHandler进行了重要的抽象,它是基于消息发送应用的基础。

Spring框架4包括一个弹簧通讯模块与Spring集成项目等信息,messagechannel,messagehandler关键抽象,和其他作为基于消息的应用程序的基础。该模块还包括用于将消息映射到方法的注释集,类似于基于Spring MVC注释的编程模型。

2.4 Data Access/Integration

  The Data Access/Integration layer consists(包含) of the JDBC, ORM, OXM, JMS, and Transaction modules.
  The spring-jdbc module provides a JDBC-abstraction layer that removes the need to do tedious JDBC coding and parsing of database-vendor specific error codes.
  spring-jdbc模块提供了JDBC抽象层,消除需要做乏味JDBC 编码以及相应的错误解析。
  The spring-tx module supports programmatic and declarative transaction management for classes that implement special interfaces and for all your POJOs (Plain Old Java Objects).
  spring-tx模块支持程序设计和实现特殊接口的类的声明事务管理以及所有的POJO (Plain Old Java Objects)类。
  The spring-orm module provides integration layers for popular object-relational mapping APIs, including JPA, JDO, and Hibernate. Using the spring-orm module you can use all of these O/R-mapping frameworks in combination with all of the other features Spring offers, such as the simple declarative transaction management feature mentioned previously.
  spring-orm模块为流行的对象关系映射API提供集成,包括JPA, JDO, and Hibernate。使用spring-orm模块,你可以将所有的这些O/R-mapping框架与Spring提供的其它特性相结合,例如前面提到的简单声明事务管理功能。
  The spring-oxm module provides an abstraction layer that supports Object/XML mapping implementations such as JAXB, Castor, XMLBeans, JiBX and XStream.
  spring-oxm模块提供支持Object/XML映射实现的抽象层,例如 JAXB, Castor, XMLBeans, JiBX and XStream.
  The spring-jms module (Java Messaging Service) contains features for producing and consuming messages. Since Spring Framework 4.1, it provides integration with the spring-messaging module.

  spring-jms模块 (Java Messaging Service)包含features for producing and consuming messages。自从Spring Framework 4.1开始,它提供与Spring-messaging 模块的集成。

2.5 Web

  The Web layer consists of the spring-web, spring-webmvc, spring-websocket, and spring-webmvc-portlet modules.
  The spring-web module provides basic web-oriented integration features such as multipart file upload functionality and the initialization of the IoC container using Servlet listeners and a web-oriented application context. It also contains an HTTP client and the web-related parts of Spring’s remoting support.
  The spring-webmvc module (also known as the Web-Servlet module) contains Spring’s model-view-controller (MVC) and REST Web Services implementation for web applications. Spring’s MVC framework provides a clean separation between domain model code and web forms and integrates with all of the other features of the Spring Framework.
  The spring-webmvc-portlet module (also known as the Web-Portlet module) provides the MVC implementation to be used in a Portlet environment and mirrors the functionality of the spring-webmvc module.

  Web层包含spring-web、spring-webmvc、spring-websocket和spring-webmvc-portlet模块。其中,spring-web提供了面向Web集成的基本特性,比如文件上传功能。Spring-webmvc模块包含了Spring的MVC和REST Web Service实现。Spring-webmvc-portlet模块提供了在Portlet环境下的MVC实现。

2.6 Test

  The spring-test module supports the unit testing and integration testing of Spring components with JUnit or TestNG. It providesconsistent loading of Spring ApplicationContexts and caching of those contexts. It also provides mock objects that you can use to test your code in isolation.

  Spring-test模块支持Spring组建JUnit和TestNG的单元测试和集成测试。

最后说明:由于个人英语水平不高且是一个初学者,所以只是针对个人兴趣进行了上述的翻译,仅供参考,如果发现有任何不合理的地方,请留言!

参考资料:

最后修改时间:2017年4月10日09:49:35

赞赏

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值