01Spring框架介绍

Spring设计的初衷

spring设计的初衷是为了解决企业级应用开发的复杂性,简化开发

使用的关键策略:

  1. 基于POJO的轻量级和最小入侵性编程
  2. 通过依赖注入和面向接口松耦合
  3. 基于切面和惯性进行声明式编程
  4. 通过切面和模板减少样版式代码

核心:BOP面向bean、DI依赖注入、AOP面向切面编程

 

BOP

BOP(Bean Oriented Programming)面向Bean编程是spring的关键核心,就如同面向对象编程OOP中的Object;

Spring提供IOC容器通过配置文件或者注解方式来管理对象之间的依赖关系

控制反转的实现方式有依赖注入(Dependency Injection,DI)和依赖查找(Dependency Lookup,DL)其中最常使用的是依赖注入(spring中已经移除依赖查找)

 

控制反转的基本概念:不负责创建对象,但是描述创建对象的方式,在代码中不直接与对象和服务连接,但在配置文件中描述服务对组件的依赖关系

 

容器负载将对象创建和对象创建的方式联系起来,容器创建了所有对象,并设置必要的属性将它们连接在一起,决定什么时间调用方法

 

依赖注入

在对象创建的过程中,容器根据描述文件描述的依赖关系,将对象所需要的组件注入;

 

IOC将处理事情的责任从应用程序代码转移到框架,Bean工厂是spring的IOC实现的基础。

Bean工厂的实现是BeanFactory,其底层支持的对象模型有单例和原型:

单例:提供具有特定名称的全局共享实例对象,可以在查询时对其检索,默认的对象模型;

原型:确保每次检索都会创建一个独立的对象,在每个用户都需要自己的对象的时候使用原型。

 

AOP

面向切面编程是一种思想,将对象职责进行模块化的思想(个人意见)。AOP的核心构造是切面,将影响类的行为封装到可重用的模块中。常用的是将业务代码和日志分离,通过构建切面,将日志相关的内容都移入切面中,业务代码不再需要关注日志信息。

 

AOP编程常用场景:Authentication(权限认证)、Auto Caching(自动缓存处理)、Error Handling(统一错误处理)、Debugging(调试信息输出)、Logging(日志记录)、Transactions(事务处理)

 

spring框架

Core Container:核心容器

主要由spring-beans、spring-core、spring-context、spring-expression组成

spring-core和spring-beans是spring框架的核心模块,包含控制反转和依赖注入

spring-context模块架构于核心模块之上,为bean添加生命周期控制,框架事件体系以及资源加载透明化等功能

spring-expression模块是统一表达式语言扩展模块

AOP、Aspect、Instrument

AOP是以JVM的动态代理技术为基础,然后设计出一系列的AOP切点增强

Spring-aspects模块集成AspectJ框架,主要为spring AOP提供多种AOP实现方法

Spring-instrument模块是基于JAVA SE中java.lang.instrument设计,在JVM启用时生成代理类,通过运行时修改类的字节,从而实现改变一个类的功能

Data Access

spring-jdbc提供JDBC抽象框架的主要实现模块,简化JDBC操作

spring-tx为spring JDBC事务控制实现的模块

Web

spring-web围殴spring提供基础的web支持

spring-webmvc是一个web-servlet模型,实现Spring MVC的web应用

spring-websocket主要是与web前端的全双工通信的协议

Spring-webflux一个新的NIO的reactive web框架

Messaging

spring-messaging是spring4引入的用作报文传送的模块

 

Test

spring-test为测试提供支持

 

原文地址:https://mp.weixin.qq.com/s?__biz=MzI5MzE4MzYxMw==&mid=2247487448&idx=1&sn=0e13e96cbfc8d41bf02576d9b1d4d24c&source=41#wechat_redirect

 

 

Spring Boot Messaging: Messaging APIs for Enterprise and Integration Solutions by Felipe Gutierrez English | 5 Jun. 2017 | ISBN: 1484212258 | 196 Pages | PDF | 6.36 MB Build messaging applications using the power of Spring Boot; use Spring application events over the Web; use WebSocket, SockJS, and STOMP messaging with Spring MVC; and use Spring JMS, Redis Pub/Sub and Spring AMQP for reliable messaging solutions. This book covers all the Spring Messaging APIs using Spring Boot. Written by a Pivotal engineer, Spring Boot Messaging is an authoritative guide to the many messaging APIs and how to use these for creating enterprise and integration solutions. You will learn and integrate these messaging APIs with more complex enterprise and cloud applications: for example, you will see how to use Spring Cloud Stream for creating message-driven and cloud native microservices. In addition, you’ll discover the new Spring Integration DSL and use it with Spring Cloud Stream to build integration solutions using every enterprise integration pattern. Finally, you’ll see Spring Reactor and Spring Cloud to take your application to the next level. After reading this book, you will come away with a case study application walk-through and will be able to use it as a template for building your own Spring messaging applications or messaging features within your enterprise or cloud application. What You'll Learn Use the main Spring messaging APIs with Spring Framework 5 Build messaging applications over the Web Use WebSocket, SockJS, and STOMP messaging Integrate Spring JMS and Spring AMQP into your applications Work with Spring Cloud Stream and microservices Who This Book Is For Enterprise Java developers who have at least some previous experience with the Spring Framework and/or the Spring platform.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值