Spring-窺探

https://spring.io/

一、Spring整體架構

1.1 Why?

Spring makes programming Java quicker, easier, and safer for everybody. Spring’s focus on speed, simplicity, and productivity has made it the world's most popular Java framework.

1.2 What?

Features

  • Core technologies: dependency injection, events, resources, i18n, validation, data binding, type conversion, SpEL, AOP.

  • Testing: mock objects, TestContext framework, Spring MVC Test, WebTestClient.

  • Data Access: transactions, DAO support, JDBC, ORM, Marshalling XML.

  • Spring MVC and Spring WebFlux web frameworks.

  • Integration: remoting, JMS, JCA, JMX, email, tasks, scheduling, cache.

  • Languages: Kotlin, Groovy, dynamic languages.

  1. 2.1 核心容器(Core Container)

包含模塊spring-core, spring-beans, spring-context, spring-context-support,spring-expression.

  • spring-core 主要包含Spring框架基本的核心工具類
  • spring-beans 包含訪問配置文件、創建和管理bean以及進行IoC/DI操作的相關類. BeanFactory
  • spring-context 構建與Core和Beans之上,繼承了Beans的特性,擴展添加了國際化、時間傳播、資源加載和對Context的創建和支持。ApplicationContext
  • spring-expression提供 一個強大的表達式語言用於在運行時查詢和操作對象,該語言支持設置/獲取屬性值,屬性的分配,方法的調用,訪問數組上下文、容器和索引器、邏輯和算是運算符、命名變量以及從Spring的容器中根據名稱檢索對象
  1. 2.2 AOP和Instrumentation

包含模塊spring-aop, spring-aspects, spring-instrument, spring-instrument-tomcat

  • spring-aop 提供了一個AOP聯盟標準的面向方面編程的實現,它允許你定義方法攔截器與切入點,從而將邏輯代碼與實現函數進行分離。
  • spring-aspects 提供了與AspectJ的集成
  • spring-instrument 提供了類工具的支持與classloader的實現,以便在特定的應用服務上使用。
  • spring-instrument-tomcat 包含了spring對於Tomcat的代理
  1. 2.3 消息(Messaging)

spring framework 4 包含了spring-messaging模塊,其中使用了來自於spring integration項目的關鍵抽象,如Message, MessageChannel, MessageHandler等,他們可以作爲基於消息的應用服務的基礎。該模塊還包含了一組可將消息映射到方法的註解,類似於spring-mvc的編程模型.

  1. 2.4 數據訪問/集成(Data Access/ Integration)

包含spring-jdbc, spring-tx, spring-orm, spring-oxm, spring-jms.

  • spring-jdbc 提供了JDBC抽象層,消除了冗長的JDBC編碼和解析數據庫廠商特有的錯誤代碼.
  • spring-tx 爲實現了特定接口的類提供了可編程的聲明式事務管理支持,對所有的POJOs都適用
  • spring-orm 提供了對象相關映射(ORM)集成,包含JPA, JDO, Hibernate,使用spring-orm模塊可以將這些框架與spring提供的特性結合在一起使用,比如事務管理.
  • spring-oxm 提供了對Object/Xml Mapping實現的抽象,包括JAXB,Castor, XMLBeans, JiBX以及XStream.
  • spring-jms 包含了一些生產和消費消息的特性,從spring Framework 4.1開始,提供了與spring-messaging集成.
  1. 2.5 Web

包含spring-web, spring-webmvc, spring-websocket, spring-webmvc-portlet

  • spring-web提供了基於面向web集成的特性,如多文件上傳功能、通過servlet listener初始化IoC容器與面向web的ApplicationContext,它還包含了HTTP客戶端與Spring遠程支持的web相關的部分.
  • spring-webmvc(又名web-servlet)包含了Spring對於Web應用的MVC與REST實現,Spring MVC框架提供了領域模型代碼和Web表單之間的分離,並集成了Spring框架的所有其他特性.
  • spring-webmvc-portlet(又名web-portlet)提供了基於Portlet環境使用MVC的實現.
  1. 2.6 Test
  • spring-test模塊支持Spring組件與JUnit或TestNG 的單元測試和 集成測試。它提供了Spring 的一致加載ApplicationContext和這些上下文的緩存。它還提供了可用於隔離測試代碼的模擬對象

 

二、Spring技術核心

 

 

 

三、實踐

手寫spring

https://blog.csdn.net/litianxiang_kaola/article/details/86646947

https://www.jianshu.com/p/f57db8b29be9

 

 

 

 

 

 

 

 

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章