Technology: Spring Framework

Overview

The Springframework is a modular framework that offers a large set of "tools" to support the developer in writing modern component-based applications. Spring is an open source project and was motivated by the quite complex concept of Enterprise Java Beans. Spring is a lightweight and modular component "glue", this means:

  • Spring is not invasive. For most scenarios classes that are developed for usage within a Spring context do not have to be aware of Spring at all, i.e., there are no interfaces to be implemented or classes to be extended
  • Using Spring does not mean, that each component of Spring has to be used, i.e., one can easily pick only the component/dependency injection part and not use any of the persistence or web-modules at all
  • Spring helps to integrate a great variety of typical components that are needed in many applications without replicating functionality, e.g., Spring supports the integration of O/R mapping tools, but does not provide or abstract any O/R functionality
  • The consequence of the last point is: there is always the full functionality of all integrated components available, but they are typicall better integrated using the Springframework
  • Using Spring-Containers with dependency injection also supports test-driven development as components can be easily exchanged and mocked when needed.

In this documentation a brief overview on Spring in general is given here, some more details on Spring JDBC, Spring ORM and Spring Remote is provided in the sub-pages.

Modules

The Spring documentation gives a good Overview on the modules Spring provides. Essentially these are:

  • Core: This is the dependency injection/inversion of control container
  • AOP Support for aspect oriented development
  • DAO Support for data access objects including Spring JDBC and transaction management
  • ORM Object relational mapping support (e.g., for Hibernate)
  • JEE Support for various "enterprise" technologies, mostly messaging and remoting, but also emailing
  • Web Web-Framework

The core module is used in every Spring project and also in all examples provided here. This module is easy to understand and is an implementation of the Dependency Injection pattern.

The DAO and ORM modules support the application developer in implementing persistence components. In the basic example the JDBC templates are used, in the medium und advanced example, the ORM module (for Hibernate) is applied.

The JEE module is only used in the advanced example for remoting.

The implementation to provide aspect oriented development (AOP) is very useful in a broad range of applications. In the examples it is used starting with the medium example to provide declaration-based database transactions and access control to objects/components.

The Spring Web framework is probably the part of the Spring project that is used by the least number of projects; in our set of examples we do not use this module. However, this shows again, that Spring perfectly allows to select the parts that are useful for a concrete implementation problem and leave the other out, that would make the application unnecessarily complex.