Past and Present and system architecture Spring Framework

Issue

" Past and Present of the Spring Framework and System Overview"

Course targets

1, through the study of this chapter, you can master the dependencies between the basic structure and each sub-module of Spring.

2, understand Spirng history, thought-provoking.

3, on the Spring form an overall understanding, after laying the groundwork for further study.

4, through the study of this chapter, you can understand the laws of Spring version upgrade, in order to apply to their system upgraded version named.

5, using Gradle build Spring5 source.

Content targeting

Spring experience 1--5 years, the hope of better understanding Spring source crowd.

Course Outline

Chapter One: the Spring Past and Present

1, everything from the beginning Bean

 

 

 

2, Spring is designed to

Simplify development

Spring simplify the development of the four basic strategies
  • Lightweight and minimally invasive programming of POJO
  • By loosely coupled to interfaces and dependency injection
  • Declarative programming based on section and inertia
  • Reduce boilerplate code via cut and templates

3, BOP program beginning

4, the basic concept of dependency injection

5, AOP programming concept

 

 

 

Chapter Two: Spring5 System Architecture

Spring total of about 20 modules, a plurality of files of different configuration 1300. These components are respectively integrated in a core container (Core
Container), AOP (Aspect Oriented Programming) and device support (Instrmentation), Data Access
And integration (Data Access / Integeration), Web, send messages (Messaging), Test, 6 modules collection. With
Spring block is the structure of Figure 5: 
Spring framework composed of a set of modules or each module may be present alone, may be combined to achieve one or more modules. Each module
Composition and function block is as follows: 

The core container

由spring-beans、spring-core、spring-context和spring-expression(Spring Expression Language,
SpEL) 4 modules.
spring-core and spring-beans module is the core module of the Spring Framework, comprising the inversion of control (Inversion of
Control, IOC), and dependency injection (Dependency Injection, DI). BeanFactory interface is the core Spring Framework
Heart interface, which is the realization of the factory model. BeanFactory inversion of control configuration application and the dependence of the actual specifications
Application code were separated. However BeanFactory container instantiated does not automatically instantiate Bean, Bean is only when
Bean BeanFactory the container will be instantiated and is assembled using dependencies.
spring-context module architecture on top of the core module, he extends BeanFactory, adding the Bean lifecycle control for her
System, system event framework and transparent resource loading and other functions. In addition, the module also provides a number of enterprise-level support, such as e-mail access, far
Cheng visit, task scheduling, ApplicationContext is the core interface of the module, she superclass is BeanFactory. versus
Different BeanFactory, all automatically Bean single instance is instantiated by the container rear ApplicationContext instantiation
Lai assembled relationship, so that in the standby state.
spring-context-support module is an extension support for Spring IOC containers, sub-containers and IOC.
spring-context-indexer module Spring class management component and Classpath scanning.
spring-expression modules are unified expression language (EL) expansion module, you can query, management and operation of the object, with
When the calling object may also convenient method, an array operation, set the like. Its syntax is similar to the conventional EL, but provides additional features, the most
Excellent template function to the number of function calls and a simple string. Characteristics of the language is based on the needs of the Spring product design, he
It can easily interact with Spring IOC. 

AOP and device support

A spring-aop, spring-aspects and spring-instrument 3 modules.
Spring is spring-aop another core module, AOP is the main implementation module. As Following OOP, a programmer shadow
One of the largest ring of programming ideas, AOP has greatly opened up people's ideas for programming. In Spring, he is a dynamic JVM
Agent technology, and then design a series of crosscutting AOP implementations, such as pre-notification, return, throws advice etc., with
When, the interface to match Pointcut entry point can be designed using existing pointcut cross-section, may be extended on demand related method
Be cut.
spring-aspects module integrates self AspectJ frame, mainly to provide a variety of implementations of AOP Spring AOP.
spring-instrument module is based on the JAVA SE "java.lang.instrument" design, and should be regarded as AOP
A support module, the main role is to enable the JVM to generate a proxy class, programmers modified at run time by proxy class class
Bytes, thereby changing the functionality of a class, to achieve AOP function. In the classification, I put him in a minute under AOP module, the official Spring
Party documentation a bit vague on this place, this is purely personal point of view.

Data Access and Integration

A spring-jdbc, spring-tx, spring-orm, spring-jms and spring-oxm 5 modules.
spring-jdbc implementation module is the main module JDBC abstraction framework provided by Spring, Spring JDBC for simplified operation.
The main way to provide JDBC template, relational database object-oriented way, SimpleJdbc way, transaction management to simplify JDBC programming,
The main implementation class is JdbcTemplate, SimpleJdbcTemplate and NamedParameterJdbcTemplate.
spring-tx Spring JDBC transaction control module is a module implemented. Using the Spring framework, it matters done a very good package,
Through its AOP configuration, flexible configuration at any level; but in many needs and applications, direct transaction control using JDBC
The system still has its advantages. In fact, business is business logic-based; a method in the business layer should correspond to a complete business;
If the business fails, the entire transaction is rolled back; therefore, it is absolutely transaction control should be placed in the service layer; however, the persistence layer design
It should follow a very important principle: atomicity operations to ensure that the persistence layer in each method should not be divided. The
So, when using Spring JDBC transaction control, it should pay attention to its particularity.
spring-orm ORM framework support module module is mainly integrated Hibernate, Java Persistence API (JPA) and
Java Data Objects (JDO) for resource management, Data Access Objects (DAO) implementation and transaction strategies.
spring-oxm main module provides an abstraction layer to support OXM (OXM is Object-to-XML-Mapping Abbreviation,
It is an O / M-mapper, mapping java object into XML data, or XML data into mapped java object), for example:
JAXB, Castor, XMLBeans, JiBX and XStream and so on.
spring-jms module (Java Messaging Service) to send and receive information to from the Spring Framework 4.1
After, he also provided support for the spring-messaging module. 

Web Components

The spring-web, spring-webmvc, spring-websocket and spring-webflux 4 modules.
spring-web module Spring provides the most basic Web support, mainly built on top of the core container, or by Servlet
Listeners who to initialize the IOC container, also includes some Web-related support.
spring-webmvc module is a well-known of Web-Servlet module, the Spring MVC
(Model-view-Controller) Web applications.
spring-websocket module is mainly full-duplex communication protocol with the Web front-end.
spring-webflux is a new non-blocking functional Reactive Web frame, can be used to establish an asynchronous, non-blocking,
Event-driven service, and scalability is very good. 

Communication 报文

I.e., spring-messaging module is newly added from the beginning Spring4 a module, the main duty is to set the Spring Framework
Into a number of messaging-based applications. 

Integration Testing

That spring-test module, providing support for the main test, after all, does not need to release (program) to your application server or connection
To the case of other business facilities able to perform some integration testing or other testing for any business it is very important.

Dependencies between modules

Spring official website of the relationship between the various modules Spring5 a detailed description:

 

 

 

 

 

 

I am also Spring5 modules summarized a system of dependencies between modules description, hoping for little friends
help.

 

 

Chapter Three: the Spring version naming rules

1, common software version number naming rules

 

 

2, semantic version naming the prevailing rules

 

 

 

3, common commercial software qualifiers

 

 

4, the software version number of defined

To facilitate understanding, brief version of the grammar is defined as [Range Description] <described version number>
Description Optional range must be equipped version and description to determine the scope, can not exist independently
<Less than a version number
<= Less than or equal to the version number of a foam cushions produced, will be fine www.gupaoedu.com
> Greater than a certain version number
> = Greater than or equal to a version number
= Equal to a version number, it does not make sense to write and direct the same as the version number
- The latest version is based on the version number of patches described
^ Based on the latest version number described compatible version
- a range, he should appear in the middle of the two versions is described, in fact, the syntax should be <version description> - <version description>, in order to write here
Unite
Strictly speaking, the expression of ~, ^ package requires a combination of specific management tools and rules to determine the version number, but keep in mind the following for general use
in principle:
^ Is to ensure version compatibility, the default limit constraints on the minor version number
When - is to ensure version compatibility, default constraints on the number of patches 

5, Spring version naming rules

 

 

Chapter IV: the Spring source code download and build skills

1, Spring5 source download Notes

