Spring Technology Insider: Overview of design concepts and overall architecture

Source: Internet
Author: User
Tags aop ldap apache mesos

Programmers adore the great God of technology, and a large part of it is because of their ability to find and solve problems, especially when there are urgent problems on the line, they are always able to locate and solve them quickly.

On the one hand, they have a deep technical basis, the application of technology know its why, on the other hand, in the process of mining the pit is constantly summed up, accumulated a lot of experience.

I believe everyone has used spring, and some people understand its core: IOC and AOP, but just understand their basic concepts, use reflection and dynamic proxies, learn more about how to manage objects, and how to implement specific implementations of proxies.

Some people use spring MVC, which uses spring to integrate databases, transactions, message queues to simplify operations, but also to understand the specific design ideas and implementations of integration.

I also this piece also compares the vegetable, therefore, after a period of time will comb and summarizes spring related technical principle, " Spring Technology Insider: In-depth analysis of the spring architecture and design principles of the book as the core, combined with their own experience and questions, as well as the network of Daniel's articles, to complement their shortcomings in this area.

The author of this book is Jivenko, based on spring source code, reveals the design idea and architecture idea of spring from the macroscopic, and analyzes the realization principle and operation mechanism of spring each function module from microcosmic. On the one hand, it is hoped that readers can better solve the various problems encountered in real development by understanding the underlying mechanism of spring, and hope that readers can absorb the excellent methods and ideas in spring design and implementation.

The whole book is divided into three parts, which describe the core, components and applications of spring respectively. The first part analyzes the IOC container and AOP implementation in detail, the second part describes the implementation of the Java EE component based on spring IOC container and AOP in spring, and the third part describes the implementation of some typical spring-based applications.

This article gives an overview of the design concept and the overall architecture, looking at the design goals and architecture of spring as a whole, and through this article, you will learn:

    • Spring's design goals
    • The overall architecture of spring
    • Introduction to the various sub-projects of spring
Design goals

In short, spring's design goal is to provide us with a one-stop lightweight application development platform that abstracts the common issues encountered in application development.

As a platform, it takes into account the use of enterprise application resources, such as data persistence, data integration, transaction processing, message middleware, distributed computing and other efficient and reliable processing of enterprise data methods of technical abstraction.

Lightweight is relative to the traditional Java EE, traditional Java EE development, need to rely on the Java EE specification implementation of the Java EE Application Server, design and implementation, the need to follow a series of interface standards, this development mode coupling high, so that the application in testability and deployment has an impact, The understanding and requirements for technology are relatively high.

With spring, developers are lightweight and can use Pojo and JavaBean development methods to enable application-oriented interface development and fully support object-oriented design methods. By reducing direct coupling through the IOC container, the functionality of the service is increased in both dynamic and non-intrusive ways through AOP, providing the basis for flexible selection of different service implementations, which is the core of spring.

The common problem with the development process is that spring encapsulates a variety of components, and spring, through the community, forms an open ecosystem, such as spring security, which comes from a community-contributed acegi.

Overall architecture

In general, Spring is divided into 3 layers, the bottom is the core layer, including the IOC, AOP and other core modules, the middle layer is packaged Java EE Services, as the intermediate driver components, the top is the application.

is an architectural diagram of the spring website, which describes the following components:

Core container

Consists of Spring-core, Spring-beans, Spring-context, Spring-context-support, and spring-expression modules:

Spring-core and Spring-beans provide a fundamental part of the framework, including IOC functionality, Beanfactory is a complex factory pattern implementation that decouples configuration and specific dependencies from the actual program logic.

The context module builds on the core and beans modules, adds support for internationalization, event broadcasts, resource loading and creation contexts, and ApplicationContext is the focus of the context module.

Spring-context-support provides support for a common third library, integrated into the spring context, such as cache (Ehcache,guava), communication (JavaMail), Dispatch (Commonj,quartz), template engine, and so on ( freemarker,velocity).

The Spring-expression module provides a powerful expression language for querying and manipulating object graphs at run time, which supports property values, attribute parameters, method invocations, array content storage, collections and indexes, logical and arithmetic operations, and named variables. And retrieve the object from the spring control reversal container by name.

AOP and Server Tools

The SPRING-AOP module provides an aspect-oriented programming implementation, and a separate spring-aspects module provides ASPECTJ integration and application.

Spring-instrument provides class-level tooling support and ClassLoader-level implementations for servers. Spring-instrument-tomcat is implemented for Tomcat instrument.

