Spring Framework is one of the most popular Java EE framework. This article is designed for java developers who want to learn Spring framework architecture, it’s core components and various projects that comes under spring framework umbrella.
Table of Contents
Spring is one of the most popular frameworks for Java enterprise edition. Developers all over the world use Spring for developing reliable and high-quality applications. Spring framework was designed by Rod Johnson. Since then Spring has became alternative technology in java world for EJB model. You can create any application by using spring framework.
Spring Framework – DI, IoC, AOP
- It is impossible to understand what is Spring Framework without understanding what is Dependency Injection and Inversion of Control. Dependency Injection, also called as DI, is one of the types of Inversion of Control (IoC).
- Inversion of Control – this is the principle of object-oriented programming, in which objects of the program do not depend on concrete implementations of other objects, but may have knowledge about their abstractions (interfaces) for later interaction.
- Dependency Injection – is a composition of structural design patterns, in which for each function of the application there is one, a conditionally independent object (service) that can have the need to use other objects (dependencies) known to it by interfaces. Dependencies are transferred (implemented) to the service at the time of its creation. This is a situation where we introduce an element of one class into another. In practice, DI is implemented by passing parameters to the constructor or using setters. Libraries that implement this approach are also called IoC containers.
- Aspect oriented programming – a programming paradigm that allows you to distinguish cross-through (functional) functionality in application. These functions, which span multiple application nodes, are called cross-cutting concerns and these cross-cutting notes are separated from the immediate business logic of the application.
In OOP, the key unit is the class, while in AOP, the key element is the aspect. DI helps to separate application classes into separate modules, and AOP helps to separate cross-cutting concerns from the objects they affect.
Spring Framework Architecture
Spring Framework is divided into a number of separate modules, which allows you to decide which ones to use in your application. Below image illustrates the most important modules of Spring Framework architecture.
Let’s look into spring ecosystem modules one by one.
Spring Framework Core Components
The Core container from Spring consists of four modules: SpEL , Context, Core, Beans. Description for these elements are as follows:
- The SpEL module provides a powerful expression language for manipulating objects during execution.
- Context is built on the basis of Beans and Core and allows you to access any object that is defined in the settings. The key element of the Context module is the ApplicationContext interface.
- The Core module provides key parts of the framework including IoC and DI properties.
- The Bean module is responsible for creating and managing Spring Beans – is application context structure unit.
Spring Framework Web
Spring framework Web layer consists of Web, Web-MVC, Web-Socket, Web-Portlet etc.
- The Web module provides functions such as downloading files, creating web application, rest web service etc.
- Web-MVC contains a Spring MVC implementation for web applications.
- Web-Socket provides support for communication between the client and the server, using Web-Sockets in web applications.
- Web-Portlet provides MVC implementation with portlet environment
Spring Framework Data Access
The Data Access/Integration container consists of JDBC, ORM, OXM, JMS and the Transactions module.
- JDBC provides an abstract layer of JDBC and eliminates the need for the developer to manually register the monotonous code associated with connecting to the database.
- Spring ORM provides integration with such popular ORMs as Hibernate, JDO, JPA, etc.
- The OXM module is responsible for linking the Object / XML – XMLBeans, JAXB, etc.
- The JMS (Java Messaging Service) module is responsible for creating, sending and receiving messages.
- Transactions supports transaction management for classes that implement certain methods and POJOs.
Spring Framework Miscellaneous Modules
Spring also includes a number of other important modules, such as AOP, Aspects, Instrumentation, Messaging and Test.
- AOP implements aspect-oriented programming and allows using the entire arsenal of AOP capabilities.
- The Aspects module provides integration with AspectJ, which is also a powerful AOP framework.
- Instrumentation is responsible for supporting class instrumentation and class loader, which are used in server applications.
- The Messaging module provides STOMP support.
- Finally, the Test module provides testing using TestNG or the JUnit Framework.
That’s all for a brief introduction of Spring Framework.