First, you'll need to upgrade to JDK 1.8 or higher. Spring3.0 start, Spring source using github hosting, no longer provides official website to download
link. Do not make too much to say, you can go to github own website, we use version download link is:
After https://github.com/spring-projects/spring-framework/archive/v5.0.2.RELEASE.zip the download is complete,
Extract the source package will see the following files in the directory

2, based on building skills Gradle source

Because after Spirng5 are compiled using Gradle, so you need to install before building the source Gradle environment. Gradle to download
Address: https: //gradle.org/releases, I recommend using a Spring5 official version Gradle4.0, download links are:
https://gradle.org/next-steps/?version=4.0&format=bin, the download is complete the following steps to
Windows operating system as an example:
Step 1: Configure environment variables 
Step two: Add the environment variable: Path:% GRADLE_HOME% \ bin
The third step: detecting the environment, gradle -v command input, to give the following results
Step four: compile source code, cmd cut to the spring-framework-5.0.2.RELEASE directory, run gradlew.bat 
Step five: Convert to eclipse the project, before executing the import-into-eclipse.bat command, build, make sure that a good network, press
Any key to continue.
Step Six: Wait for building a successful (if an error occurs midway, most cases are due to network interruption caused after retries can usually be resolved
Questions), after building a successful, it will appear the following interface:

 

 

Up to this point, Eclipse still using a small partner can have in the project into Eclipse. And we recommend the use of IDEA
Also more intelligent, it can be directly compatible with the Eclipse project. Next, look at the following steps:
Step Seven: Import IDEA. Open IntelliJ IDEA, click Import Project, the following interface pops up, select
spring-framework-5.0.2.RELEASE folder: 

 

Step eight: waiting constructed, in good network conditions takes about 10 minutes to complete the automated build, you will see the following interface:
Step 9: In the IDEA, if after subproject files in the folder Project bold words, explained that it had successfully constructed. There is also a
Authentication is: find ApplicationContext class, press Ctrl + Shift + Alt + U, appeared class diagram interface instructions for building success.
If I have to build a good "spring-framework-5.0.2.RELEASE- Chinese version of Notes", submitted to the Git, after downloading the import into IDEA
Out of the box, without having to repeat construct. 
 

3, Gradle build process pit

If the project environment has been unable to build the project folder has not changed in bold, class diagrams can not be generated automatically. Then you must step on such a pit.
Step 1: Open View-> Tool Windows -> Gradle
 
Then, click on the right Gradle view Refresh, the following error occurs:
 
Step Two: Look mistake, apparently nothing to do with Gradle, solution:
1. Turn off the IDEA, open the Task Manager to end all processes associated with java.
2. Locate the JAVA_HOME -> jre -> lib directory, rename tools.jar tools.jar.bak.
3. Restart IDEA, click refresh again, waiting for the build. 
 
 
 

Pre-class preparation

1, advance registration ProcessOn account, https: //processon.com.

2. Download and extract the source package, temporarily without the need to build, advance understanding of the structure of the source code has been downloaded, thinking that naming rules. Download: https: //github.com/spring-projects/spring-framework/archive/v5.0.2.RELEASE.zip

3, self-earlier access to relevant information in accordance with the syllabus.

4, recommended books: "Spring in Action"

5, recommended books: "Spring Definitive Guide"

 

Pre-class preparation

1, advance registration ProcessOn account, https: //processon.com.

2. Download and extract the source package, temporarily without the need to build, advance understanding of the structure of the source code has been downloaded, thinking that naming rules. Download: https: //github.com/spring-projects/spring-framework/archive/v5.0.2.RELEASE.zip

3, self-earlier access to relevant information in accordance with the syllabus.

4, recommended books: "Spring in Action"

5, recommended books: "Spring Definitive Guide"

 

after class homework

contents of homework

1, using ProcessOn Spring rendering system architecture of FIG.

2, organize notes, fully understand the dependencies between modules Spring.

3, be appreciated SpringIOC vessel core, generating class diagram.

4, installation configuration Gradle environment, building Spring source.

 

Guess you like

Origin www.cnblogs.com/MrZhouZ/p/11530578.html