Java
  Home arrow Java arrow Page 2 - Introducing the Spring Framework
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 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? 
Google.com  
JAVA

Introducing the Spring Framework
By: A.P.Rajshekhar
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 18
    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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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

     
     
    ADVERTISEMENT


    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
     

       

    JAVA ARTICLES

    - Exception Handling Techniques in Java
    - More About Multithreading in Java
    - The Basics of Multiple Threads in Java
    - Data Access Using Spring Framework JDBC
    - New Object Initialization in Java
    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek