jobs4timesLogo jobs4timesLogo

Spring FrameWork

Agenda :
  • It is a special software that is capable of developing applications based on ceratian architecture with the ability to generate common logics of the application.
  • It is given based on core technologies.
  • It provides an abstraction layer on core technologies.

Struts: It is a framework to develop MVC-II architecture based web applications only.

Hibernate: Its a ORM Framework which is used only for database operations.

Its a framework software which can be used to develop any kind of Java/J2EE applications.
Spring framework provides abstraction layer on:
  • java & J2EE core technologies
  • ORM Tools like:
    1. Hibernate
    2. JDO
    3. iBastis etc..,
    4. AOP Framework etc..,


  1. Spring framework is developed to simplify the development of enterprise applications in Java technologies.
  2. It is an open source framework begin developed by Interface21.
  3. The Spring provides light weight IoC Container and AOP framework.
  4. It provides support for JPA, Hibernate, Web services, Schedulers, Ajax, Struts, JSF and many other frameworks.
  5. The Spring MVC components can be used to develop MVC based web applications.
  6. The Spring 3.0 framework has been released with major enhancements and support for the Java 5 [JDK1.5].
  7. Spring can be used to configure declarative transaction management, remote access to your logic using RMI or web services, mailing facilities and various options in persisting your data to a database.
  8. Spring framework can be used in modular fashion, it allows to use in parts and leave the other components which is not required by the application.
  • Spring is an open source framework, which is very flexible while developing any kind of application. i.e. stand alone application/web-application/enterprise applications.
  • Struts is used only for web applications, where as Spring can be used for developing stand-alone application, applet based application, web application and enterprise application.
  • Spring framework is created to address the complexity of enterprise application development.
  • One of the chief advantages of the Spring framework is its layered architecture
  • Spring is a light-weight framework.
  • Spring is having total 6 modules.
  • We can use the modules independently or combine depending on the type of application and requirement.
  • Main core of Spring is IOC module.

The Advantages of spring framework

The advantages of spring are as follows:
  • Spring has layered architecture. Use what you need and leave you don't need now.
  • Spring Enables POJO Programming. There is no behind the scene magic here. POJO programming enables continuous integration and testability.
  • Dependency Injection and Inversion of Control Simplifies JDBC
  • Open source and no vendor lock-in.

The Features of Spring framework

The features of spring framework are as follows
  • Lightweight: Spring is lightweight when it comes to size and transparency. The basic version of spring framework is around 1MB. And the processing overhead is also very negligible.
  • Inversion of control (IOC): Loose coupling is achieved in spring using the technique Inversion of Control. The objects give their dependencies instead of creating or looking for dependent objects.
  • Aspect oriented (AOP): Spring supports Aspect oriented programming and enables cohesive development by separating application business logic from system services.
  • Container: Spring contains and manages the life cycle and configuration of application objects.
  • MVC Framework: Spring comes with MVC web application framework, built on core Spring functionality. This framework is highly configurable via strategy interfaces, and accommodates multiple view technologies like JSP, Velocity, Tiles, iText, and POI. But other frameworks can be easily used instead of Spring MVC Framework.
  • Transaction Management: Spring framework provides a generic abstraction layer for transaction management. This allowing the developer to add the pluggable transaction managers, and making it easy to demarcate transactions without dealing with low-level issues. Spring's transaction support is not tied to J2EE environments and it can be also used in container less environments.
  • JDBC Exception Handling: The JDBC abstraction layer of the Spring offers a meaningful exception hierarchy, which simplifies the error handling strategy. Integration with Hibernate, JDO, and iBATIS: Spring provides best Integration services with Hibernate, JDO and iBATIS
Spring framework came up with every module for every tier. No other framework contains these many modules.
  • Tier: It is a clear separation of two or more Systems arranged by one after another.
Possible Tiers while developing an application.
UI Tier
Web browser
Presentation Tier
Business Tier
Integration Tier
DataBase Tier
  • UI Tier: User Interface Tier. Like a web browser
  • Presentation Tier: CSS, HTML, JavaScript, Images, Servlet, Jsp, Web MVC Module of spring,Struts.
  • Business Tier: we can use plain java class, java beans, ejb, messaging services. For this Spring is providing J2EE Module.
  • Integration Tier: JDBC or any ORM tools like Hibernate, IBatis. For this Spring is providing JDBC& DAO Module.
  • DataBase Tier: under this Enterprise Information Services will come.
If you are using any ORM related tools like Hibernate, for this Spring provides one module ORM.

Spring Architecture:

Spring is well-organized architecture consisting of seven modules.
Modules in the Spring framework are:

Spring1.x: It has 7 modules. They are:
  1. Core
  2. DAO
  3. ORM
  4. JEE/Context
  5. Web
  6. MVC
  7. AOP

AOP Module
O/R Mapping ModuleWeb Context and Utility Module
JDBC and DAO ModuleApplication Contex Module
MVC Module
Core Container and Supporting Utilities

Spring2.x: It has 6 modules only. Because Web & Web MVC modules were clubbed together & given as Web MVC module.

O/R Mapping Module JDBC and DAO Module
AOP Module
JEE/Contex Module Web
MVC Module
Core Container and Supporting Utilities

