- 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:
- iBastis etc..,
- AOP Framework etc..,
- Spring framework is developed to simplify the development of enterprise applications in
- It is an open source framework begin developed by Interface21.
- The Spring provides light weight IoC Container and AOP framework.
- It provides support for JPA, Hibernate, Web services, Schedulers, Ajax, Struts, JSF and
many other frameworks.
- The Spring MVC components can be used to develop MVC based web applications.
- The Spring 3.0 framework has been released with major enhancements and support for the
Java 5 [JDK1.5].
- 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.
- 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
Spring framework came up with every module for every tier. No other framework contains these many modules.
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.
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
Possible Tiers while developing an application.
- Tier: It is a clear separation of two or more Systems arranged by one after another.
|DataBase Tier |
If you are using any ORM related tools like Hibernate, for this Spring provides one module ORM.
- UI Tier: User Interface Tier. Like a web browser
- 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.
Spring is well-organized architecture consisting of seven modules.
Spring1.x: It has 7 modules. They are:
Modules in the Spring framework are:
|O/R Mapping Module||Web Context and Utility Module|
|JDBC and DAO Module||Application 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 ||JEE/Contex Module
|Core Container and Supporting Utilities|
This module contains IOC container.
- It is base module for all modules.
- Provides BeanFactory container which makes Spring as a container
- provides the fundamental functionality of the Spring framework.
- The Core package is the most import component of the Spring Framework.
- This component provides the Dependency Injection [DI] features.
IOC container is a piece of s/w, Which creates the objects and establish the dependencies.
Core module is sub-divided into 4 modules :
- Expression Language
Expression Language : This module is an extension to the JSPEL expression.
- 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.
We can use Expression Language as part of configuration files as well as java programs and etc.,
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.
- It provides abstraction layer on JDBC & allows us to do database operations.
- Using it we can focus only on database operations instead of doing repeated work by writing
common code again and again.
- Here we can make use of JdbcTemplate class where we can call methods to do required
- We can connect to database either by manual code same like jdbc or we can do easily by
using JdbcTemplate class.
- Using JdbcTemplate class we can retrieve data from database in the form of serializable
- It provides an abstraction layer on ORM Framework software's like Hibernate, iBatis, JDO
- Spring doesn't attempt to implement its own ORM solution
- Spring's transaction management supports each of these ORM frameworks as well as JDBC.
- As part of ORM module, Spring guys given the classes like HibernateTemplate, JPATemplate etc.,
JEE/Application Context Module:
- It provides abstraction layer on Java/J2EE technologies like Java Mail, JMS, JMX, EJB etc..,
- The context module is what makes spring as a framework.
- This module extends the concept of BeanFactory
- Adds support for internationalization (I18N) messages, application life cycle events, and
- Supplies many enterprise services such as e-mail, JNDI access, EJB integration, remoting,
AOP [Aspect Oriented Programming] Module:
- One of the key components of Spring is the AOP framework.
- 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.
- Without disturbing any kind of spring resources we can integrate our spring application with
any kind of middle-ware service.
- Spring provides a separate layer for middle-Ware configuration.
- This module serves as the basis for developing your own aspects for your Spring-enabled
Ex: TransactionManager is predefined aspect given by the spring guys.
- 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.
Web MVC Module:
It is given for two operations:
- To integrate spring application with any other web based framework like Struts, JSF etc..,
- 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-
- Spring Servlet
- Spring Struts
- 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.
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.
- Spring is lightweight in terms of both size and overhead.
- The entire Spring framework can be distributed in a single JAR file that weighs in at just
over 1 MB.
- Spring is non-intrusive: objects in a Spring-enabled application typically have no
dependencies on Spring specific classes.
- 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.