Architecture and directory structure of Spring framework

Spring is a layered JavaEE/SE one-stop (full stack) lightweight development framework rented and developed by Rob Jonson. His core ideas are Inversion of Control IOC and Aspect Oriented Programming , aop) programming, in which IoC is the foundation of Spring, which supports Spring's management function for Java Beans; Aop is an important feature of Spring, and AOP realizes program functions through pre-compiled methods and dynamic agents during operation, that is, without In the case of modifying the code, add functions uniformly to the program.
Spring runs through the presentation layer, business logic layer and persistence layer:
Spring MVC framework is provided in the presentation layer.
The business logic layer can manage transactions and record logs. The
persistence layer can integrate MyBatis, Hibernate, JDBCTemplate and other technologies.
Spring is modular and allows Users only choose to use their own modules. The Spring framework adopts a layered architecture and is divided into 21 modules according to different functions, mainly divided into 8 modules.
insert image description here

1. Core container

Spring's core container is the foundation of other modules, plays a supporting role in Spring's functional system, and is the cornerstone of other modules. It is composed of Beans module, Core core module, Context context module and SpEL expression language module. Without these core containers, it is impossible to have upper layer functions such as AOP and Web. The details are as follows.

Beans module

The Bean module provides the BeanFactory class, which is a classic implementation of the factory pattern. The main function of the Bean module is to create and manage Bean objects.

Core core module

It encapsulates the underlying parts of the Spring framework, including resource access, type conversion, and some common tool classes. Provides the basic components of the Spring framework, including Ioc and DI

Context context module

Context is built on the basis of Core and Beans modules, integrates Beans module functions and adds resource binding, data validation, internationalization, Java EE support, container life cycle, event propagation, etc. The ApplicationContext interface is the focus of the context module.

SpEL module

The SpEL (Spring Expression Language) module is a new module after Spring 3.0, which provides powerful expression language support, supports accessing and modifying attribute values, method calls, supports accessing and modifying arrays, containers and indexers, named variables, and supports Arithmetic and logical operations, support to get beans from the Spring container, it also supports list projection, selection and general list aggregation, etc.

2. Data Access/Integration

The data access/integration layer includes JDBC, ORM, OXM, JMS and Transactions modules, their details are as follows:

JDBC module

The JDBC-Java Data Base Connectivity module provides a JDBC abstraction layer that eliminates tedious JDBC coding and parsing of database vendor-specific error codes.

ORM module

The ORM-Object Relational Mapping module provides integration with popular object-relational mapping APIs, including JPA, JDO, and Hibernate. Through this module, these ORM frameworks can be integrated with other functions of spring.

OXM module

The OXM-Object XML Mapping module provides support for OXM implementations, such as JAXB, Castor, XML Beans, JiBX, XStream and so on.

JMS module

The JMS-Java Messaging Service module contains functions for producing and consuming messages. Starting from Spring 4.1, the spring-messaging module is integrated.

Transactions module

The transaction module supports programmatic and declarative transaction management for implementing special interface classes and all POJOs. (Note: Programmatic transactions need to write transaction management methods such as beginTransaction(), commit(), rollback(), etc. Declarative transactions are automatically processed by spring through annotations or configuration, and the granularity of programmatic transactions is finer)

web module

The implementation of the Web module is based on ApplicationContext, which provides various tool classes for Web applications, including Web-Socket, Servlet, Web and Portlet. Their details are as follows:

Web-Socket module

The Web-Socket module is a new module after Spring 4.0, which provides the implementation of WebSocket and SockJS, and provides two ways of communication between the client and the server in the web application.

Servlet module

The Servlet module provides implementations of Spring's models, views, controllers, and Rest web services for web applications.

web module

The Web module provides integrated features for Web development, such as most file upload functions, etc. In addition, the Web module also contains a client and Web-related parts supported by Spring remoting.

Portlet module

The function of the Portlet module is similar to that of the Servlet module, providing an MVC implementation for the Portlet environment and reflecting the functions of the spring-webmvc module.

4. Other modules

There are other important modules like AOP, Aspects, Instrumentation, Web and Testing modules, their details are as follows:

AOP module

The AOP module provides an aspect-oriented (aspect) programming implementation, allowing you to define method interceptors and pointcuts to cleanly decouple the code, so that the code that implements the function is completely decoupled. Using source-level metadata, behavioral information can be incorporated into code in a manner similar to .Net properties.

Aspects module

The Aspects module provides integration with AspectJ, a powerful and mature aspect-oriented programming (AOP) framework.
Instrumentation module I
The instrumentation module provides the support of class instrumentation and the realization of class loader in a certain application server.
The Messaging Module
The Messaging Module provides support for STOMP as a WebSocket subprotocol for use in applications. It also supports an annotated programming model for routing and handling STOMP messages from WebSocket clients.

Test module

The test module supports testing of Spring components with JUnit or TestNG frameworks.
Dependencies between commonly used modules
insert image description here

spring directory structure

https://repo.spring.io/ui/native/release/org/springframework/spring/
After downloading and decompressing, there are 3 folders: docs, libs, schema

docs folder

This folder stores Spring-related documents, including development guides and API reference documents

libs folder

The jar package and source code required for development are stored in this folder. The entire spring framework is composed of 21 modules. In the libs directory, spring provides 3 compressed packages for each module. Therefore, there are 63 compressed packages in the libs folder. The 63 compressed packages are divided into three categories:
the JAR package ending with RELEASE.jar is the class file of the Spring framework
The JAR package ending with RELEASE-javadoc.jar is the compressed package of the API documentation of the Spring framework
ending with RELEASE-source.jar The JAR package is a compressed package of the source code of the Spring framework

schema folder

The XML Schema documents of various spring configuration files are stored in this folder

Notice

When using spring development, in addition to using the built-in jar package, the core container of spring also needs the commons-logging jar package.

Guess you like

Origin blog.csdn.net/yandao/article/details/130865180