Recently in preparation for a job, the most commonly used things, but also to take out to turn over. Let's take a look at spring today.
Java development in the domestic friends, spring must not be unfamiliar.
The history of spring?
When we talk about spring, I think of Ejb2.0. Despite the fact that there are many successful systems based on Ejb2.0, Ejb2.0 did not implement its original vision: simplifying enterprise-level application development. The declarative programming pattern of EJBS does simplify many infrastructure-level developments, such as transactions, security, and so on, but Ejb2.0 's template-based coding makes people feel complicated.
In order to simplify the ejb,spring was born. Spring, with its core of AOP and IOC, provides JavaBean as powerful as EJB, which provides Pojo with a declarative, EJB-like programming model without introducing any EJB complexity.
After that, spring and EJB learn from each other, and in Ejb3.0, they draw on the light of spring, and spring draws on the EJB's distribution. Whether spring and EJB are competing or cooperating, they are simplifying our development anyway.
What is Spring?
Spring is a lightweight open-source framework in Java EE development, with the IOC (inverse of control: inversion control) and AOP (Aspect oriented programming: plane-oriented programming) as the core, providing the presentation layer Spring Many enterprise-class applications such as MVC and persistent layer spring JDBC and business-level transaction management. In addition, Spring is a big feature, it does not have to be the same as EJB, Spring integrates a large number of third-party class libraries, for integration with other frameworks. Really implement interface-oriented programming.
Why use Spring?
Spring is an open source project, a middleware and a framework. So why do we use spring? Some people say: the framework of this kind of thing, when the first contact with Java, do not use. Or learn something from the basics of Java, some say: Spring is a great framework. Its IOC can write more interface-oriented programs, and its AOP is a better complement to OOP.
Yes, I agree with both of these statements. To better understand spring, we have to master the fundamentals of Java, and spring is really a great tool for working with coding. So, different stages, different treats.
The advantages of spring?
Lightweight--spring are non-intrusive, meaning that objects in spring applications do not rely on spring interfaces or abstract classes.
ioc--the IOC, I'll think of it. Jndi,jndi is an object that is actively looking for dependencies from a container, whereas an IOC is a container that proactively passes dependencies to an object when it is initialized. Spring uses the application context (ApplicationContext) to load the bean definitions and assemble them. ApplicationContext is responsible for creating and assembling objects, and then actively injecting them into the object's use.
Aop--spring provides support for aspect-oriented programming, allowing for the development of cohesive lines by separating the business logic of the application from the cut-in services such as transaction management, logging, and permissions.
The container--spring contains and manages the configuration and life cycle of the Application object, in this sense it is a container.
Framework--spring can be a simple component configuration, combined into a complex application. In spring, the Application object is a combination of declarative expressions, typically in an XML.
springmvc--is a web framework similar to STRUTS2.
Spring Overview
IOC
The spring core module implements the functions of IOC, describes the dependencies between classes in the form of configuration files or annotations, and the IOC container is responsible for the creation, splicing, management, and acquisition of the classes, and the Beanfactory interface is the core interface of the spring framework. It implements many of the core functions of the container.
With spring, the most important feature we use, and spring's other features, are mostly IOC-based extensions.
The Context module , built on the core module, extends the functionality of Beanfactory, adding UI support, Bean Lifecycle control, framework event architecture, resource loading transparency, and more. In addition, the module provides support for many enterprise-class services such as mail services, task scheduling, JNDI positioning, EJB integration, remote access, and more.
ApplicationContext is the core interface of the Context module.
The context is a spring-ready extension that enhances the functionality of spring.
Data Access/Integration
The data access/integration layer includes JDBC,ORM,OXM,JMS and transaction processing modules, each of which functions as follows
The JDBC module provides an abstraction layer that does not require lengthy JDBC coding related to JDBC.
An ORM module provides an integration layer. Popular object-relational mapping APIs, including Jpa,jdo,hibernate and Ibatis.
The OXM module provides an abstraction layer that supports object/XML mapping implementation to Jaxb,castor, using XMLBEANS,JIBX and XStream.
Spring can not be integrated with Hibernate or Ibatis, MyBatis, spring internal integration of the SPRINGJDBC template, Springjdbc is a very useful ORM sub-framework of spring;
In addition, spring is often integrated with Hibernate, IBatis, and MyBatis.
The Java Messaging Service JMS module contains information about the functionality for production and consumption.
This is the spring extension's support for JMS.
The transaction module supports programmatic and declarative transaction management to implement special interface classes.
The problem with any application, its core, is access to and manipulation of data. Data has many manifestations, such as data tables, XML, messages, etc., and each data form has different data access techniques (such as data table access can be either directly through JDBC or through hirnate or ibatis).
Spring stands at the abstract level of DAO, and establishes a set of anomaly systems for DAO-layer unification, and simultaneously transforms the check-type anomaly of various access data into non-inspection anomaly, which provides the foundation for consolidating various persistent layer frameworks. Second, Spnng has a thin-layer encapsulation of various data access technologies through templating techniques, hiding the modeled code and making the program of data access much easier. So spring has built a unified DAO layer that is independent of data form and access technology, and with AOP technology, Spring provides the functionality of declarative transactions.
Springmvc
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 and the 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, you can invoke some service for data manipulation, Modelandview is used to hold the data in the DAO, and it can hold the data of the corresponding 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 and returns the corresponding response to the user, based on the indicator returned by the controller.
SPRINGMVC is a sub-project of spring, similar to the STRUTS2 function, but the internal implementation is very different. In terms of integration with spring, SPRINGMVC has a congenital advantage, and there is no security vulnerability like STRUTS2. Now more and more people are favored.
The above content, more for reference network resources: including Baidu Encyclopedia, Open source China, netizens blog and "Spring Combat" and other information. Before planning to sneak lazy don't write summary, read the book, look at the information on the past. However, do not take the good and the small and not do it for the small and evil. So, it is decided to make a summary of this knowledge.
Spring's talk