Architecture of the Java Framework Learning path--spring

Source: Internet
Author: User
Tags stomp


Classification:

Java Framework Learning

The architecture of Spring

Spring is an open-source lightweight framework

Spring Project development process:

Create a project--add the required class Library jar package--Create a source file programming call Library--Create a bean's profile--run debugging

Core Features:

1. AOP: Plane-oriented programming

2, IOC: control inversion, the creation of objects to spring management, Dependency injection Di, object generation is placed in the XML definition

3. Spanning Java EE three layers

Web tier: SPRINGMVC

Service layer: Spring IOC

DAO Layer: JdbcTemplate

For example, the Spring framework module is divided into core containers (cores Container), data access Integration (dataaccess/integration), Web (mvc/remoting), and other modules in four categories, a total of about 20 modules

Core container

The core container, the bottom four modules in the diagram, is the core, Bean, context, and expression language module, where

The core module provides a basic component of the framework, including IoC and dependency injection capabilities.

The Bean module provides beanfactory, which is a complex implementation of a factory pattern.

The context module is built on a solid foundation provided by the core and the Bean module, which is the medium for accessing any object defined and configured. The ApplicationContext interface is the focus of the context module.

The expression Language module provides a powerful expression language for querying and manipulating an object graph at run time.

Data Access/Integration

The data access/Integration layer includes the JDBC,ORM,OXM,JMS and transaction processing modules, where:

The JDBC module provides a JDBC abstraction layer that removes redundant JDBC-related encodings.

The ORM module provides an integration layer for the popular object relational mapping APIs, including Jpa,jdo,hibernate and IBatis.

The OXM module provides an abstraction layer that supports object/xml mapping implementations of JAXB,CASTOR,XMLBEANS,JIBX and XStream.

The Java Messaging Service JMS module contains the functionality of production and consumption information.

The transaction module supports both programmatic and declarative transaction management for classes that implement special interfaces and all POJO.

Web

The WEB layer consists of web,web-mvc,web-socket and Web-portlet, where:

The Web module provides basic web-oriented integration features, such as the ability to upload multiple files, and the use of servlet listeners and Web application-oriented contexts to initialize the IoC container.

The WEB-MVC module contains Spring's model-view-Controller (MVC), which implements the Web application.

The Web-socket module provides support for websocket-based and provides two ways to communicate between client and server side in a Web application.

The Web-portlet module provides the implementation of MVC in a Portlet environment and reflects the functionality of the Web-servlet module.

Other modules

There are other important modules, like Aop,aspects,instrumentation,web and test modules, where

The AOP module provides an aspect-oriented programming implementation that allows you to define method interceptors and pointcuts to cleanly decouple the code, which implements the functions that should be detached.

The aspects module provides integration with the AspectJ, a powerful and sophisticated aspect-oriented programming (AOP) framework.

The instrumentation module provides support for class instrumentation and implementation of Class loaders in a certain application server.

The Messaging module provides STOMP with support for the use of WebSocket sub-protocols in the application. It also supports an annotated programming model for Routing and processing of stomp information from WebSocket clients.

The test module supports testing of Spring components that have a JUnit or TestNG framework.

Spring IOC Container:

Divided into spring beanfactory containers and spring applicationcontext containers

The ApplicationContext container includes all the functions of the Beanfactory container, so it is generally recommended to exceed beanfactory. Beanfactory can still be used for lightweight applications, such as mobile devices or applet-based applications, where its data volume and speed are significant.

The spring IOC container is the core of the spring framework. Containers will create objects, connect them together, configure them, and manage their entire lifecycle from creation to destruction. The Spring container uses Dependency injection (DI) to manage the components that make up an application. These objects are called Spring Beans

The Bean container component, the entire IOC container core, the so-called Bean container, is where the bean object is loaded and the various data required. Where beanfactory is a pure bean container, used to store description beans, unrelated to other environments, and like ApplicationContext, is also a bean container, but it is closely related to the application environment, so called the application context (environment) more appropriate, ApplicationContext not only has eanfactory "descent", but also inherited Environmentcapable, Messagesource, Applicationeventpublisher, It expands many of its additional features, and its implementation classes are related to specific applications.

IOC container underlying principle:

(1), XML configuration file

(2), dom4j Resolve XML

(3), factory design mode

(4), Reflection

IOC Operation:

1. IOC configuration file Mode

2. The IOC annotation method

The entire work flow:

ApplicationContext context = new Classpathxmlapplicationcontext (path);

0. New ApplicationContext container object (not initialized);

1.ResourceLoader load and parse resource file ——— > Get resource object;

2.BeanDefinitionReader reads the resource object and encapsulates the bean element data it reads into

Beandefinition components;

3.BeanDefinitionRegister Register all beandefinition in Beanfactory

(Beandefinition is the basic data structure of the container's internal bean, Beanfactory maintains a

Beandefinition Map);

4. Container initialization starts, container initialization work is provided by Abstractapplicationcontext

Refresh () method completed

Context functions as a contextual function of the application environment, and the program can then pass through the Gebean of the context

The (String Beanname) method obtains the Bean object defined by the path file declaration


Architecture of the Java Framework Learning path--spring

Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.