Java
  Home arrow Java arrow Introducing the Spring Framework
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Developerworks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Introducing the Spring Framework
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2008-03-05

    Table of Contents:
  • Introducing the Spring Framework
  • Using Spring Framework, Step by Step
  • Mapping the Beans continued
  • Spring Framework in the Real World
  • Beans and Client

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    Introducing the Spring Framework
    (Page 1 of 5 )

    In this discussion, I will be focusing on the Spring Framework. The first section will be about the whys and wherefores of the Spring Framework. In the second and third sections, I will explain how to use the Spring Framework to implement business logic. In the fourth and fifth sections, I will develop an application that uses the Spring Framework.

    In an enterprise application, business logic forms the basis of transforming the persisted data. That is the reason why the business logic layer is considered the most important layer of any enterprise application. Typically, the Java Enterprise Edition (JEE) component that was used to implement business logic was Enterprise Java Beans (EJB). However, EJBs are heavy weight components that require application servers to run.

    This was the scenario before the Spring Framework came into the picture. The Spring Framework provides a lightweight container to run the objects implementing business logic. In other words, Spring Framework-based business objects do not require an application server to run.

    Spring Framework: What is it?

    By definition the Spring Framework is “An open-source layered Java/J2EE application framework having a light-weight container implementing Inversion-of-Control and Aspect Oriented Programming.” The key points here are “layered application framework” and “Inversion of Control and Aspect Oriented Programming.” These key points can be divided into two broad categories:

    1. Patterns

    2. Components of the Framework

    The former refers to the design patterns supported by Spring Framework and the latter refers to the components that build up the Framework. 

    Spring has two patterns at its core. They are:

      • Inversion-of-Control

      • Aspect Oriented Programming

    The former is also called IoC and the latter is known as AOP. Here are the details.

    Inversion-of-Control is called IoC for short. IoC “is a concept, and an associated set of programming techniques, in which the control flow is inverted compared to the traditional interaction model expressed in imperative style by a series of procedure calls.” In other words, the framework calls the procedures created by the programmer, rather than programmer calling the procedures or methods of the framework. IoC is also known as the “Hollywood Principle.” The Hollywood Principle says “Don’t call me, I will call you.”

    IoC is used to ‘inject’ dependencies at runtime. When one uses this pattern, the dependencies of a particular object are not satisfied at compile time. Instead, the framework provides the required dependencies to the object at runtime. Thus, this pattern releases the programmer from the chore of providing all the dependencies at compile time.

    Aspect Oriented Programming or AOP for short, is by definition “An approach to programming that attempts the separation of concerns, specifically cross-cutting concerns, as an advance in modularization.” Here, the key point is separation of concerns. Concern is another term for a module of an application, where module refers to a functionality of the application.

    Separation of concerns means that the applications are divided into modules that do not overlap in terms of functionality. However, some functionalities or modules/concerns always overlap other modules/concerns. Logging is an example of such a concern. AOP provides techniques to encapsulate cross cutting or overlapping concerns. In other words, by using AOP a developer can encapsulate cross cutting concerns.

    Spring provides both IoC as well as AOP. They are built into the core of the Spring Framework. The next aspect of the Spring Framework worth noting is its support for layered architecture. It provides this support through its various components. Some of them are:

    1. MVC Component

    2. IOC container

    3. DAO support

    These three cater to the Presentation, Business, and Persistence layers. Here is a brief overview:


    1. MVC Component: The flexibility of the Spring Framework is that one can use any MVC framework with it. However, it also provides its own framework, called Spring MVC. Spring MVC implements MVC-Model 2 for JSP. It does this by providing controller Servlet and JSP taglib for you to view.

    1. IoC Container: The business logic layer can be developed without coupling it with any other layers by using IoC provided by the Spring Framework. The IoC container is the core component of the framework. IoC lets the developer implement the business logic as Plain Old Java Objects (POJO) and wire them up so that they can be injected or called at runtime. This approach lets you avoid specifying the business objects as dependencies at compile time.

    1. DAO Support: Any of the technologies, including JDBC, Hibernate, and iBatis, can be used with the Spring Framework to access persisted data. The Spring Framework provides this functionality through its DAO support component. A developer can plug in almost any of the persistence framework by using the DAO component.

    That completes the bird’s eye view of the Spring Framework. Next, let us have a look at the steps involved in using the Spring Framework, specifically the IoC capability of the Spring Framework.

    More Java Articles
    More By A.P.Rajshekhar


       · I am happy that there finally is a simple Spring tutorial out there. However, I was...
       · HiYou can remove the exception by adding jar of apache commons-2 in the class...
       · It does actually solve the problem.Good luck :)
     

       

    JAVA ARTICLES

    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup
    - Using RPC-Style Web Services with J2EE
    - Integrating XML with J2EE
    - Taming Tiger: Concurrent Collections
    - Combating the ‘Object Crisis’

    Iron Speed



    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway