ITWissen.info - Tech know how online

Spring, framework

Spring is a comprehensive framework for the development of applications based on the Javaprogramming language. Especially in connection with the J2EE platform, Spring is a standard framework that is available as open source for all possible forms of Java applications. The background of the development of Spring was to realize a lightweight framework as an alternative to the often complex J2EE architectures. For this purpose, Spring is based on a POJO-oriented programming model. More complex architectures are easier to test when using Spring, and the source code is easier to maintain, so that Spring has a lasting impact on the design of an application. Spring implements the concept of Dependency Injection (DI) at its core and continues to incorporate the mechanisms of aspect-oriented programming (AOP).

The structures of Spring provide for the integrative use of other frameworks and standards such as Enterprise JavaBeans (EJB) or Hibernate - Spring is a meta-framework and can be integrated into the most diverse architectures due to its independence from a specific platform. Thus, Spring is used in many application servers such as Tomcat, Jetty, JBoss, Glassfish, etc. or standalone in its own environment. For this purpose Spring also defines appropriate mechanisms for security. Distributed applications as well as distributed transactions are also possible because Spring guarantees high reliability and scalability. Under the links below you can download the Spring Framework as well as further information about Spring.

The history of Spring

A short history of Spring: It started with a framework called interface21, which was published by Rod Johnson in his book "Expert One-on-One J2EE Design and Development", and was intended to support his own applications. Due to the high response, the open source project Spring was created from this in February 2003. The project is hosted at Sourceforge and currently employs a number of developers to further develop and support Spring. The current version of the framework is available at the link below. There you can also find other projects that have been developed in the Spring environment. For example, a version ported to the .NET platform is also available. Here is a short overview of other projects:

  • Spring Webs Service for the realization of web services.
  • Spring Security for the realization of security aspects in Java and web applications.
  • Spring LDAP for the realization of access to LDAP systems.
  • Spring Rich Client for the realization of rich client applications based on Spring.
  • Spring Modules with a summary of tools and extensions for Spring.
Further projects are available via the links below.

The framework of Spring

Spring is typically described as a so-called lightweight framework for building Java applications. Beyond that, however, it must be added:

  • The Spring framework can be used for all kinds of conceivable Java applications.

    Architecture of a typical Spring-based web application

    Architecture of a typical Spring-based web application

    For example, it is not limited to web applications like Apache 's Struts framework. The figure shows an example of the architecture of a typical Spring-based web application.
  • Lightweight in this context means that you only have to make minimal changes to the existing source code in order to use Spring to your advantage.
At its core, Spring relies on technologies such as interfaces and dependency injection (DI), which complement each other. Based on interfaces, a mesh of a decoupled architecture of the application is created. If Dependency Injection is also used, the configuration of the dependencies takes place outside the code. Dependency Injection can then be used to greatly reduce the amount of code in an interface-based design, which consequently prevents tight coupling of system components. In the context of Dependency Injection, Spring acts as a container. This container provides fully configured instances of the classes of an application with all their dependencies.

Using the Spring framework can result in the following architectural advantages:

  • Applications can be subjected to unit tests without further effort.
  • Spring provides a consistent framework for accessing data. For this purpose, Java Database Connection (JDBC) or ORM products (Object-Relational Mapping) such as Hibernate, Toplink or Java Data Objects (JDO) can be used.
  • Spring is an alternative to Enterprise JavaBeans (EJB) and uses mechanisms of aspect-oriented programming and thus offers declarative transaction management without an EJB container.
  • Spring offers the developer a defined framework on all levels for his development.
  • Business interfaces can be implemented as simple Java classes, the Plain Old Java Objects (POJO).
The central point of Spring is to make J2EE development easier and to support good programming practices. This includes that Spring as a meta-framework supports the integration of other frameworks, for example for persistence. At the same time, Spring is portable beyond the boundaries of application servers. The background is that Spring consistently does without platform-specific and non-standard components.

Overview of Spring modules

Overview of Spring modules

The figure shows the arrangement and distribution of Spring's functionalities and features across seven different modules. Thus, all functions for the development of enterprise-wide applications are covered. However, an application does not have to be completely based on the Spring framework. The developer is free to choose the modules that are most useful in his specific environment. As shown in the figure, the central module is the Spring Core - this provides a container with the basic functions. Here, Spring is referred to as Beans, meaning all the resources managed by Spring. The central element of every Spring application is the BeanFactory - an implementation of the pattern factory. This uses the Inversion of Control (IoC) principle to separate the application configuration from the specification of code dependencies.

Spring Context Module Extends the concept of the BeanFactory with life-cycle events, validation, EJB integration, remoting and scheduling. The BeanFactory implements the container and the Context Module implements the framework-specific part.

Spring AOP Module Supports aspect-oriented programming (AOP) of custom aspects for Spring-based applications. It also enables metadata programming in Spring. To implement interoperability with other AOP frameworks, Spring AOP realization is largely based on the interface defined by the AOP Alliance.

Spring DAO Module The module abstracts the Java Database Connectivity (JDBC) interfaces so that the actual technical code to establish data connections, handle statements, results or errors, for example, is moved to the classes of the framework. This allows the application code to focus purely on the application. In order to provide transaction management services for the objects of a Spring application, the DAO module in turn uses the possibilities of the AOP module.

Spring ORM ModuleORM stands for object-relational mapping - this refers to the mapping of objects to relational databases. With this module, Spring integrates popular ORM frameworks such as Hibernate, TopLink, JDO and iBATISSQL Maps. However, transaction management services are also available in this module.

Spring Web Module Provides a context for the realization of web-based applications. Furthermore, this module integrates the Struts framework.

Spring Web MVC Module Contains a complete MVC framework for the realization of web applications and thus competes with other webapplication frameworks. However, the difference is that Spring with Model View Controller (MVC) while using Inversion of Control (IoC) has advantages in terms of flexibility and decoupling of components compared to other frameworks such as Struts.

In practice, the Spring framework is often part of the development of an application because it provides this large amount of functionality. Furthermore, the integration of persistence technologies and a declarative transaction management are supported, so that Spring is also used for database applications.

Informationen zum Artikel
Englisch: Spring, framework
Updated at: 01.04.2010
#Words: 1976
Links:
Translations: DE