Message components

Spring Framework 4 contains the Spring-messaging module, abstracted from the spring integration project, such as Messge, Messagechannel, MessageHandler, and others to provide basic message-based services.

Data Access/Integration

The data access and integration layer consists of JDBC, ORM, OXM, JMS, and transaction modules.

The SPRING-JDBC module provides a JDBC abstraction that does not require writing lengthy JDBC code and parsing database vendor-specific error codes.

The SPRING-TX module provides programmable and declarative transaction management.

The Spring-orm module provides a leading API integration layer for Object relational mapping, such as JPA, Hibernate, and so on.

The SPRING-OXM module provides an abstraction layer to support Object/xml maping implementations such as JAXB, XStream, and so on.

The SPRING-JMS module includes the ability to produce and consume messages, providing an integrated spring-messaging module starting from Spring4.1.

Web

The Web layer consists of Spring-web, SPIRNG-WEBMVC, Spring-websocket, and Spring-webmvc-portlet modules.

The Spring-web module provides basic web development-oriented integration features such as multi-file uploads, the use of Servert listeners, and web development application contexts to initialize the IOC container. It also contains the supported web-related parts of the HTTP client and spring remote access.

SPRING-WEBMVC contains the Web applications implemented by spring's model-view-controller and rest Web services.

The Spring-webmvc-portlet module provides a portlet implementation of the MVC pattern, the biggest difference between the Protlet and the servlet is that the processing of the request is divided into the action and render phases, in which the action phase is executed only once, However, the render phase may be executed several times due to the user's browser operation.

Test

The Spring-test module supports unit testing and integration testing by combining JUnit or testng, providing continuous loading applicationcontext and caching these contexts.

Introduction to individual sub-projects

From configuration to security, from Web applications to big data-no matter what infrastructure your application needs, there is a spring project to help you build it, and spring is a modular design.

Spring Boot

Simplifying the initial setup and development of new spring applications and configuring them in a specific way eliminates the need for developers to define boilerplate configurations for rapid development.

Spring Cloud

Providing a toolset for distributed system development, based on spring Boot, provides a simple development method for configuration management, service discovery, circuit breaker, intelligent routing, Control Bus, global lock, decision-making campaign, distributed session, and cluster state management in JVM-based cloud application development, with many sub-projects under it.

    • Distributed/versioned configuration: Spring Cloud config
    • Service Registration and Discovery: Netflix Eureka or Spring Cloud Eureka (two packages for the former)
    • Routing: Spring Cloud Zuul, based on Netflix Zuul
    • Service-to-service Call: Spring Cloud feign
    • Load balancing: The Spring Cloud Ribbon is based on the Netflix ribbon implementation
    • Circuit breakers: Spring Cloud Hystrix
    • Distributed messaging: Spring Cloud Bus
Spring Cloud Data Flow

Data flow is a unified programming model and managed services for developing and executing large-scale data processing, batch operations, and continuous operations.

Spring Cloud Data Flow is a redesign of spring XD based on the native cloud, and the project goal is to streamline the development of big data applications. Spring XD's stream processing and batch module refactoring is based on the spring boot stream and Task/batch's microservices program respectively. Native support for these programs, such as Apache YARN, Apache Mesos, and Kubernetes, is a modern, automated deployment unit.

Spring Data

Data access module, which provides good support for JDBC and ORM, with the advent of NoSQL and Bigdata, more and more new technologies, such as non-relational databases, MapReduce frameworks, are being developed to make it easier for spring developers to use these new technologies. With spring data, developers can access data in different types of data stores in a relatively consistent way that spring provides.

Spring Integration

In the enterprise software development process, often encountered with external system integration, spring integration for the Spring programming model provides a support enterprise integration model extension, in the application provides a lightweight message mechanism, through the declaration of the adapter and external systems integration.

There are several basic concepts in Spring Integraton:

    • Message: Java object with meta data;
    • Channel: A pipeline that transmits messages;
    • Message Endpoint: The processing side of messages can be transformed, routed, filtered, split, aggregated, and so on at the processing end;

You can also use channel Adapter, which is where the application interacts with the outside world, where the input is inbound, the output is outbound, and there are many optional connection types, such as AMQP, JDBC, Web Services, FTP, JMS, XMPP, A variety of NoSQL databases and so on. All of these things can be concatenated together in a simple configuration file, enabling complex integration efforts.

Spring Batch

