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

    PCmover - $15 Off with Coupon Code CJPH7Q

    Introducing the Spring Framework - Spring Framework in the Real World
    (Page 4 of 5 )

    In the previous section, the steps required to use the IoC component of the Spring Framework were enumerated. Now, it's time to develop a real world example based upon these steps. The application we are going to develop will wrap the logic to calculate simple interest. The application will have the following files:

    1. SimpleCalculatorBean.java – POJO that wraps the logic for calculating simple interest.

    2. bean.xml – The configuration file that contains details about the POJO

    3. Client.java – The client for the simple interest calculation


    First comes the SimpleCalculatorBean.java. It is a simple Java Bean that has getters and setters for rate, years, and principle. It also contains the calculate method for calculating simple interest. Here is the code:


    package org.me;

    class SimpleInterestCalculatorBean{


    float years;

    float principle;

    float rate;


    SimpleInterestCalculatorBean(){

    }


    public void setYears(float years){

    this.years=years;

    }


    public float getYears(){

    return years;

    }

     

    public void setPrinciple(float principle){

    this. principle = principle;

    }


    public float getPrinciple(){

    return principle;

    }

     

    public void setRate(float rate){

    this. rate=rate;

    }

     

    public float calculate(){

    return (float)((principle*rate*years)/100);

    }


    public float getInterest(){

    return calculate();

    }

     

    }

    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