Java
  Home arrow Java arrow Page 2 - 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

    Route your faxes to your email inbox. Private, secure fax numbers available from CallWave. Choose your fax number.

    Introducing the Spring Framework - Using Spring Framework, Step by Step
    (Page 2 of 5 )

    To use the Spring Framework in an application, there are three main steps. They are:

    1. Developing the POJO

    2. Mapping the POJO

    3. Developing the Client

    The second step involves an XML file that the Spring Framework uses to understand the configuration. These are the details:

    Developing the POJO: POJO or Plain Old Java Objects are, essentially, simple JavaBeans. The first step in using the Spring Framework is to wrap the business logic in a JavaBean. For example, if the logic just says hello, the bean will be as follows:

    public class Hello


    {


    private String greeting;

    public Hello()


    {


    }


    public Hello(String a)


    {


    greeting=a;


    }


    public String sayhello(String s)


    {


    return greeting+s;


    }


    public void setGreeting(String a)


    {


    greeting=a;


    }


    }


    It is a simple JavaBean with getters and setters. That completes the first step.

    Mapping the Beans: The beans need to be mapped using XML so that the IoC container can ‘inject’ the required dependency at runtime. The configuration file contains the following entries. They are:

    • beans
    • bean
    • property
    • value

    These are the most common entries. They are arranged in a hierarchical manner. Here are the details:

    Beans is the first entry or tag. It is the root tag/element of the configuration file. It encapsulates the bean tags.

    The details of the bean are given to the Spring Framework. The details are passed using the attributes of the bean tag. The most commonly used attributes are:

    • id – id by which the bean will be called. It has to be unique.
    • class – the fully qualified name of the bean.

    For example, to provide the details for the Hello bean, the bean tag will be as follows:


    <beans>

    <bean id=”Hello” class=”org.me.Hello”>

    :

    :

    </bean>

    <beans>

    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 5 hosted by Hostway