Spring Modular Architecture

In a previous article Introduction to Spring, we discussed What is Spring and why it so popular among Java developers and we also discussed how Spring has broken its complete framework into different-different modules based on the functionality.

Spring framework is organized into 20 modules which can again be grouped into Core Container, Web, Data Access/Integration, AOP, Aspect, Instrumentation, Messaging, and Test, as shown in the following diagram.
 spring-modules

Core container

The Core and Beans modules provide the most fundamental parts of the framework and provide the IoC and Dependency Injection features. The basic concept here is the BeanFactorywhich provides a sophisticated implementation of the factory pattern. It removes the need for programmatic singletons and allows you to decouple the configuration and specification of dependencies from your actual program logic.

The Context module builds on the solid base provided by the Core and Beans modules: it provides a way to access objects in a framework-style manner in a fashion somewhat reminiscent of a JNDI-registry. The Context module inherits its features from the Beans module and adds support for internationalization (I18N) (using for example resource bundles), event-propagation, resource-loading, and the transparent creation of contexts by, for example, a servlet container. The Context module also contains support for some Java EE features like EJB, JMX, and basic remoting support. The ApplicationContext interface is the focal point of the Context module that provides these features.

The Expression Language module provides a powerful expression language for querying and manipulating an object graph at runtime. It can be seen as an extension of the unified expression language (unified EL) as specified in the JSP 2.1 specification. The language supports setting and getting of property values, property assignment, method invocation, accessing the context of arrays, collections, and indexers, logical and arithmetic operators, named variables, and retrieval of objects by name from Spring's IoC container. It also supports list projection and selection, as well as common list aggregators.

Spring Web module

Spring's Web module provides basic web-oriented integration features, such as multipart file-upload functionality, the initialization of the IoC container using servlet listeners and a web-oriented application context. It also contains the web-related parts of Spring's remoting support.

The Web-Servlet module provides Spring's Model-View-Controller implementation for web-applications. Spring MVC framework is a full-featured MVC implementation for building Web applications. The MVC framework is highly configurable via strategy interfaces and accommodates numerous view technologies including JSP, Velocity, Tiles, iText, and POI. We can also create Rest APIs using the same annotation as we use in web MVC.

The Web-Portlet module provides the MVC implementation to be used in a portlet environment and mirrors what is provided in the Web-Servlet module.

Data Access & Integration

The Data Access/Integration layer consists of the JDBC, ORM, OXM, JMS and Transaction modules.

The JDBC module provides a JDBC-abstraction layer that removes the need to do tedious JDBC coding and parsing of database-vendor specific error codes.

The ORM module provides integration layers for popular object-relational mapping APIs, including JPA, JDO, Hibernate, and iBatis. Using the ORM package you can use all those O/R-mappers in combination with all the other features Spring offers, such as the simple declarative transaction management feature mentioned previously.

The OXM module provides an abstraction layer for using a number of Object/XML mapping implementations. Supported technologies include JAXB, Castor, XMLBeans, JiBX, and XStream.

The JMS module provides Spring's support for the Java Messaging Service. It contains features for both producing and consuming messages.

The Transaction module provides a way to do programmatic as well as declarative transaction management, not only for classes implementing special interfaces but for all your POJOs (plain old Java objects).

Spring AOP and Aspect

The Spring AOP module integrates Aspect Oriented Programming functionality directly into the Spring framework, which allows us to define segregate our cross-cutting functionalities from our business logic. As a result, we can easily AOP-enable any object managed by the Spring framework. The Spring AOP module provides transaction management services for objects in any Spring-based application.

There is also a separate Aspects module that provides integration with AspectJ.

Instrumentation

The Instrumentation module provides class instrumentation support and classloader implementations to be used in certain application servers.

Messaging

Spring framework's messaging module serves as a foundation for messaging-based applications. The module provides a set of classes e.g., Message, MessageChannelMessageHandler to send and receive messages from the application and it also provides a set of annotations for mapping messages to methods, similar to the Spring MVC annotation based programming model.

Test

Spring framework's Test module provides abstraction over a lot of testing and mocking framework such as TestNG, JUnit, Mockito, PowerMock which makes writing unit and integration a lot easier.

Below are the dependencies for the above modules

GroupId
ArtifactId
Description
org.springframework
spring-aop
Proxy-based AOP support
org.springframework
spring-aspects
AspectJ based aspects
org.springframework
spring-beans
Beans support, including Groovy
org.springframework
spring-context
Application context runtime, including scheduling and remoting abstractions
org.springframework
spring-context-support
Support classes for integrating common third-party libraries into a Spring application context
org.springframework
spring-core
Core utilities, used by many other Spring modules
org.springframework
spring-expression
Spring Expression Language (SpEL)
org.springframework
spring-instrument
Instrumentation agent for JVM bootstrapping
org.springframework
spring-instrument-tomcat
Instrumentation agent for Tomcat
org.springframework
spring-jdbc
JDBC support package, including DataSource setup and JDBC access support
org.springframework
spring-jms
JMS support package, including helper classes to send/receive JMS messages
org.springframework
spring-messaging
Support for messaging architectures and protocols
org.springframework
spring-orm
Object/Relational Mapping, including JPA and Hibernate support
org.springframework
spring-oxm
Object/XML Mapping
org.springframework
spring-test
Support for unit testing and integration testing Spring components
org.springframework
spring-tx
Transaction infrastructure, including DAO support and JCA integration
org.springframework
spring-web
Foundational web support, including web client and web-based remoting
org.springframework
spring-webmvc
HTTP-based Model-View-Controller and REST endpoints for Servlet stacks
org.springframework
spring-webmvc-portlet
MVC implementation to be used in a Portlet environment
org.springframework
spring-websocket
WebSocket and SockJS infrastructure, including STOMP messaging support
Previous Post Older Post Home

5 comments :

  1. Please correct the name of hyperlink from Introduction to String to Introduction to Spring. Typo mistake

    ReplyDelete
    Replies
    1. Thanks for mentioning it! I have corrected it.

      Delete
  2. Thanks for sharing such a nice blog...It is very useful and informative..
    mitroztech

    ReplyDelete
  3. Can truly relate and retain this outstanding post. Very well written. replica watches india

    ReplyDelete