Core Module:

  1. It is base module for all modules.
  2. Provides BeanFactory container which makes Spring as a container
  3. provides the fundamental functionality of the Spring framework.
  4. The Core package is the most import component of the Spring Framework.
  5. This component provides the Dependency Injection [DI] features.
This module contains IOC container.

IOC container is a piece of s/w, Which creates the objects and establish the dependencies.

Core module is sub-divided into 4 modules : They are
  1. bean
  2. core
  3. context
  4. Expression Language
  • The beans & core modules contains the code of IOC container.
  • Context module is dependent on beans & core module.
    When we use context module, it takes care of developing I18N applications, and validations.
  • By using context module also we can create IOC container.
  • If we created IOC container based on beans and core modules, If we want to take care of I18N applications we have to provide our own code.
  • If we created IOC container based on context module, It will take care of I18N applications on it's own.
Expression Language : This module is an extension to the JSPEL expression.
We can use Expression Language as part of configuration files as well as java programs and etc.,

DAO Module:

DAO stands for Data Access Object
This module contains set of classes & interfaces, which takes care of JDBC code by using DAO module, we no need to provide a tedious JDBC code.
  1. It provides abstraction layer on JDBC & allows us to do database operations.
  2. Using it we can focus only on database operations instead of doing repeated work by writing common code again and again.
  3. Here we can make use of JdbcTemplate class where we can call methods to do required database operation.
  4. We can connect to database either by manual code same like jdbc or we can do easily by using JdbcTemplate class.
  5. Using JdbcTemplate class we can retrieve data from database in the form of serializable objects.

ORM Module:

  1. It provides an abstraction layer on ORM Framework software's like Hibernate, iBatis, JDO etc..,
  2. Spring doesn't attempt to implement its own ORM solution
  3. Spring's transaction management supports each of these ORM frameworks as well as JDBC.
  4. As part of ORM module, Spring guys given the classes like HibernateTemplate, JPATemplate etc.,

JEE/Application Context Module:

  1. It provides abstraction layer on Java/J2EE technologies like Java Mail, JMS, JMX, EJB etc..,
  2. The context module is what makes spring as a framework.
  3. This module extends the concept of BeanFactory
  4. Adds support for internationalization (I18N) messages, application life cycle events, and validation.
  5. Supplies many enterprise services such as e-mail, JNDI access, EJB integration, remoting, and scheduling.

AOP [Aspect Oriented Programming] Module:

  1. One of the key components of Spring is the AOP framework.
  2. It provides a methodology to configure middle-ware services or to perform any authentication, validations or to perform any pre processing logic or post processing logic on our business logic methods.
  3. Without disturbing any kind of spring resources we can integrate our spring application with any kind of middle-ware service.
  4. Spring provides a separate layer for middle-Ware configuration.
  5. This module serves as the basis for developing your own aspects for your Spring-enabled application.
  • This module takes care of staring the AOP & ending the AOP.
  • This AoP programming module is integrated with AspectJ.
  • This AOP model, address of all the problems of object orientation(OOP)
  • A programming Language AspectJ is built based on AOP programming model.
  • The spring guys has integrated AspectJ programming language as part of spring.
  • Spring guys has developed their own aspects & placed inside the AOP module.
Ex: TransactionManager is predefined aspect given by the spring guys.

Web MVC Module:

It is given for two operations:
  1. To integrate spring application with any other web based framework like Struts, JSF etc..,
  2. It provides its own web framework named as Spring MVC to develop MVC-II architecture based web applications. It provides the MVC implementations for the web applications.
  • In the web based applications we generate reports, Spring guys has integrated the report generation tools like Jasper, IReports generation of excel sheets as part of spring.
  • The web module is divided into a 4 sub-modules : They are-
    1. Web
    2. Spring Servlet
    3. Spring Struts
    4. Spring Portlets
  • From Spring 3.0 onwards, they are removed a support of integrating Spring with Struts.
    According to Spring documentation, using struts 2 is same as Spring MVC.

Note: We can develop a spring application either by using all modules or only by using few modules of spring. We can also integrate our spring module with any kind of a java application. So spring is loosely coupled.
Terminology :

Spring is a open source, light weight, loosely coupled, aspect oriented & dependency injection based framework software which can be used to develop any kind of java/j2ee application.

Open Source: Spring software can be down loaded and used at free of cost. Spring developed source code can referred by any one who is interested.

Container is a special software which can manage complete life cycle of a given resource.

Loosely Coupled: Need not to inherit any class or interface as we do for our servlet programming. Instead of having "is-a" relationship here we can have "has-a" relationship.


  1. Spring is lightweight in terms of both size and overhead.
  2. The entire Spring framework can be distributed in a single JAR file that weighs in at just over 1 MB.
  3. Spring is non-intrusive: objects in a Spring-enabled application typically have no dependencies on Spring specific classes.
  4. Mainly spring is used for business logic. The same business logic if we try to develop using EJB, then its compulsory to have support of any application server like weblogic. But the same logic can be executed in Spring without help of any web server or application server. Because Spring provides its own containers in the form of pre defined classes.

Note:Servlet Container & EJB Container are heavy weight because unless we start web server or application server we cannot activate either servlet container or EJB Container.