Developing a CORBA Client
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
/**
 * StockMarketClient
 */

import org.omg.CORBA.*;    
// All CORBA applications need these classes.
import org.omg.CosNaming.*;
// Client will use the naming service
import SimpleStocks.*;     
// The package containing our stubs.

public class StockMarketClient {
 
  public static void main(String[] args) {
 
    try {
     
// Create and initialize the ORB
      ORB orb = ORB.init(args, null);
 
     
// Get the root naming context
      NamingContext ncRef = NamingContextHelper.narrow(orb.resolve_initial_references("NameService"));

      // Resolve the object reference in naming
      NameComponent path[] = {new NameComponent("NASDAQ", "")};
      StockMarket market = StockMarketHelper.narrow(ncRef.resolve(path));

 
     
// Call the StockMarket server object and print results
      System.out.println("Price of MY COMPANY is $" + market.get_price("MY_COMPANY"));
    } catch( Exception e ) {
      e.printStackTrace();
    }
 
  }
 
}

2. Compile the files and run the CORBA client

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

E:\MyProjects\corba\StockCorba>java StockMarketClient
Price of MY COMPANY is $159.2

E:\MyProjects\corba\StockCorba>

 

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
Developing a CORBA Server 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.