2. Main modules of spring and 2. Functions of spring
Spring contains about 20 modules, including the following:
1. Core Container
Core Container (Core Container) contains Core, Beans, Context, and Expression Language modules.
Core and Beans are the basic parts of spring and provide IOC and dependency injection features. The basic concept is BeanFactory, which provides the classic Implementation of the Factory mode to eliminate the requirements for the procedural Single-Column mode, the dependency and configuration can be separated from the logic by the program.
Core: It mainly includes the basic core tool class of the spring framework, and the Core module is the basic core of other components.
Beans: the beans module is used by all applications. It contains all classes related to accessing the configuration file, creating and managing Beans, and performing IOC/DI operations.
Context: on the basis of core and bean, it provides a kind of interface similar to JNDI (Java Naming and Directory Interface, all references to resources outside the system, can be defined through the JNDI and reference https://www.cnblogs.com/shawnblogs/p/5279733.html), Context inherits the characteristics of Beans, spring core provides a lot of expansion, added the state, Time Propagation, resource loading, EJB, and JMX support. The ApplicationContext interface is the core of Context.
Expression Language: an extension of the unifed expression language defined in the jsp specification. It is used to query and operate objects at runtime. It supports setting/getting attribute values and attribute allocation, method call, access the array context and other operations.
2. Data Access/Integration
JDBC: provides a JDBC abstraction layer to eliminate lengthy JDBC coding and parse error codes unique to database vendors, including all classes that encapsulate jdbc database access.
ORM: Object-link ing APIs, such as JPA, JDO, Hibernate, and Mybatis, provide an interaction layer that is encapsulated Using ORM, you can use all the features provided by Spring to perform O/R ing.
JMS: mainly includes the characteristics of manufacturing and consumption information.
Transaction: the management of transactions. These transactions must implement specific interfaces and use them for all POJO.
3. Web module
The WEB module provides support for common frameworks such as Struts and JSF. Spring can manage these frameworks, inject Spring resources to the framework, and insert interceptors before and after these frameworks.
Web: provides basic web-oriented integration features, such as file upload. Use servlet listeners to initialize the IOC container and a web-oriented application context.
Web-servlet: includes Spring's model-view-controller (MVC) implementation. Spring's MVC framework clearly separates code within the model range from web forms, it is integrated with other features of the Spring framework.
Web-struts: provides support for struts. The class can be integrated with a typical struts web layer in Spring applications.
4. AOP
AOP (Aspect Oriented Programming) is a supplement and improvement of Object-Oriented Programming (OOP. OOP introduces concepts such as encapsulation, inheritance, and Polymorphism to establish an object hierarchy for simulating a set of public behaviors. However, OOP allows developers to define vertical relationships, but it is not suitable for defining horizontal relationships, such as the log function. Log Code is usually distributed horizontally across all object layers, and its core functions are irrelevant to other types of code, this is also true for security, exception handling, and transparent continuity. Unrelated code distributed everywhere is called cross-cutting. in OOP design, it leads to a lot of code duplication, and is not conducive to the reuse of each module.
The AOP technology is the opposite. It uses a technology called "cross-cutting" to segment the encapsulated object, encapsulate the public behaviors that affect multiple classes into a reusable module and name it "Aspect", that is, the Aspect. The so-called "aspect" is simply encapsulated by the logic or responsibilities that are not related to the business, but are called by the business module, so as to reduce the repeated code of the system and reduce the coupling between modules, it is also conducive to future operability and maintainability.
Using the "cross-cutting" technology, AOP divides the software system into two parts:Core concernsAndCross-concern. The main process of business processing is the core focus, and the part that has little to do with it is the cross-cutting focus. One feature of cross-cutting concerns is that they often occur in multiple aspects of the core concerns, and are similar everywhere, such as permission authentication, logs, and transactions. The function of AOP is to separate the various concerns in the system from the core concerns and the cross-cutting concerns.
Aspects: Provides integration support for AspectJ
Instrumentation: provides support for Class instrumentation and classloader implementation, so that it can be used on a specific application server.
Join point: in an application, it represents a point.
Pointcut: This is a group of one or more connection points, and the notification should be executed
Advice (notification): This method is executed before or after the actual action.
Introduction: reference allows you to add new methods or attributes to an existing class.
Target object: The object notified by one or more parties. This object is always a proxy object.
Weaving: Weaving connects the aspect to other application types or objects and creates a notification object, which can be completed at compilation, class loading, and runtime.
5. Test
The Test module supports testing Spring components using Junit and TestNGINX.