"60" Spring Summary infrastructure (1)

Source: Internet
Author: User
Tags to domain

Why use Spring?

Spring has been implementing and adhering to the concept that "good design is better than concrete implementation, code should be easy to test", and ultimately brings us a development framework that is easy to develop, easy to test, and fully functional. To sum up Spring brings us the following benefits:

1, easy to decouple, simplify the development

With spring's IOC container, we can control the dependencies between objects by spring, avoiding the over-program coupling of hard-coded illumination. With spring, users no longer have to write code for these very low-level requirements such as singleton schema classes, attribute file parsing, and more focus on upper-layer applications.

2, AOP programming support

The AOP functionality provided by spring facilitates aspect-oriented programming, and many features that are not easily implemented with traditional OOP can be easily coped with by AOP.

3. Declarative transaction support

In spring, we can free ourselves from the tedious management code of Things, and use declarative way to manage things flexibly and improve the efficiency and quality of development.

4. Convenient program Testing

Almost all of the testing work can be done in a non-container-dependent way, and testing in spring is no longer an expensive operation, but something that can be done at your fingertips.

5, convenient integration of a variety of excellent framework

Spring does not exclude a variety of excellent frameworks, instead, spring reduces the difficulty of using various frameworks, and spring provides direct support for a variety of excellent frameworks such as struts, Hibernate, Mybatis, Hessian, quartz, and so on.

6. Reduce the difficulty of using Java EE API

Spring provides a thin layer of packaging for many of the hard-to-use Java EE APIs, such as JDBC, JavaMail, remote invocation, and so on, which are significantly less difficult to use with spring's simple encapsulation.

7, Spring source code is a classic learning paradigm

Spring's source code design is exquisite, the structure is clear, the ingenuity uses, everywhere manifests the master to the Java design pattern flexible use as well as to the Java Technology Advanced attainments. The spring framework source code is undoubtedly a best practice example of Java technology. If you want to quickly improve your Java level and application development level in a short time, learning and studying spring source code will give you unexpected results.

Diagram of Spring structure:

Description of the structure: the spring framework is divided into 7 modules, each module (or component) that makes up the spring framework can exist separately or be implemented in conjunction with one or more modules. The functions of each module are as follows: 1. Core container

: The core container provides the basic functionality of the Spring framework. The main component of the core container is Beanfactory, which is the implementation of the factory pattern. The beanfactory uses the inversion of control (IOC) pattern to separate the application's configuration and dependency specifications from the actual application code.
  

2.Spring context

: The spring context is a configuration file that references the following information to the spring framework. The Spring context includes enterprise services such as JNDI, EJB, e-mail, internationalization, checksum scheduling.
  

3.Spring AOP

: With the configuration management feature, the Spring AOP module directly integrates aspect-oriented programming capabilities into the spring framework. Therefore, it is easy to enable any object managed by the Spring framework to support AOP. The spring AOP module provides transaction management services for objects in spring-based applications. By using Spring AOP, you can integrate declarative transaction management into your application without relying on EJB components.

4. Spring DAO

: The JDBC DAO Abstraction layer provides a meaningful exception hierarchy that can be used to manage exception handling and error messages thrown by different database vendors. The exception hierarchy simplifies error handling and greatly reduces the number of exception codes that need to be written (such as opening and closing connections). Spring DAO's JDBC-oriented exception conforms to the common DAO exception hierarchy.

5.Spring ORM

: The Spring framework inserts several ORM frameworks, providing ORM object-relational tools, including JDO, Hibernate, and IBatis SQL Map. All of these conform to Spring's common transaction and DAO exception hierarchies.
  

6. Spring Web Module

: The Web context module is built on top of the application context module and provides the context for Web-based applications. Therefore, the Spring framework supports integration with Jakarta Struts. The Web module also simplifies the process of working with multipart requests and binding request parameters to domain objects.
 

7. Spring MVC Framework

: The MVC framework is a full-featured MVC implementation of building WEB applications. With the policy interface, the MVC framework becomes highly configurable, and MVC accommodates a large number of view technologies, including JSP, Velocity, Tiles, IText, and POI.

Spring has the following advantages:

1. Low-intrusive design with very low code contamination
2. Independent of various application servers, can truly realize the promise of write Once,run anywhere
The 3.Spring di mechanism reduces the complexity of business object substitution
4.Spring is not entirely dependent on spring, and developers are free to select part or all of the spring framework

Basic concepts of IOC and AOP control reversal patterns (also known as dependency intervention)

In the traditional Java development paradigm, when an object is needed, we create an object ourselves using either a new or getinstance method, such as a direct or indirect constructor, and in spring development mode, the spring container uses the factory pattern to create the desired object for us. , we don't need to create it ourselves and call the object that spring provides for us, which is the idea of control inversion. There are three ways to instantiate a Java object: Using the class constructor, using the static factory method, using the instance factory method, we don't need to care about how to instantiate an object when using spring, and spring automatically instantiates an object for us through the control reversal mechanism.

Dependency Injection (DI):

The process of spring using the set method of the Java Bean object, or the constructor with parameters, is the basic idea of dependency injection for the value we need to set its properties automatically when we create the desired object.

Facet-oriented Programming (AOP):

In object-oriented programming (OOP), we abstract things vertically into objects. In the aspect-oriented programming, we will abstract some similar aspects of objects into a tangent plane, and the process of this aspect, such as permission verification, object management, logging and other common operations processing is the idea of face-cutting programming.

My QR code is as follows, welcome to exchange discussion

You are welcome to pay attention to the "It question summary" subscription number. Every day to push the classic face test and interview tips, are dry! The QR code of the subscription number is as follows:

Reference:
http://my.oschina.net/u/1476426/blog/598554
http://blog.csdn.net/zhixiang2010/article/details/18404567
http://codepub.cn/2015/06/21/Basic-knowledge-summary-of-Spring/

"60" Spring Summary infrastructure (1)

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.