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

码农小汪-spring框架学习之1-spring简单的介绍入门

2016-04-10 19:46 706 查看

Spring框架的概述

Spring框架是一个轻量级的解决方案和一个潜在的一站式服务 构建企业级应用程序。 然而,spring是模块化的,允许你 只使用那些你需要的部分,没有其他。 您可以使用 IoC容器,任何web框架上,但你也可以只使用Hibernate集成代码或者是JDBC抽象 层。 Spring框架支持声明式事务管理、远程访问 你的逻辑通过RMI或web服务和持久化数据的各种选项。 它提供了一个功能齐全的MVC框架,使您可以 集成AOP透明地到你的软件。

依赖注入和控制反转 Dependency Injection and Inversion of Control

Spring框架控制反转(IoC)组件的的解决了这个问题 提供一个正式的方式不同的组件组合成一个完全工作 应用程序可以使用了。 Spring框架把正式的设计模式 一类对象,您可以集成到您自己的应用程序。 众多 以这种方式组织和机构使用Spring框架,工程师 健壮的、可维护的应用程序。

模块化 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), Spring框架的功能组织成大约20个模块。 这些模块 分为核心容器的、数据访问/集成、网络,AOP(面向方面的吗 编程)

框架整体概述



核心容器

The Core Container consists of the Core, Beans, Context, and Expression Language modules.

Core and Beans:

including the IoC and Dependency Injection features.(控制反转和依赖注入) The BeanFactory is a sophisticated implementation of the factory pattern. 这个是一个BeanFactory的一个复杂的工厂模式的实现。消除了,通过编程实现单列模式和允许你解耦程序中的依赖关系,从实际的编程中逃脱出来。这个我最近使用过的,根本不需要new,直接简单的实现了很多的东西。非常的方便。

Context

The Context module builds on the solid base provided by the Core and Beans modules:访问对象的一种手段 framework-style方式类似于一个JNDI注册表.

上下文模块继承 其功能从bean模块和增加了对国际化的支持(使用, 例子中,资源包)、事件传播资源载入,透明 创建上下文,例如,一个servlet容器.

The Context module also supports Java EE features such as EJB, JMX ,and basic remoting. The ApplicationContext 接口是这个模块的最重要的

数据访问和集成

The Data Access/Integration layer consists of the JDBC, ORM, OXM, JMS and Transaction modules. 数据访问的继承包括了JDBC

面向对象关系数据库 OXM,JMX 和失误处理的模块。哈哈有的我根本看不懂,没关系。我们基本上使用Hibernate。这个Spring又不是专门给Hibernate使用的,所以我们还是可以接受的。

网络模块 Web

spring有自己的MVC模块的哦,也可以是使用Struct2也是可以的哦。

网络层由Web、Web-Servlet WebSocket和Web-Portlet模块。

网络模块提供基本的面向web集成等特性 多部分文件上传功能和IoC容器使用的初始化 servlet侦听器和一个面向web应用程序上下文。 它还包含了 Spring的web部分远程支持。

Web-Servlet模块包含Spring的模型-视图-控制器 (MVC)实现web应用程序。 Spring的MVC 框架提供了一个干净的分离和web表单域模型代码,和 与Spring框架的所有其他功能集成。

The Web-Portlet module provides the MVC implementation to be used in a portlet environment and mirrors the functionality of Web-Servlet module.

AOP and Instrumentation(面向切面编程),处理事务的

AOP模块提供了一个AOP联盟兼容的 面向方面的编程实现允许您定义,例如, method-interceptors和切入点干净地分离代码实现的功能 应该分开

使用的场景

典型的成熟的Spring web应用程序



Spring’s declarative transaction management features make the web application fully transactional事务管理, just as it would be if you used EJB container-managed transactions. All your custom business logic can be implemented with simple POJOs and managed by Spring’s IoC container. Additional services include support for sending email and validation that is independent of the web layer发动EMAIL 和拦截器机制, which lets you choose where to execute validation rules. Spring’s ORM support is integrated with JPA, Hibernate and and JDO;继承持久层 for example, when using Hibernate, you can continue to use your existing mapping files and standard Hibernate SessionFactory configuration. Form controllers seamlessly integrate the web-layer with the domain model, removing the need for ActionForms or other classes that transform HTTP parameters to values for your domain model.

还是原滋原味的好,我在看李刚的这本书,但是还是觉得原滋原味的比较好。自己也是比较好理解。不懂翻译嘛!

中间层使用第三方web框架



这个比价好理解吧,最近我使用SSH做的后台就是使用的这种模式吧,感觉还行,年轻人多学点没事的,反正还年轻,能学习的东西还是比较的多的,养活自己还是没得事的吧!

有时情况不允许你完全切换到一个不同的框架。 Spring框架是不强迫你使用一切在它;它不是一个孤注一掷的解决方案。 现有的前端由Struts,Tapestry,JSF 或其他UI框架可以集成基于spring的中间层,它允许 你使用Spring事务特性。 你只需要连接您的业务逻辑 使用一个ApplicationContext和使用WebApplicationContext将你的网页 层。

Remoting使用场景



当你需要通过web服务访问现有的代码,您可以使用Spring的Hessian-,Burlap-,Rmi-或JaxRpcProxyFactory类。 启用远程访问 现有的应用程序并不难。

看到了好多的东西,其实想要学好这些东西,需要时间和经验的积累,慢慢的掌握了!这今天忙去做别的事情了,写博客的时间都比较的少了。这几天再次继续的写吧!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: