Overview of Spring Framework


Spring is an open source framework, originally created by Rod Johnson and described in his book Expert One-on-One: J2EE Design and Development. Spring was created to address the complexity of enterprise application development, and makes it possible to use plain-vanilla JavaBeans to achieve things that were previously only possible with EJBs. But Spring’s usefulness isn’t limited to server-side development. Any Java application can benefit from Spring in terms of simplicity, testability, and loose coupling.

A 'plain-vanilla' bean/class means a very basic class usually with the following properties:
- Doesn't extend or implement anything
- Has private class variables
- Has an empty constructor
- Has standard getter/setter methods

How does Spring simplify Java development?
Spring employs four key strategies:
- Lightweight and minimally invasive development with plain old Java objects (POJOs)
- Loose coupling through dependency injection and interface orientation
- Declarative programming through aspects and common conventions
- Boilerplate reduction through aspects and templates

Modules
The Spring Framework consists of features organized into modules. These modules are grouped into Core Container, Data Access/Integration, Web, AOP (Aspect Oriented Programming), Instrumentation, and Test, as shown in the following diagram.


CORE SPRING CONTAINER
The centerpiece of the Spring Framework is a container that manages how the beans in a Spring-enabled application are created, configured, and managed.
Within this module you’ll find the Spring bean factory, which is the portion of Spring that provides dependency injection.
Building upon the bean factory, you’ll find several implementations of Spring’s application context, each of which provides a different way to configure Spring.
In addition to the bean factory and application context, this module also supplies many enterprise services such as email, JNDI access, EJB integration, and scheduling.

SPRING’S AOP MODULE
AOP is used in Spring:
- To provide declarative enterprise services, especially as a replacement for EJB declarative services. The most important such service is declarative transaction management, which is build on Spring’s transaction abstraction layer.
- To allow users to implement custom aspects, complementing their use of OOP with AOP. The Spring AOP module also introduces metadata programming to Spring. This is used to add annotation to the source code that instructs Spring on where  and how to apply aspects.

DATA ACCESS AND INTEGRATION
Working with JDBC often results in a lot of boilerplate code that gets a connection, creates a statement, processes a result set, and then closes the connection. Spring’s JDBC and data access objects (DAO) module abstracts away the boilerplate code so that you can keep your database code clean and simple, and prevents problems that result from a failure to close database resources. This module also builds a layer of meaning-ful exceptions on top of the error messages given by several database servers. No more trying to decipher cryptic and proprietary SQL error messages!
For those who prefer using an object-relational mapping (ORM) tool over straight JDBC, Spring provides the ORM module.
Spring’s ORM support builds on the DAO support, providing a convenient way to build DAOs for several ORM solutions. Spring doesn’t attempt to implement its own ORM solution, but does provide hooks into several popular ORM frameworks, including Hibernate, Java Persistence API, Java Data Objects, and iBATIS SQL Maps.
Spring’s transaction management supports each of these ORM frameworks as well as JDBC.
This module also includes a Spring abstraction over the Java Message Service (JMS) for asynchronous integration with other applications through messaging. And, as of Spring 3.0, this module includes the object-to-XML mapping features that were originally part of the Spring Web Services project.
In addition, this module uses Spring’s AOP module to provide transaction management services for objects in a Spring application.

WEB AND REMOTING
The Model-View-Controller (MVC) paradigm is a commonly accepted approach to building web applications such that the user interface is separate from the application logic. Java has no shortage of MVC frameworks, with Apache Struts, JSF, WebWork, and Tapestry among the most popular MVC choices.
Even though Spring integrates with several popular MVC frameworks, its web and remoting module comes with a capable MVC framework that promotes Spring’s loosely coupled techniques in the web layer of an application. This framework comes in two forms: a servlet-based framework for conventional web applications and a portlet-based application for developing against the Java portlet API.
In addition to user-facing web applications, this module also provides several remoting options for building applications that interact with other applications.
Spring’s remoting capabilities include Remote Method Invocation (RMI), Hessian, Burlap,JAX-WS, and Spring’s own HTTP invoker.

TESTING
Recognizing the importance of developer-written tests, Spring provides a module dedicated to testing Spring applications.
Within this module you’ll find a collection of mock object implementations for writing unit tests against code that works with JNDI, servlets, and portlets. For integration-level testing, this module provides support for loading a collection of  beans in a Spring application context and working with the beans in that context.