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

    The Web Buyer's Guide is your best source for white papers on a wide range of IT products and services. This Week's Featured White Papers: Help Simplify Virtualization by IBM

    Introducing the Spring Framework - Beans and Client
    (Page 5 of 5 )

    Next is the beans.xml file. It contains configuration information for the POJO and its properties.


    <beans>

    <bean id=”SimpleInterestBean”

    class=”org.me.SimpleInterestCalculatorBean”>

    <property name=”principle”>

    <value>10000.00<value>

    </property>

    <property name=”years”>

    <value>10.00<value>

    </property>

    <property name=”rate”>

    <value>9.50<value>

    </property>


    </bean>

    <beans>


    Last is the code for Client.java. It first loads the configuration, then gets a reference for BeanFactory and retrieves the instance of SimpleInterestCalculatorBean. After that, it calls the calculate method to get the calculated simple interest. Here is the code:


    import java.io.*;

    import org.springframework.beans.factory.*;

    import org.springframework.beans.factory.xml.*;

    import org.springframework.core.io.*;


    public class Client


    {


    public static void main(String args[]) throws Exception


    {


    try


    {


    System.out.println("please Wait.");

    Resource res = new ClassPathResource("beans.xml");

    BeanFactory factory = new XmlBeanFactory(res);

    SimpleInterestCalculatorBean interest=

    (SimpleInterestCalculatorBean)factory.getBean(“SimpleInterestBean);

    System.out.println(interest.getInterest());

    }


    catch(Exception e1)


    { System.out.println(""+e1); }


    }


    }


    That completes the introduction to Spring Framework. What has been described here is just the tip of the iceberg. In the future, I will be discussing each of the components of Spring Framework in depth. Till then…


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · 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 6 hosted by Hostway