Introduction to Spring (i)

Source: Internet
Author: User
Tags sql error

One, spring definition

Spring is an open source framework, and spring is a lightweight Java development framework that was created in 2003 by Rod Johnson.

In short, spring is a layered, Javase/javaee full-stack (All-stack) lightweight, open-source framework.

Spring Framework features (1) Light weight

Spring is lightweight both in terms of size and overhead. The full spring framework can be published in a jar file with a size of more than 1MB. and the processing overhead required by spring is negligible. In addition, spring is non-intrusive: Typically, objects in spring applications do not depend on a particular class of spring.

(2) Control reversal IOC

Spring facilitates low coupling through a technique called inversion of Control (IoC). When an IOC is applied, other objects that an object relies on are passed in passively, rather than the object itself creating or locating dependent objects. You can think of the IOC as opposed to Jndi--not the object looking for dependencies from the container, but the container actively passing the dependency to it when the object is initialized without waiting for the object to be requested.

(3) Facet-oriented AOP

Spring provides rich support for aspect-oriented programming, allowing for the development of cohesion through the separation of application business logic with system-level services such as auditing (auditing) and transaction (transaction) management. The Application object only implements what they should do-complete the business logic-that's all. They are not responsible (or even conscious) for other system-level concerns, such as log or transaction support.

(4) Container

Spring contains and manages the configuration and lifecycle of the Application object, in this sense it is a container where you can configure how each of your beans is created-based on a configurable prototype (prototype), Your bean can create a separate instance or generate a new instance each time it is needed-and how they relate to each other. However, spring should not be confused with traditional heavyweight ejb containers, which are often bulky and cumbersome and difficult to use.

(5) Frame

Spring can configure and combine simple components into complex applications. In spring, application objects are combined declaratively, typically in an XML file. Spring also provides a number of basic functions (transaction management, persistence framework integration, etc.), leaving the development of application logic to you.

(7) MVC

Spring's role is consolidation, but not just consolidation, the spring framework can be seen as an enterprise solution-level framework. The client sends the request, the server controller (implemented by Dispatcherservlet) completes the forwarding of the request, and the controller invokes a class handlermapping for the mapping, which is used to map the request to the corresponding processor to process the request. Handlermapping maps the request to the corresponding processor controller (equivalent to action) in spring if you write some processor components, generally implement the Controller interface, in the controller can call some service or DAO for data manipulation Modelandview is used to hold data taken from the DAO, and it can hold some data from the response view. If you want to return the processing results to the user, a view component, Viewresolver, is provided in the spring framework, which finds the corresponding view based on the indicator returned by the controller, and returns the response response to the user.

Iii. Composition of Spring

(1) Core kernel container This is the most basic part of the spring framework, which provides a dependency injection (dependencyinjection) feature to implement container-to-bean management. The most basic concept here is beanfactory, which is the core of any spring application. Beanfactory is an implementation of the factory pattern, which uses IOC to isolate application configuration and dependency descriptions from the actual application code. (2) Applying context the beanfactory of the core module makes spring a container, and the context module makes it a framework. This module extends the concept of beanfactory and adds support for internationalization (i18n) messaging, event propagation, and validation. In addition, this module provides many enterprise services, such as e-mail, jndi access, EJB integration, remote, and timing scheduling (scheduling) services. It also includes support for template frameworks such as velocity and freemarker integration. (3) AOP aspect-oriented programming spring provides rich support for slicing-oriented programming in its AOP modules. This module is the basis for implementing slice programming in spring applications. To ensure the interoperability of spring with other AOP frameworks, Spring's AOP supports APIs based on the AOP Alliance definition. An AOP consortium is an open source project whose goal is to promote the use of AOP and the interoperability of different AOP implementations by defining a common set of interfaces and components.  By visiting their site, you can find out more about the AOP Alliance. Spring's AOP module also introduces metadata programming to spring. With spring's metadata support, you can add comments to your source code, indicate where spring is and how to apply a tangent function. (4) DAO data Access objects using JDBC often result in a large amount of duplicate code, a connection is made, a statement is created, a result set is processed, and the connection is closed.  Spring's JDBC and DAO modules extract these duplicated code, so you can keep your database access code clean and concise, and prevent problems caused by the failure to shut down the database resources. This module also establishes a meaningful anomaly layer on top of the error messages given by several database servers.  So you no longer have to try to decipher the mysterious private SQL error message! In addition, the module uses spring's AOP module to provide transaction management services for objects in spring applications. (5) Orm Object/Relational mapping integration for those who prefer to use the object/relational mapping tool instead of using JDBC directly, Spring provides an ORM module. Instead of trying to implement its own ORM solution, Spring provides an integrated approach to several popular ORM frameworksscenarios, including Hibernate, JDO, and Ibatis SQL mappings. Spring's transaction management supports each of these ORM frameworks, including JDBC. (6) The Web Module Web context module is built on the application context module and provides a context appropriate for the Web application. In addition, this module provides some service-oriented support. For example: Multipart request for file upload, which also provides the integration of spring and other web frameworks, such as struts, webwork. (7) MVC Spring provides a full-featured MVC framework for building Web applications. Although spring can be easily integrated with other MVC frameworks, such as struts, the Spring MVC Framework uses IOC to provide a complete separation of control logic and business objects.

Introduction to Spring (i)

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.