Spring's seven core modules are for your reference. The specific content is as follows
1. Spring core: core container
The core container provides the basic functions of the spring framework. Spring organizes and manages various components and their relationships in Java applications in a bean manner. Spring uses BeanFactory to generate and manage beans, which is an implementation of the factory pattern. BeanFactory uses the Inversion of Control (IoC) mode to separate the application's configuration and dependency specification from the actual application code. BeanFactory uses dependency injection to provide component dependencies. Mainly implements control inversion IoC and dependency injection DI, Bean configuration and loading.
2. Spring AOP: Spring Oriented Programming
Through the configuration management feature, the Spring AOP module directly integrates aspect-oriented programming functions into the Spring framework. Therefore, it is easy to make any object managed by the Spring framework support AOP. The Spring AOP module provides transaction management services for objects in Spring-based applications. By using Spring AOP, declarative transaction management can be integrated into the application without relying on EJB components. AOP divides a business process into several parts, such as permission checking, business processing, logging, each part is processed separately, and then assembles them into a complete business process. Each part is called a section or a focus.
The implementation principle of AOP is dynamic proxy technology, and there are two proxy modes:
(1) ProxyFactoryBean Agent Factory Object
Spring has built-in proxy classes, which introduces an intermediate layer, which can create different types of objects, and can implement any form of AOP.
(2) TransactionProxyFactoryBean transaction agent factory object
Commonly used in database programming, Spring uses TransactionProxyFactoryBean to manage transactions. Before specifying methods, use AOP to connect to the database and start the transaction. Then, after the specified method returns, use AOP to submit the transaction and disconnect the database.
3. Spring context: Spring context
Spring context is a configuration file that provides context information to the Spring framework. Spring context includes enterprise services such as JNDI, EJB, Email, Internationalization, Checksum Scheduling capabilities. Provides framework-based bean access, and other programs can access Spring's bean resources through Context.
4. Spring DAO
The main purpose of the DAO module is to isolate persistence layer-related issues from general business rules and workflows. DAO in Spring provides a consistent way to access databases, and no matter what persistence technology is used, Spring provides a consistent programming model. Spring also provides a consistent DAO approach to exception hierarchy for different persistence layer technologies. Spring's DAO module reencapsulates JDBC, hiding JDBC APIs such as Connection, Statement, and ResultSet, so that the DAO module directly inherits the JdbcDaoSupport class.
5. Spring ORM (Object Relation Mapper) object relationship mapping module
Spring is well integrated with all major ORM frameworks, including hibernate, JDO implementation, TopLink, and IBatis SQL Map. Spring provides auxiliary classes such as templates for all these frameworks, reaching a consistent programming style.
Spring's ORM module encapsulates ORM frameworks such as Hibernate. Spring can manage and maintain Hibernate. When using it, it can directly inherit the HibernateDaoSupport class. This class has a HibernateTemplate built-in. Hibernate's configuration is also transferred to Spring configuration files.
(Note: ORM uses metadata that describes the mapping between the object and the database. The ORM framework uses metadata to describe the object-relational mapping details. The metadata is generally in the xml format and is stored in a special object-mapping file)
6. Spring Web Module
The web module is built on top of the application context module and provides context for web-based applications. The web layer uses a web layer framework. Optionally, it can be Spring's own MVC framework, or provided Web frameworks such as Struts, Webwork, tapestry and jsf.
The web module is used to integrate the web framework and incorporate the web framework into Spring's management. If Spring provides inheritance method and proxy method to integrate Struts, the inheritance method does not require any configuration file to be changed. It only inherits Action from ActionSupport, but it will depend on Spring. The proxy method requires the <controller> to be configured in struts-config.xml, and is proxied by Spring's full disk, so various resources, interceptors, etc. of Spring can be used.
7. Spring MVC
The MVC framework is a fully functional MVC implementation for building web applications. Through the policy interface, the MVC framework becomes highly configurable. Spring's MVC framework provides clear role division: controller, validator, command object, form object and model object, distributor, processor map, and view resolver. Spring supports multiple viewing technologies.
Spring MVC workflow:
(1) The client sends a request, and the request reaches the DispatcherServlet main controller.
(2) The DispatcherServlet controller calls HandlerMapping for processing.
(3) HandlerMapping is responsible for maintaining the corresponding relationship between requests and Controller components. HandlerMapping calls the corresponding Controller component according to the request.
(4) To execute business processing of the Controller component, you need to access the database and you can call DAO and other components.
(5) After the Controller business method is processed, a ModelAndView object will be returned. This component encapsulates model data and view identifiers.
(6) The Servlet main controller calls the ViewResolver component and processes it according to ModelAndView information. Position view resources and generate view response information.
(7) The controller outputs the response information to the user.
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.