`

Spring框架的前生今世

阅读更多

    整理完Spring 1.2.9引用文档的整个目录和Spring 2.04.0的新功能和增强功能的介绍后,发现还有不少重要的功能还不了解,这些都是自己接下来要补看的。

作为一名Spring框架的使用者来说,结合3.2.x引用文档[PDF]目录,我觉得以下内容是必须要仔细看的:

l  Overview of Spring Framework (框架概述)

l  The IoC container (控制反转容器)

l  Resources

l  Validation, Data Binding, and Type Conversion (校验、数据绑定与类型转换)

l  Aspect Oriented Programming with Spring (AOP - 面向切面编程)

l  Spring AOP APIs

l  Transaction Management

l  Controlling database connections - Data access with JDBC (数据源连接池管理)

l  Web MVC framework

l  Testing

l  Classic Spring Usage

l  Classic Spring AOP Usage

l  XML Schema-based configuration

以下这些内容是选择性地看:

l  Object Relational Mapping (ORM) Data Access

l  View technologies

l  Task Execution and Scheduling

l  Cache Abstraction

l  Integration

l  Extensible XML authoring

 

目录 (1.2.9版本)

1.      Introduction (框架介绍)

1.1    Overview (框架概述)

1.2    Usage scenarios (使用场景)

3.      Beans, BeanFactory and the ApplicationContext

3.1    Introduction

3.2    BeanFactory and BeanDefinitions - the basics (bean工厂与定义)

The BeanFactory

The BeanDefinition

To singleton or not to singleton

3.3    Properties, collaborators, autowiring and dependency checking (属性、协作者、自动装配与依赖检查)

Setting bean properties and collaborators (设置bean属性与协作者)

依赖注入的两种方式:基于setterconstructor方法

Bean dependency resolution (Bean依赖解析过程)

Autowiring collaborators (自动装配协作者)

Checking for dependencies (依赖检查)

3.4    Customizing the nature of a bean (自定义bean的特性)

Lifecycle interfaces (生命周期接口)

              InitializingBean and DisposableBean

Knowing who you are

              BeanFactoryAwareBeanNameAware (Bean工厂感知器)

       FactoryBean

3.6    Interacting with the BeanFactory (Bean工厂交互)

A BeanFactory is essentially nothing more than the interface for an advanced factory capable of maintaining a registry of different beans and their dependencies. (一个Bean工厂本质上无非就是一个能够维护不同beans定义及其依赖关系的注册表高级工厂)

3.7    Customizing beans with BeanPostProcessors (自定义bean)

The post-processor will get a callback from the BeanFactory before any initialization methods are called, and also afterwords. A bean post-processor will typically check for marker interfaces. (一个bean后置处理器会在任何初始化方法被调用之前和之后被回调,通常用来检查标记接口)

3.8    Customizing bean factories with BeanFactoryPostProcessors (自定义bean工厂)

A bean factory post-processor, implements the BeanFactoryPostProcessor interface, is executed automatically to apply changes of some sort to an entire BeanFactory. (一个bean工厂后置处理器会自动执行,并将所有更改应用到整个bean工厂。)

The PropertyPlaceholderConfigurer is used to externalize some property values from a BeanFactory definition, into another separate file in Java Properties format. (属性占位符配置器被用于外部化一些属性值到其它分开的文件中)

The PropertyOverrideConfigurer, the original definitions can have default values or no values at all for bean properties. (属性覆盖配置器)

3.9    Registering additional custom PropertyEditors (类型转换)

a BeanFactory ultimately uses standard JavaBeans PropertyEditors to convert these Strings to the complex type of the property.

3.11     Introduction to the ApplicationContext (应用上下文介绍)

While the beans package provides basic functionality for managing and manipulating beans, the context package adds ApplicationContext which enhances BeanFactory functionality in a more framework-oriented style. (beans包提供了管理与操作beans的基本功能,而context包通过应用上下文以框架的形式来增强bean工厂功能。)

3.13     Customized behavior in the ApplicationContext (自定义行为)

The BeanFactory already offers a number of mechanisms to control the lifecycle of beans and bean post-processors. In an ApplicationContext, all of these still work, but additional mechanisms are added for customizing behavior of beans and the container. (Bean工厂提供了一系列机制来控制beansbean后置处理器的生命周期。在应用上下文中,以上这些功能仍然可用,同时增加了自定义beans和容器行为的机制。)

ApplicationContextAware marker interface (应用上下文感知器)

The BeanPostProcessor

The BeanFactoryPostProcessor

The PropertyPlaceholderConfigurer

3.18     Importing Bean Definitions from One File Into Another

4.      Abstracting Access to Low-Level Resources

4.1    Overview

4.2    The Resource interface (资源抽象接口)

Spring's Resource interface is a more capable interface for abstracting access to low-level resources. (一个更强大地抽象访问底层资源的接口)

4.3    Built-in Resource implementations (内部的资源实现类)

ClassPathResource

4.4    The ResourceLoader Interface (资源加载器)

The ResourceLoader interface is implemented by objects that can return (i.e load) Resources.

4.5    The ResourceLoaderAware interface

5.      PropertyEditors, data binding, validation and the BeanWrapper (属性编辑器、数据绑定、校验、Bean封装)

5.1    Introduction

5.2    Binding data using the DataBinder

5.3    Bean manipulation and the BeanWrapper (Bean操作)

the BeanWrapper offers functionality to set and get property values (individually or in bulk), get property descriptors, and to query properties to determine if they are readable or writable. (设置与获取属性值)

5.4    Validation using Spring's Validator interface (校验)

Spring Validator interface you can use to validate objects. The Validator interface, is pretty straightforward and works using with a so-called Errors object. (Validator接口用于校验对象,与Errors对象一起工作)

5.5    The Errors interface

6.      Spring AOP: Aspect Oriented Programming with Spring (面向切面编程)

6.1    Concepts

AOP concepts (AOP概念)

Spring AOP capabilities and goals (功能与目标)

AOP Proxies in Spring (AOP代理)

6.2    Pointcuts in Spring (切点)

Concepts

       Spring's pointcut model enables pointcut reuse independent of advice types.

Convenience pointcut implementations

6.3    Advice types in Spring (特定连接点上的动作)

Advice lifecycles

      Spring advices can be shared across all advised objects, or unique to each advised object. This corresponds to per-class or per-instance advice.

Advice types in Spring (动作类型)

       Interception around advice (拦截)

       Before advice

       Throws advice

       After Returning advice

6.4    Advisors in Spring

6.5    Using the ProxyFactoryBean to create AOP proxies

Proxying interfaces

6.6    Convenient proxy creation

6.9    Manipulating advised objects (操作动作对象)

6.11     Using TargetSources (实现连接点的目标对象)

Hot swappable target sources

Pooling target sources

ThreadLocal target sources

6.12     Defining new Advice types

6.13     Further reading and resources

8.      Transaction management (事务管理)

8.1    The Spring transaction abstraction (事务抽象层)

8.2    Transaction strategies (事务策略)

The key to the Spring transaction abstraction is the notion of a transaction strategy. This is captured in the PlatformTransactionManager interface. (事务抽象的关键是事务策略的概念)

8.3    Resource synchronization with transactions (资源同步)

8.4    Programmatic transaction management

Using the TransactionTemplate

8.5    Declarative transaction management (声明式事务管理)

Source Annotations for Transaction Demarcation (事务注解)

The Transactional Annotation

Using AOP to ensure the Transactional annotation is applied

              AOP and Transactions

8.6    Choosing between programmatic and declarative transaction management

9.      Source Level Metadata Support

10.  DAO support

11.  Data Access using JDBC

11.1     Introduction

11.2     Using the JDBC Core classes to control basic JDBC processing and error handling

JdbcTemplate (简化资源创建与释放的处理)

DataSource (获取一个连接到数据库的链接)

11.3     Controlling how we connect to the database (如何连接到数据库)

TransactionAwareDataSourceProxy

DataSourceTransactionManager (支持单个资源场景)

11.4     Modeling JDBC operations as Java objects

12.  Data Access using O/R Mappers (对象/关系映射器)

12.1     Introduction

12.6     iBATIS SQL Maps

iBATIS SQL Maps 2.x

    Setting up the SqlMapClient

    Using SqlMapClientTemplate and SqlMapClientDaoSupport

13.  Web MVC framework

13.1     Introduction to the web MVC framework

Pluggability of other MVC implementations

Features of Spring MVC (功能介绍)

13.2     The DispatcherServlet (请求分发中心)

Spring's web MVC framework is a request-driven web MVC framework, designed around a servlet (DispatcherServlet) that dispatches requests to controllers and offers other functionality facilitating the development of web applications. (Spring MVC框架是一个请求驱动的MVC框架,其围绕DispatcherServlet设计。分发器用于分发请求到控制器,并提供其它功能。)

13.3     Controllers (控制器)

AbstractController and WebContentGenerator

13.4     Handler mappings (处理映射器)

The functionality a basic HandlerMapping provides is the delivering of a HandlerExecutionChain, which must contain the handler that matches the incoming request, and may also contain a list of handler interceptors that are applied to the request. (处理映射器的功能由处理执行链提供,处理执行链必须包含与请求相匹配的处理器,也可能包含被应用到这个请求的处理拦截器)

Adding HandlerInterceptors

13.5     Views and resolving them (视图解析)

ViewResolvers

    VelocityViewResolver

Redirecting to views

13.6     Using locales

CookieLocaleResolver

SessionLocaleResolver

LocaleChangeInterceptor

13.7     Using themes

13.8     Spring's multipart (fileupload) support

13.9     Handling exceptions (处理异常)

14.  Integrating view technologies

14.4     Velocity & FreeMarker

Context configuration (上下文配置)

Creating templates (创建模板)

Advanced configuration

       velocity.properties

Bind support and form handling (绑定支持)

       the bind macros

       simple binding

       form input generation macros (form输入宏)

14.6     Document views (PDF/Excel)

14.7     JasperReports

16.  Remoting and web services using Spring

16.1     Introduction

16.2     Exposing services using RMI

Exporting the service using the RmiServiceExporter

16.3     Using Hessian or Burlap to remotely call services via HTTP

16.4     Exposing services using HTTP invokers

18.  JMS

18.1     Introduction

JMSJava Messaging Service,即Java消息服务,是面向消息中间件的API,用于在系统之间发送消息,进行异步通信。

Spring provides a JMS abstraction framework that simplifies the use of the JMS API.

JmsTemplate simplifies the use of the JMS by handling the creation and release of resources. (通过管理资源的创建与释放来简化JMS的使用)

18.2     Domain unification

JMS 1.0.2 defined two types of messaging domains, point-to-point (Queues) and publish/subscribe (Topics). JMS 1.1 introduced the concept of domain unification that

minimized both the functional differences and client API differences between the two domains. (1.0.2版定义了两种消息域点对点(队列)和发布/订阅(主题)1.1引入域一体化的概念,以便最小化两种消息域的功能差异。)

19.  JMX Support

       The JMX support in Spring provides you with the features to easily and transparently integrate your Spring application into a JMX infrastructure.

20.  JCA CCI

J2EE provides a specification to standardize access to EIS: JCA (Java Connector Architecture).

       SPI (Service provider interfaces) that the connector provider must implement.

       CCI (Common Client Interface) that an application can use to interact with the connector and thus communicate with an EIS.

21.  Sending Email with Spring mail abstraction layer

22.  Scheduling jobs using Quartz or Timer (定时任务)

23.  Testing

23.1     Unit testing (单元测试)

23.2     Integration testing (集成测试)

Context management and caching (上下文管理与缓存)

Dependency Injection of test class instances (测试对象的依赖注入)

Transaction management (事务管理)

 

2.02.5版本的新功能

Spring框架已经经历了两次重大修改:Spring 2.0Spring 2.5。前者发布于200610月,后者发布于200711月。

2.0版已深度支持Java 52.5版引入了Java 6的专门支持。

本章是对Spring 2.02.5的新功能和改进功能介绍的入门指南。

控制反转容器 (IoC)

l  New bean scopes (新的bean作用域)2.0版引入requestsession和允许用户创建自己的作用域 (原来有singletonprototype)

l  Easier XML configuration (更简单的XML配置):基于XML Schema的新XML配置语法

l  Extensible XML authoring (可扩展的XML编写):可编写自定义的配置标记

l  Annotation-driven configuration (注解驱动的配置)2.5版支持一套完整的配置注解,包括@AutowiredJSR-250@Resource, @PostConstruct, @PreDestroy2.0版的@Transactional

l  Autodetecting components in the classpath (自动检测类路径下的组件)2.5版支持组件扫描,模式化注解包括@Component, @Repository, @Service, @Controller

面向切面编程 (AOP)

l  Easier AOP XML configuration2.0版使用普通Java对象定义切面 (aspects),充分利用了AspectJ切点语言

l  Support for @AspectJ aspects2.0版支持@AspectJ切面注解

l  Support for bean name pointcut element2.5版支持bean(...)名称的切点元素

l  Support for AspectJ load-time weaving2.5版支持AspectJ装载时织入,作为基于代理AOP框架的可选方案

中间层

l  Easier configuration of declarative transactions in XML2.5版结合装载时织入功能来支持方便的注解驱动的事务管理

l  JPA2.0版提供了JPA抽象层(类似于JDBC抽象层)

l  Asynchronous JMS2.0版完全支持以异步的方式接收消息,2.5版以JCA方式来设置异步消息监听者,同时2.5版还引入JMS命名空间来简化配置

Web

l  Sensible defaulting in Spring MVC:约定优于配置支持

l  Annotation-based controllers2.5版引入一个基于注解的MVC控制器编程模型,使用@Controller, @RequestMapping, @RequestParam等注解

l  A form tag library for Spring MVC2.0版提供了一个全功能的JSP标签库

通天塔

l  Enhanced testing support2.5版引入了Spring TestContext框架,其提供了注解驱动的单元与集成测试支持,还提供了通用的、可扩展的测试基础设施

l  Deploying a Spring application context as JCA adapter2.5版支持将Spring应用上下文作为JCA资源适配器的部署

l  Task scheduling2.0版提供了一个任务调度的抽象

l  Java 5 (Tiger) support:基于注解的配置、@AspectJ支持

l  Migrating to Spring 2.52.5版运行在Java 5之上,可以借助其重要配置便利性和性能改进。建议的迁移策略是删除老的jars,然后选择使用新的功能实现

l  Updated sample applications:展示新的和改进的功能,要花时间仔细研究这些示例程序

l  Improved documentation:参考文档已经进行了充分的更新,以便反映上述所有提到的Spring 2.02.5的新功能

3.0版本的新功能和增强功能

Spring框架的第三次重大修改是Spring Framework 3.0

Spring 3.0基于Java 5,并完全支持Java 6

l  Java 5:整个框架的代码已经被修改,以便充分利用Java 5的特性,如泛型、注解、并发工具、可变变量。TaskExecutor抽象已经更新,以便紧密集成Java 5的并发工具。同时,提供了对CallablesFutures的最佳支持,还有ExecutorService适配器和ThreadFactory集成

l  Improved documentation:参考文档已经进行了充分的更新,以便反映Spring 3.0的所有更改和新功能

l  New articles and tutorials:有很多优秀的文章和教程来说明如何开始使用Spring 3.0功能,请来Guides页面阅读。示例程序(samples)已经进行了改进和更新,以便充分利用Spring 3.0的新功能

l  New module organization and build system:模块包括beanscontextaoptransactionjdbcwebormtest

Overview of new features

l  Core APIs updated for Java 5TaskExecutor接口继承concurrent.Executor;新的基于Java 5的转换器APISPI,包括无状态的ConversionServiceConverters

l  Spring Expression Language:表达式语言可用于定义基于XML和注解的bean定义

l  Java based bean metadata@Configuration@Bean@Import

l  General purpose type conversion system and field formatting system:引入类型转换系统和formatter SPI

Web

最令人兴奋的新功能是对构建RESTful Web服务和Web应用程序的支持。

l  Comprehensive REST support:服务端支持已作为现有注解驱动的MVC框架的扩展提供,使用HttpConverters来帮助对象和HTTP请求和响应的表示之间的转换

l  @MVC additions:引入mvc命名空间来大大简化MVC配置

l  Declarative model validation:现在已完全支持JSR-303 Bean Validation APIDataBinder可以验证对象以及绑定到它们,MVC已支持声明式校验@Controller输入

l  Early support for Java EE 6:使用新的@Async注解来支持异步方法调用

3.1版本的新功能和增强功能

l  Cache AbstractionCache Abstraction (SpringSource team blog)

l  Bean Definition ProfilesIntroducing @Profile (SpringSource Team Blog)

l  PropertySource Abstraction

l  Code equivalents for Spring's XML namespaces

l  Support for Hibernate 4.x

l  TestContext framework support for @Configuration classes and bean definition profiles@ContextConfiguration注解现在支持提供配置TestContext@Configuration

l  c: namespace for more concise constructor injection

l  Support for injection against non-standard JavaBeans setterssetter可以返回'this'引用

l  New HandlerMethod-based Support Classes For Annotated Controller Processing3.1版引入了一套新的处理控制器注解请求的支持类,包括RequestMappingHandlerMappingRequestMappingHandlerAdapter;第二个显著区别是引入HandlerMethod抽象来表示@RequestMapping方法

l  "consumes" and "produces" conditions in @RequestMapping

l  Flash Attributes and RedirectAttributes

l  URI Template Variable Enhancements

l  @Valid On @RequestBody Controller Method Arguments@RequestBody方法参数可以添加@Valid注解,以便自动调用检验程序

l  @RequestPart Annotation On Controller Method Arguments:处理文件上传请求

l  UriComponentsBuilder and UriComponents:使用UriTemplate作为更灵活的替代方案

3.2版本的新功能和增强功能

l  Support for Servlet 3 based asynchronous request processingMVC编程模型现在提供了明确的Servlet 3异步支持

l  Spring MVC Test framework:完美支持MVC应用程序测试

l  Content negotiation improvementsContentNegotiationStrategy现在可用于解析请求的媒体类型

l  @ControllerAdvice annotation

l  Abstract base class for code-based Servlet 3+ container initialization

l  Support for generic types in the RestTemplate and in @RequestBody arguments

l  Jackson JSON 2 improvementsMappingJackson2HttpMessageConverter

l  @RequestBody improvements

l  Excluded patterns in mapped interceptors

l  Using meta-annotations for injection points and for bean definition methods

l  Initial support for JCache 0.5

l  Support for @DateTimeFormat without Joda Time

l  Global date & time formatting

l  New Testing Features:配置并加载Web应用上下文、配置上下文层次结构、测试requestsession作用域的beans、改进的Servlet API mocks

l  Concurrency refinements across the framework

l  New Gradle-based build and move to GitHub

l  Refined Java SE 7 / OpenJDK 7 support

4.0版本的新功能和增强功能

Spring框架自2004年首次发布以来,已经经历了几次显著重大修改:Spring 2.0提供的XML命名空间和AspectJ支持,Spring 2.5拥抱的注解驱动配置,Spring 3.0引入的基于强大的Java 5+基础之上的框架代码库。

4.0版是Spring框架的最新主要版本,基于Java 6,并率先全面支持Java 8功能。

Migration guide for upgrading to Spring 4.0

l  Improved Getting Started Experience:新的spring.io网站提供了全系列的入门指南("Getting Started" guides)来帮助你了解Spring

l  Removed Deprecated Packages and MethodsAPI Differences Report包含了所有的变化

l  Java 8 (as well as 6 and 7)4.0版提供了几个Java 8功能的支持,包括lambda表达式和方法引用;首次支持java.time (JSR-310)Spring支持的最小Java版本为JDK 6 update 18。对于新启动的基于Spring 4的开发项目,我们建议使用Java 78

l  Java EE 6 and 7Java EE 6Spring 4的基准,一个更具前瞻性的关注点是Spring 4.0现在支持Java EE 7的应用规范

l  Groovy Bean Definition DSL:用于定义外部bean配置

l  Core Container Improvements:在注入bean时把泛型类型作为限定词的一种形式,使用元注解的支持来开发自定义的注解

l  General Web Improvements:使用新的@RestController注解来消除需要在每一个@RequestMapping方法增加@ResponseBody

l  WebSocket, SockJS, and STOMP Messaging:一个新的spring-websocket模块提供了对基于WebSocket的客户端和服务端之间的双向通信的强大支持

l  Testing Improvements:几乎所有spring-test模块下的注解现在都可以用来作为元注解来创建自定义的组合注解,来减少重复配置。Spring 4.0下的mocks接口集现在基于Servlet 3.0 API


 

玩的开心!^_^

分享到:
评论

相关推荐

    spring框架,技术详解及使用指导

    spring框架,技术详解及使用指导spring框架,技术详解及使用指导spring框架,技术详解及使用指导spring框架,技术详解及使用指导spring框架,技术详解及使用指导spring框架,技术详解及使用指导spring框架,技术详解及使用...

    Spring框架.ppt

    提供Spring框架的基本功能,其主要组件是BeanFactory,是工厂模式的实现。 Spring 上下文。向Spring 框架提供上下文信息,包括企业服务,如 JNDI、EJB、电子邮件、国际化、校验和调度等。 Spring AOP。通过配置管理...

    Spring框架的简单实现

    我们从一个简单的容器开始,一步步的重构,最后实现一个基本的Spring框架的雏形,为了帮助我们更加深入的理解Spring的IoC的原理和源码。 详细内容见博文: 【SSH进阶之路】一步步重构容器实现Spring框架——从一个...

    spring框架api中文版.zip(spring开发手册)

    即Spring框架的概述 1。 介绍Spring框架 1.1。 依赖注入和控制反转 1.2。 模块 1.2.1。 核心容器 1.2.2。 数据访问/集成 1.2.3。 web 1.2.4。 AOP和仪表 1 2 5。 测试 1.3。 使用场景 1.3.1。 依赖关系管理和命名...

    Spring框架文档 - 核心技术部分 中文版 - 第一部分.pdf

    本参考文档涵盖了Spring框架中绝对不可或缺的所有技术。 其中最重要的是Spring框架的控制反转(Inversion of Control,IoC)容器(container)。在对Spring框架的IoC容器进行全面介绍之后,将全面介绍Spring的面向切...

    Spring框架开发参考中文手册

    一本很好的快速学习Spring框架开发的指导手册,中文、PDF排版格式。

    Spring框架的前世今生已经源码构建.rar

    Spring框架的前世今生已经源码构建.rar

    Spring框架文档 - 核心技术部分 中英双语版 第二部分.pdf

    本参考文档涵盖了Spring框架中绝对不可或缺的所有技术。 其中最重要的是Spring框架的控制反转(Inversion of Control,IoC)容器(container)。在对Spring框架的IoC容器进行全面介绍之后,将全面介绍Spring的面向切...

    spring框架外文文献.docx

    毕业论文外文文献+中文翻译,选取spring框架外文文献并进行相应翻译。 The Spring Framework evolved from the code written for Expert One-on-One J2EE Design and Development by Rod Johnson (Wrox, 2002). The ...

    传智博客Spring框架2016版笔记资料.zip

    传智博客Spring框架2016版笔记资料 传智博客Spring框架2016版笔记资料 传智博客Spring框架2016版笔记资料 传智博客Spring框架2016版笔记资料 传智博客Spring框架2016版笔记资料

    Java Spring框架研究.docx

    Java Spring框架研究

    spring框架帮助文档

    spring框架帮助文档 能够帮助您解决spring框架里的一些难题

    Spring框架文档 - 核心技术部分 中文版 - 第二部分.pdf

    本参考文档涵盖了Spring框架中绝对不可或缺的所有技术。 其中最重要的是Spring框架的控制反转(Inversion of Control,IoC)容器(container)。在对Spring框架的IoC容器进行全面介绍之后,将全面介绍Spring的面向切...

    android的spring框架

    android的spring框架

    Spring框架学习 思维导图 【原创】

    自学自用的Spring框架学习路径,从IOC、AOP、SSM整合到事务管理,内容丰富。注:整合SpringMVC需要配合上传的SpringMVC思维导图一起学习

    spring框架2016

    最新spring框架2016视频教程,包含源码和笔记。小白入手实用教程。

    spring框架,技术详解及使用指导

    spring框架,技术详解及使用指导spring框架,技术详解及使用指导spring框架,技术详解及使用指导

    详细介绍Spring框架

    详细介绍了spring框架的核心内容以及怎么配置框架

    spring框架教程 PPT

    spring框架教程 PPT ppt

    spring框架快速入门

    struct、spring及hibernate是目前最为流行的框架,三者组合成为ssh,其中我最喜欢的就是spring框架,在此分享

Global site tag (gtag.js) - Google Analytics