Introduction of the Spring Web Application Framework

batterycopperInternet and Web Development

Nov 12, 2013 (3 years and 5 months ago)


Introduction of the Spring Web Application Framework

Lance Berry

CIS 764 Fall 2006

Enterprise Database Design

Kansas State University


This paper will attempt to provide a brief overview of the Spring Framework as
defined by the Open Source Sp
ring Framework project and its affiliate website
. This paper will attempt to provide a description of features,
advantages, and disadvantages of using the Spring framework.


Most web application frameworks, such as the STRUTS framework, attempt to be
a “do
all, be
all” solution to developing enterprise
level applications. In many ways this
can be useful, providing

of design by using one technology and framewor
k. In
some ways, though, this can be cumbersome and difficult to incorporate. The Spring
framework ventures a different approach to the web application paradigm by providing
an “as needed” basis. As a standalone web development framework, Spring can pro
many of the
necessary to components to build an enterprise application. However, the
strength and unique character of Spring is that it can integrate with other technologies and
applications seamlessly and easily.


The Spring Model is divide
d into several different areas as defined by this picture:



Uses Inversion of Control to decouple applications and classes. POJO’s
and POJI’s, as well as newly developed classes

are developed and referenced as
No one class is dependent

on any other classes. The Core component uses
a Dispatcher servlet to route request and responses.


Aspect Oriented Programming. Aspect Oriented Programming is an
extension of the Object Oriented Programming paradigm. AOP allows
programmers to i
nject programming calls before, after, or during execution calls
without directly modifying the resultant class. In addition to having a core AOP
stack, Spring also provides integration with the AspectJ stock.


Data Access Object. Provides basic JD
BC connectivity and transaction


Object Relational Mapping. Instead of having a built
in component for
this particular technology, Spring relies on other open source projects. Object
Relational Mapping is the means of associating an o
bject with its container.
Traditionally, database SQL access cannot provide a hierarchical structure. Data
is received in the form of rows and columns. Spring provides hooks into several
different popular technologies including Hibernate, Toplink, JDO,
and iBATIS.


Java Enterprise
. Provides both synchronous and asynchronous e
mail message ca
pability, remoting capability, and EJB integration. This is
provided by hooks into other technologies such as Java Management Extensions
(JMX) which p
rovides distributed web applications, Java Messaging Service
(JMS) which provides messaging capability. The JEE component provides
connectors to standard EJB’s and connectors through the Java Connector
Architecture (JCA).

Web Tier

Provides the visual c
omponents of the enterprise application. Not
only does Spring provide its own Model
Controller piece, it can hook into
several different components including newer technologies such as Jasper and
Velocity, older technologies such as Struts and Webwor
k, and basic view
components such as Java Server Faces (JSF) and Java Server Pages JSP. Spring
also supports Portlets,
which are similar to servlets except that they have two
distinct phases, action and render. The ‘Action’ phase occurs only once, wherea
the ‘Render’ phase may occur several times to produce various views.

Advantages of Using Spring

Spring has numerous advantages. One of the biggest advantages (and the one
most referenced) is its inherent modularity. Outside of the Inversion of

container, being the BeanFactory, virtually any piece of Spring can use a different
technology. Spring can use this modularity to incorporate legacy applications that are
built as Enterprise Java Beans (EJB’s) or as Plain Old Java Objects (POJO’s
) and Plain
Old Java Interfaces (POJI). Using virtually any other framework requires rebuilding the
application to conform to its model.
Another big advantage to using Spring, is the ability
to unit test each component. Spring primarily uses Aspect Orie
nted Programming (AOP)
to support this. Most of the other frameworks can only test the integration of the entire
application. This makes testing cumbersome and difficult.

Disadvantages of Using Spring

The modularity of Spring comes at a surprising cos
t. While other frameworks
such as Struts rely on one XML file for configuration, Spring uses several different XML
files which are incorporated as metadata within the application. For smaller applications,
this is not as obvious. With larger application
s, this presents a unique difficulty. In this
way, Spring is termed as “too loose”
. Another disadvantage is that Spring also relies
heavily on its integration with other technologies. In some cases, such as the Spring
MVC and the AOP stack, limited fu
nctionality is provided. However, if extensive
functionality is required, Spring must hook into the other technologies. In the case of the
JEE and ORM components, Spring does not even provide a basic functionality. This is
y important if these are ne
eded. If they are needed, it requires knowledge in these
other areas in addition to Spring itself. Configuring the other components in is an easy
matter. Using them effectively is a different matter.

How Spring Works

Spring manages the application with

a single IOC container, which references
other objects as “beans”. The objects do not rely on each other for dependency, but
instead defer to the Spring container. In this way, Spring is able to incorporate POJO’s
and POJI’s as beans simply by referenci
ng them.


This is an example configuration of a Bean Factor

Resource resource=new FileSystemResource(“beans.xml”);

BeanFactory factory=new XmlBeanFactory(resource);

which references a bean configuration data file:

<?xml version=”1.0…..

id=”…” class=”…”/>

Or possibly multiple configuration files:


<import resource=”services.xml”/>

<import resource=”resources/messageSource.xml”/>

<bean id=”bean1” class=”…”/>

<bean id=”bean2” class=”…”/>

Incorporating Other Technologies

To in
corporate other technologies, Spring treats them as other beans. For
example, to reference a Hibernate object:


<bean id="myDataSource"

<property name="driverClassName"


<property name="url"

<property name="username" value="sa"/>

<property name="password" value=""/>


<bean id="mySessionFactory"

<property name="dataSource" ref="myDataSource"/>

<property name="mappingResources">





<property name="hibernateProperties">









Spring is enjoying the usual buzz that surrounds any new technology. While I
agree that it seems to support a modular
approach, I do not feel it meets the expectations
of simplicity that it touts itself to be.
It seems that the two determining factor of using
Spring is whether other components are really necessary and whether unit testing is
required. Until more example
s and better documentation are created, using Spring will
be a matter of choice instead of a de facto standard.



Johnson, Rod “Spring Framework Reference Documentation” Overview
Section 1.1


Lee, Bob “I Don’t Get


Johnson, Rod “Spring Framework Reference Documentation” IOC Container
Section 3


Johnson, Rod “Spring Framework Reference Documentation” Hibernate
Section 12.2


Raible, Matt “Comparing Web Frameworks”.

Harrop and Machacek
Pro Spring

Apress Publishing. 2005

Johnson, et al. “Spring Framework Reference Documentation”.