Spring: Overview

First, understand the Spring development

  Spring is an open source framework Spring is a lightweight rise in 2003 Java development framework, part of the philosophy set forth by the Rod Johnson in his book Expert One-On-One J2EE Development and Design and prototypes derived. It is designed to address the complexity of enterprise application development created. One of the main advantages of the framework is its layered architecture, layered architecture allows the user to select which components to use, as well as J2EE application development provides an integrated framework. Spring uses basic JavaBean to do things previously only possible done by EJB. However, Spring's use is not limited to server-side development. Any Java application can benefit from the simplicity, testability and loose coupling from the perspective of Spring. The core is the Spring Inversion of Control (IoC) and the facing section (AOP). Briefly, Spring is a layered JavaSE / EEfull-stack (stop) lightweight open source framework.

Second, understand the architecture of Spring

  Spring Framework has been integrated in more than 20 modules, distributed in the following modules:

  • The core container (Core Container)
  • Data Access / Integration (Data Access / Integration) Layer
  • Web layer
  • AOP (Aspect Oriented Programming) module
  • Implant (the Instrumentation) module
  • Messaging (Messaging)
  • Test (Test) module

  Spring architecture as shown below:

  2.1, the core container 

Spring's core container is the basis for other modules built with Spring-core, Spring-beans, Spring-context, Spring-context-support and Spring-expression (String Expression Language) and other modules.

  • Spring-core module: provides a basic element of the framework, including inversion of control (Inversion of Control, IOC), and dependency injection (Dependency Injection, DI) function.
  • Spring-beans module: Provides BeanFactory, is a classic factory pattern implementation, Spring will manage objects called Bean.
  • Spring-context module: based on the Core and Beans module, a frame-object access mode, access to any object is defined medium and configurations. Context is the focus ApplicationContext interface module.
  • Spring-context-support module: support for the integration of third-party libraries into a Spring application context, in particular support for caching (EhCache, JCache) and task scheduling (CommonJ, Quartz) of.
  • Spring-expression Module: provides a powerful expression language to support querying and manipulating an object graph at runtime. This is an extension of the provisions of JSP2.1 specification unified expression language (Unified EL) is. The language supports to set and get property values, property distribution, method call, the accessing the array, collections and indexers, logical and arithmetic operations, and a variable name from the IOC Spring vessel to retrieve the name of the object. It also supports list projection, selection, and a list of commonly used polymerization.

  2.2、AOP和Instrumentation 

  • Spring-aop module: provides one AOP requirements aspect-oriented programming, the method allows the definition and entry points interceptors, separated by function code to cleanly decoupled.
  • Spring-aspects Module: provides integration with the AspectJ, AspectJ is a powerful and mature AOP framework.
  • Spring-instrument module: provides a class implant (the Instrumentation) to support and implement a class loader can be used in a specific application server.

2.3, message

  After the new message Spring4.0 (Spring-messaging) module, which provides support for the architecture and messaging protocol.

2.4, data access / Integration

  Data Access / Integration layer of JDBC, ORM, OXM, JMS, and transaction modules.

  • Spring-jdbc module: it provides a JDBC abstraction layer, eliminating cumbersome JDBC coding error code and parsing the database vendor specific.
  • Spring-orm module: integration layer provides for the popular object-relational mapping (Object-Relational Mapping) API, and comprising JPA Hibernate. All other features Spring-orm use these modules may be O / R mapping is provided in connection with the Spring framework, for example declarative transaction management functions.
  • Spring-oxm Module: provides an abstraction layer that supports Object / XML mapping implemented, e.g. JAXB, Castor, JiBX and XStream.
  • Spring-jms module (Java Messaging Service): refers to the Java Messaging Service, comprising functions for production and use of message. Since Spring4.1, it provides integration with Spring-messaging module.
  • Spring-tx module (transaction module): Support for implementing programmatic and declarative transaction management and a special interface for all POJO (Plain Old Java Object) class.

2.5、Web

Web layer made Spring-web, Spring-webmvc, Spring-websocket and Portlet module.

  • Spring-web module: Provides basic Web development of integrated features, such as multi-file upload function, the use of Servlet listener to initialize an IOC container and Web application context.
  • Spring-webmvc modules: also known as Web-Servlet module comprising Spring MVC and REST Web Services for web applications implementation. Spring MVC framework provides a clear separation between domain model code and Web forms, and integration with all the other features of the Spring Framework.
  • Spring-websocket module: Spring4.0 after the new module, which provides WebSocket and implementation of SocketJS.
  • Portlet module: similar to the Servlet module provides the MVC in Portlet environment to achieve.

2.6 Test

Spring-test module supports JUnit or TestNG Spring components of unit and integration test.

Third, understand the advantages and new features Spring

  3.1, Spring features

(. 1) the IOC (inversion control) or DI (dependency injection) : a well-defined component interfaces, independent development of the individual components, and then assembling the components of Run dependencies; claimed will be created and managed objects to Spring container. Spring is a lightweight containers (light-weight Container), the core is Bean plants (Bean Factory), configured to M we need (Model). It enables software components that work together to maintain loose coupling. Reducing the complexity of business objects Alternatively, to improve decoupling between the components.

(2) the AOP (Aspect Oriented Programming) : by pre-compiled methods and dynamic agent operating program to implement a technique for dynamically add unified function without modifying the source code. That system-level services decoupled from the code. For example: the logging, performance statistics, security control, transaction processing, exception handling code is divided from the business logic code. It allows you to separate out reusable component form throughout the entire application functionality.

  3.2 The benefits of using the Spring Framework

(1) Inversion of Control: Spring Inversion of Control achieved by loosely coupled, objects are given their dependencies instead of creating them or find dependent objects.
(2) cut-Oriented Programming (AOP): Spring support aspect-oriented programming, and to separate the application business logic and system services.
(3) MVC framework: Spring WEB framework of a well-designed framework, is a good alternative to Web framework.
(4) Low-intrusive design, code, pollution is very low, independent of the various application servers, applications based on the Spring framework that can really achieve Write Once, Run Anywhere's commitment.
(5) strong integration capabilities: integration of a variety of excellent open source framework. (Hibernate, Struts, Hessian, etc.).
(6) Exception Handling: Spring API provides a convenient technique related to specific abnormalities (such as a JDBC, Hibernate or JDO thrown) into uniform unchecked exceptions.
(7) containers: Spring contain and manage the life cycle of the application and arrangement of objects.
(8) Lightweight: Spring is lightweight, basic version is about 2MB.

  3.3 Why use Spring?

  • Convenient decoupling, simplify development.

Spring is a large factory, all objects can be created and maintained relationships of dependence, to the Spring management.

  • AOP programming support

Spring provides aspect-oriented programming, you can easily implement a program permission to intercept, operation monitoring and other functions.

  • Support for declarative transactions

Only you need to complete the configuration management of affairs without manual programming.

  • To facilitate the testing program

Spring for Junit4 support, you can easily comment Spring test program.

  • Easy integration of a variety of excellent framework

Spring does not exclude a variety of excellent open source framework, which provides a variety of excellent internal framework: direct support (such as Struts2, Hibernate, MyBatis, Quartz, etc.).

  • The difficulty of reducing the use of JavaEE API

Spring for some API JavaEE development is very difficult to use (JDBC, JavaMail, remote calls, etc.), provides packaging so that these API application difficulty greatly reduced.

Guess you like

Origin www.cnblogs.com/BalmyLee/p/10936500.html