Home arrow Java & J2EE arrow Page 4 - Introducing the Spring Framework

Spring Framework in the Real World - Java

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.

TABLE OF CONTENTS:
  1. Introducing the Spring Framework
  2. Using Spring Framework, Step by Step
  3. Mapping the Beans continued
  4. Spring Framework in the Real World
  5. Beans and Client
By: A.P.Rajshekhar
Rating: starstarstarstarstar / 113
March 05, 2008

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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 & J2EE Articles          >>> More By A.P.Rajshekhar
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVA & J2EE ARTICLES

- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: