Coding a CORBA Client that uses a Stringified reference
Gopalan Suresh Raj

Note
To work with any of these samples, you will need the following:
.........................................JDK 1.2 (Java 2)
.........................................
The idltojava compiler

The Steps involved in developing a CORBA Client are:

  1. Implement your CORBA client application
  2. Compile the files and run the CORBA client

1. Implement your CORBA client application

StockMarketClient.java
/**
 * Client.java, stringified object reference version
 */

import java.io.*;
import org.omg.CORBA.*;    
// All CORBA applications need these classes.
import Interest.*;          
// The package containing our stubs.

public class Client {
  public static void main(String args[]) {
    try {
      // create and initialize the ORB
      ORB orb = ORB.init(args, null);

      // Get the stringified object reference and destringify it.
      String filename = System.getProperty("user.home")+
                        System.getProperty("file.separator")+"RatesIOR";
      FileInputStream fis = new FileInputStream(filename);
      DataInputStream dis = new DataInputStream(fis) ;
      String ior = dis.readLine() ;
      org.omg.CORBA.Object obj = orb.string_to_object(ior) ;

      Rates ratesRef = RatesHelper.narrow(obj);

      // call the Interest server object and print results
      System.out.println("\nInterest Rates provided by The Lake Side Credit Union");
      System.out.println("    Premium Checkings Interest = " +
                         ratesRef.getPremiumChecking() + "%");
      System.out.println("    Premium Savings Interest   = " +
                         ratesRef.getPremiumSavings() + "%");
      System.out.println("    Economy Checkings Interest = " +
                         ratesRef.getEconomyChecking() + "%");
      System.out.println("    Economy Savings Interest   = " +
                         ratesRef.getEconomySavings() + "%");

    } catch (Exception e) {
      System.out.println("ERROR : " + e) ;
      e.printStackTrace(System.out);
    }
  }
}

2. Compile the files and run the CORBA client

E:\MyProjects\corba\Stringification>
E:\MyProjects\corba\Stringification>javac *.java

E:\MyProjects\corba\Stringification>java Client

Interest Rates provided by The Lake Side Credit Union
    Premium Checkings Interest = 0.55%
    Premium Savings Interest   = 2.1%
    Economy Checkings Interest = 0.2%
    Economy Savings Interest   = 1.5%

E:\MyProjects\corba\Stringification>
E:\MyProjects\corba\Stringification>

 

About the Author...
Gopalan Suresh Raj is a Software Architect, Developer and an active Author. He is contributing author to a couple of books "Enterprise Java Computing-Applications and Architecture" (Cambridge University Press, June '99) and "The Awesome Power of JavaBeans" (Manning, July'98). His expertise spans enterprise component architectures and distributed object computing. Visit him at his Web Cornucopia© site (http://www.execpc.com/~gopalan) or mail him at gopalan@execpc.com.

 

click here to go to the
Coding a CORBA Server that creates Stringified Servants Page...
click here to go to
My CORBA HomePage...

Go to the Component Engineering Cornucopia page

This site was developed and is maintained by Gopalan Suresh Raj

This page has been visited times since September 21,1998.

Last Updated : Dec 19, '98

If you have any questions, comments, or problems regarding this site, please write to me I would love to hear from you.


Copyright (c) 1997-2000, Gopalan Suresh Raj - All rights reserved. Terms of use.

All products and companies mentioned at this site are trademarks of their respective owners.