Spring's overall architecture and environment (1)

1. Overall architecture

Spring is a layered architecture, it contains a series of functional elements, and is divided into about 20 modules, as shown in the figure:

Spring architecture diagram
These modules are summarized as follows:

① Core Containe

Core Container (The core container) contains Beans、Core、Contextand Expression Language. Core and Beans are the basic modules of the framework, controlling IOC (Control Inversion) and DI (Dependency Injection).

  • CoreThe module mainly contains the basic core tool classes of the Spring framework. All other Spring components need to depend on the classes in this package. The Core module is the basic core of other components.
  • BeansModules are needed by all applications. It includes all classes related to accessing configuration files, creating and managing beans, and performing IOC / DI operations.
  • ContextThe module is built on the basis of the Core and Beans modules, and provides a framework-like object access method similar to the JNDI registrar. Context integrates the special features of Beans, provides a lot of expansion for the Spring core, adds internationalization, event propagation, resource loading, and support for the transparent creation of Context. Context colleagues also support some features of J2EE, such as EJB, JMX and basic remote processing. The ApplicationContext interface is the key to the Context module.
  • Experssion LanguageAn expression language is provided for querying and manipulating objects at runtime. It is an extension of the unifed expression language defined in the JSP2 specification. The language supports setting / getting the attribute values ​​of objects, the assignment of attributes, the invocation of methods, access to digital online text, containers and indexers, logical and arithmetic operators, and named variables And retrieve objects by name from Spring's IOC container. It also supports list projection, selection and general list aggregation.

② Data Access / Integration
Data Access/Integrationlayer contains JDBC、ORM、OXM、JMSand Transactionmodules.

  • JDBCThe module provides a JDBC abstraction layer, eliminating lengthy JDBC coding and parsing database vendor-specific error codes.
  • ORMPopular object-relational mapping API. Such JPAas: JDO, Hibernate, , iBatisetc., to provide an interactive layer.
  • OXM Provides an abstraction layer for Object / XML mapping matters.
  • JMS Encapsulates the sending and receiving of messages.
  • Transaction Supports programmatic and declarative transaction management.

③ Web

The Web context module is built on the application context module and provides context for Web-based applications. Therefore, the Spring framework supports integration with Jakarta Struts. The Web module also simplifies handling most requests and binding request parameters to domain objects. Web module contains the main Web, Web-Servlet, Web-Strutsand Web-Porletmodules.

  • Web module: provides basic Web-oriented integration features. For example: file upload, using servlet listeners to initialize the IOV container and a web-oriented application context.
  • Web-Servlet Mainly encapsulates some features of Spring MVC.
  • Web-Struts Encapsulated support for Struts, which has been deprecated in Spring 3.0.
  • Web-Porlet Provides MVC implementation of Porlet environment and Web-Servlet module.

④ AOP

Provides an aspect-oriented implementation. Applicants can define method interceptors and pointcuts to separate logic and code for decoupling purposes.

⑤ Test

The Test module supports testing of Spring using JUnit and TestNg.

2. Environment construction

① Source code pull:
https://github.com/spring-projects/spring-framework

② IDEA import

③ Solve the compilation error of cglib and obienesis

Cause of the problem: In order to avoid conflicts with third-party classes, Spring repackaged the latest cglib and obienesis. It did not provide this part of the code in the source code, but put it directly in the jar package, which caused After we pull the code and import it, a compilation error occurs.

Open Gradle on the right side of IDEA, select spring-core, and execute cglibRepackJar and objenesisRepackJar under other to automatically introduce the two missing dependencies.

Cglib and obienesis compilation error resolved
Subsequent code analysis will be based on 5.2.5.Release version for analysis and study.
Insert picture description here

Published 41 original articles · Liked 14 · Visitors 10,000+

Guess you like

Origin blog.csdn.net/Yunwei_Zheng/article/details/104039806