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

Spring技术内幕1 Spring的设计理念和整理架构

2012-03-10 16:58 337 查看
1Spring的各个子项目

Spring Framework(Core):

The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of deployment platform. A key element of Spring is infrastructural support at
the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.

Spring includes:

Flexible dependency injection with XML and annotation-based configuration styles.

Advanced support for aspect-oriented programming with proxy-based and AspectJ-based variants.

Support for declarative transactions, declarative caching, declarative validation, and declarative formatting.

Powerful abstractions for working with common Java EE specifications such as JDBC, JPA, JTA and JMS.

First-class support for common open source frameworks such as Hibernate and Quartz.

A flexible web framework for building RESTful MVC applications and service endpoints.

Rich testing facilities for unit tests as well as for integration tests.

Spring Web Flow:

Spring Web Flow is a Spring MVC extension that allows implementing the "flows" of a web application. A flow encapsulates a sequence of steps that guide a user through the execution of some business task. It spans multiple
HTTP requests, has state, deals with transactional data, is reusable, and may be dynamic and long-running in nature.

Spring Web Flow provides a declarative flow definition language for authoring flows on a higher level of abstraction. It allows it to be integrated into a wide range of applications without any changes (to the flow programming
model) including Spring MVC, JSF, and even Portlet web applications.

Spring BlazeDS Integration:

Spring BlazeDS Integration is a top-level Spring project, and a component of the complete Spring Web stack. This project's purpose is to make it easier to build Spring-powered Rich Internet Applications using Adobe Flex
as the front-end client. It aims to achieve this purpose by providing first-class support for using the open source Adobe BlazeDS project and its powerful remoting and messaging facilities in combination with the familiar Spring programming model.

Spring Security:

Spring Security is a powerful and highly customizable authentication and access-control framework. It is the de-facto standard for securing Spring-based applications.

Spring Security OAuth:

The purpose of Spring Security OAuth is to provide an OAuth implementation for Spring Security. Support is provided for the implementation of OAuth providers and OAuth consumers.

Spring Dynamic Modules (Eclipse Gemini):

The Spring Dynamic Modules for OSGi(tm) Service Platforms project makes it easy to build Spring applications that run in an OSGi framework. A Spring application written in this way provides better separation of modules,
the ability to dynamically add, remove, and update modules in a running system, the ability to deploy multiple versions of a module simultaneously (and have clients automatically bind to the appropriate one), and a dynamic service model. OSGi is a registered
trademark of the OSGi Alliance. Project name is used pending approval from the OSGi Alliance.

Spring Batch:

Spring Batch is a lightweight, comprehensive batch framework designed to enable the development of robust batch applications vital for the daily operations of enterprise systems.

Spring Integration:

Spring Integration provides an extension of the Spring programming model to support the well-known Enterprise Integration Patterns. It enables lightweight messaging within Spring-based applications and supports integration
with external systems via declarative adapters. Those adapters provide a higher-level of abstraction over Spring's support for remoting, messaging, and scheduling. Spring Integration's primary goal is to provide a simple model for building enterprise integration
solutions while maintaining the separation of concerns that is essential for producing maintainable, testable code.

Spring AMQP:

The Spring AMQP project applies core Spring concepts to the development of AMQP-based messaging solutions. We provide a "template" as a high-level abstraction for sending and receiving messages. We also provide support for
Message-driven POJOs. These libraries facilitate management of AMQP resources while promoting the use of dependency injection and declarative configuration. In all of these cases, you will see similarities to the JMS support in the Spring Framework. The project
consists of both Java and .NET versions.

Spring for Android:

Spring for Android is an extension of the Spring Framework that aims to simplify the development of native Android applications.

Spring Mobile:

Spring Mobile is an extension to Spring MVC that aims to simplify the development of mobile web applications.

FEATURES

A Device resolver abstraction for server-side detection of mobile devices.

Site preference management that allows the user to indicate if he or she prefers a "normal" or "mobile" experience.

A site switcher capable of switching the user to the most appropriate site, either mobile or normal, based on his or her device and optionally indicated site preference.

Spring Social:

Spring Social is an extension of the Spring Framework that allows you to connect your applications with Software-as-a-Service (SaaS) providers such as Facebook and Twitter.

Spring Data:

Spring Data makes it easier to build Spring-powered applications that use new data access technologies such as non-relational databases, map-reduce frameworks, and cloud based data services as well as provide improved support
for relational database technologies.

........

2Spring的设计目标

在Java EE的应用开发中,支持POJO和使用JavaBean的开发方式,使应用面向接口开发,充分支持OO(面向对象)的设计方法。

轻量级,无需像EJB依赖J2EE应用服务器。

把依赖关系的管理从Java对象中解放出来,交给IoC容器通过IoC容器实现的依赖反转。

一方面,他通过IoC容器来管理POJO对象,以及他们相互之间的耦合关系,使企业的信息资源可以以简单的Java语言来抽象和描述;另一方面,可以通过AOP,以动态和非侵入式的方式来增强服务的功能。

Spring的设计理念--面向接口开发而不依赖于具体的产品实现。

实现AOP多种方式,比如他集成了AspectJ框架,同时也有ProxyFactory代理工厂的模式,而在代理工厂的实现中,既有直接使用JVM动态代理Proxy实现,也有使用第三方代理类库的CGLIB的实现。

3Spring的整体架构

划分为几个层次:

IoC容器、AOP核心模块、封装的Java EE服务、作为中间的驱动组件、其他作为上层的应用。

Spring的架构图:



Spring IoC:包含了最基本的IoC容器BeanFactory的接口和实现,还提供了一些列这个接口的实现。

Spring AOP:围绕着AOP增强功能,Spring继承了AspectJ作为AOP的一个特定实现,同时还在JVM动态代理/CGLIB的基础上,实现一个AOP框架,作为Spring继承其他模块的工具。在这个模块中,Spring AOP实现了一个完整的建立AOP代理对象,实现AOP拦截,直至实现各种Advice通知的过程。

Spring MVC:这个模块以DispatcherServlet为核心,实现了MVC模式,包括怎样与Web容器环境的继承,Web请求的拦击、分发、处理和ModelAndView数据的返回,以及如何集成各种UI视图展示和数据表现。

Spring JDBC/Spring ORM:对JDBC进行封装,提供了RDBMS的操作对象。同时对现有的ORM框架进行template等封装提供。

Spring的事务处理:Spring事务处理是通过Spring AOP实现自身功能增强的典型模块。在这个模块中,Spring把企业开发中事务处理的主要过程抽象出来,并且简单的通过AOP的切面增强实现了声明式事务的处理。

Spring远端调用:spring为应用屏蔽了各种通讯和调用细节的实现。可以使用HTTP调用器(以HTTP协议为基础),可以使用第三方的二进制通讯实现Hessian/Burlap,甚至还封装了传统Java技术中的RMI调用。

Spring应用:严格来说不属于Spring的范围。丰富了整个Spring生态圈,使Spring应用越来越广泛。

4Spring的应用场景

轻量级、简化应用开发的编程模型、模块之间的独立性比较强。

Spring是一个非侵入性(non-invasive)框架,其目标是使应用程序代码对框架的依赖性最小是。

Spring提供了一个一直的编程模型,使应用直接使用POJO开发,从而可以和运行环境隔离开来。

Spring推动应用的设计风格向面向对象和面向接口编程转变,提高了代码的重用性和可测试性。

Spring改进了体系结构的选择。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