Developing a CORBA
Server
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 Server are:
1. Define your Interface as an
IDL file
Define a module called SimpleStocks with an interface called StockMarket. Place this in a file called StockMarket.idl.
StockMarket.idl |
module
SimpleStocks { interface StockMarket { float get_price( in string symbol ); }; }; |
2. Compile the IDL file and
generate stubs and skeletons
When compiled with the idltojava compiler, the stubs and skeletons are placed in a
package named after our module - SimpleStocks
E:\MyProjects\corba\StockCorba> E:\MyProjects\corba\StockCorba>idltojava -fno-cpp stockmarket.idl E:\MyProjects\corba\StockCorba> |
3. Develop the servant class by
writing an implementation for our interface
Notice that we extend _StockMarketImplBase. This class which we use as the parent is
generated for us and is placed in the generated SimpleStocks package.
StockMarketImpl.java |
/** * StockMarketImpl */ import org.omg.CORBA.*; // All CORBA applications need these classes. import SimpleStocks.*; // The package containing our stubs public class StockMarketImpl extends _StockMarketImplBase {
public float get_price( String symbol )
{ public StockMarketImpl() { super(); } } |
4. Develop the CORBA server application
StockMarketServer.java |
/** * StockMarketServer Main */ import org.omg.CORBA.*; // All CORBA applications need these classes. import org.omg.CosNaming.*; // Server will use the naming service. import SimpleStocks.*; // The package containing our stubs public class StockMarketServer
{
//
Create the servant and register it with the ORB
//
Get the root naming context
//
Wait forever for current thread to die |
5. Compile the files, run the
CORBA Naming Service provided with JDK 1.2
The naming service is called tnameserv and is part of the JDK1.2 download. It is a CORBA
Naming Service implementation provided by JavaSoft.
E:\MyProjects\corba\StockCorba> E:\MyProjects\corba\StockCorba>javac *.java E:\MyProjects\corba\StockCorba>tnameserv Initial Naming Context: IOR:000000000000002849444c3a6f6d672e6f72672f436f734e616d696e672f4e61 6d696e67436f6e746578743a312e3000000000010000000000000030000100000000 0008686f6d655f7063000422000000000018afabcafe0000000272e141a700000008 0000000000000000 TransientNameServer: setting port for initial object references to: 900 |
6. Run the CORBA Server
E:\MyProjects\corba\StockCorba> E:\MyProjects\corba\StockCorba>java StockMarketServer The StockMarket Server is up and ready... |
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. |
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 |
Copyright (c) 1997-99, Gopalan Suresh Raj - All rights reserved. Terms of use. |
All products and companies mentioned at this site,are trademarks of their respective owners. |