Simplify and optimize batch operations for large volumes of data, supporting transactional, concurrency, process, monitoring, vertical and horizontal scaling, providing unified interface management and task management.

For example, it provides many ways to read large files (such as a 1GB csv, XML file), load or update tens of thousands of or even hundreds of thousands of records in a database, and if you select all records directly to drag down the entire system, and use spring Batch, The framework helps him to page through a subset of records at a time, submitting them in batches during the update.

Spring Security

A spring certification and security tool. Its predecessor is ACEGI, which aims to provide a security service for spring applications, such as user authentication, authorization, and so on.

It uses the filter in the Servlet specification to secure Web requests and restrict URL-level access, and it can use Spring AOP protection method calls-with the help of object proxies and use notifications, to ensure that only users with appropriate permissions can access the security method.

It is flexible enough to authenticate users based on a variety of data stores. It includes a variety of common user storage scenarios, such as memory, relational databases, and LDAP, and can also be written and inserted into custom user storage implementations.

Spring HATEOAS

First to understand Hateoas: Everyone has heard of rest, it is positioned as a "distributed hypermedia Application" architecture style, the article mentions the Hateoas (hypermedia as the engine of the application state) concept, Hypermedia is the application state engine, which provides links to the returned results, and connects to other API methods so that users do not look up documents and know what to do next.

For example, to get an article, a non-Hateoas response example is:

GET /posts/1 HTTP/1.1Connection: keep-aliveHost: blog.example.com{    "id" : 1,    "body" : "My first blog post",    "postdate" : "2015-05-30T21:41:12.650Z"}

The Hateoas response example is:

{    "id" : 1,    "body" : "My first blog post",    "postdate" : "2015-05-30T21:41:12.650Z",    "links" : [        {            "rel" : "self",            "href" : http://blog.example.com/posts/1,            "method" : "GET"        }    ] }

To streamline operations such as checking in or getting hyperlinks, Spring Hateoas provides relevant support.

Spring Rest DOCS

You can generate a restful service document that is accurate and readable, and the spring official documentation is generated using spring REST docs.

Generating document fragments based on unit tests does not invade the source code, so it does not make the source become more and more bloated, support MarkDown, modify a line of configuration code to support the generation of MarkDown syntax of the document fragments.

By default, when you build, the unit tests are run first, the document fragments are generated, and then, when you package, the final document is generated by adding the Asciidoctor-maven-plugin plug-in, and the document is automatically updated with each release of the version as long as it is a canonical development process.

Spring Social

The biggest benefit of using Spring social is that it already provides support for mainstream social networking sites, with simple configuration, and the ability to find components from the community for less commonly used social networking sites.

Spring AMQP

The spring framework-based AMQP message solution, which provides a templated abstraction layer for sending and receiving messages, provides a message-driven pojo that makes it easier to use AMQP messaging servers in spring applications, SpringSource's rabbit MQ is an open source, AMQP-based messaging server.

Spring Web Flow

Spring Web Flow is an extension of spring MVC that supports the development of process-based applications. It separates the definition of the process from the classes and views that implement the process behavior, has simultaneous processing of multiple HTTP requests, manages session state, data transactions, supports Ajax to build a rich client experience, and provides support for JSF.

Spring LDAP

Spring LDAP is a Java framework for manipulating LDAP. It is a spring-based JdbcTemplate model that helps developers streamline operations.

Spring Session

The Spring session provides a set of scenarios for creating and managing servlet httpsession. The Spring session provides the cluster session function by default, using an external Redis to store session data to solve the session sharing problem.

Spring Shell

The spring shell provides an interactive shell that lets you develop commands using a simple spring-based programming model.

Spring Kafka

Spring for Kafka encapsulation and integration of native Kafka client consumer.

Spring StateMachine

Its main function is to help developers simplify the state machine development process, so that the state machine structure more hierarchical.

Spring IO Platform

Can be thought of as a dependency maintenance platform that brings dependencies together and provides a version number for each dependency.

Mainly to resolve the dependency version conflict, in the use of spring, often used to third-party libraries, General people are based on experience to pick a version number or pick the latest, the wind is large, very easy to conflict.

Spring IO Platform is a good solution to these problems, we do not need to write a version number when adding third-party dependencies, it can automatically help us pick an optimal version.

Welcome to scan the QR code below, follow my personal public number, see more articles ~

Spring Technology Insider: Overview of design concepts and overall architecture

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.