Coding a CORBA
Server that creates Stringified Servants
Gopalan Suresh Raj
Note |
To
work with any of these samples, you will need the
following: .........................................JDK 1.2 (Java 2) .........................................The idltojava compiler |
To invoke an operation on a CORBA object, a client application needs a reference to the server object. You can get such references in a number of ways, such as calling ORB.resolve_initial_references() or using another CORBA object (like the name service). Often, however, there is no naming service available in the distributed environment. In that situation, CORBA clients use a stringified object reference to find their first object.
The Steps involved in developing a CORBA Server that uses Stringification are:
1. Define your Interface as an
IDL file
Define a module called Interest with an interface called Rates. Place this in a file called Interest.idl.
Interest.idl |
module Interest { interface Rates { float getPremiumChecking(); float getPremiumSavings(); float getEconomyChecking(); float getEconomySavings(); }; }; |
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 - Interest
E:\MyProjects\corba\Stringification> E:\MyProjects\corba\Stringification>idltojava -fno-cpp Interest.idl E:\MyProjects\corba\Stringification> |
3. Develop the servant class by
writing an implementation for our interface
Notice that we extend InterestRates. This class which we use as the parent is
generated for us and is placed in the generated Interest package.
InterestRates.java |
/** * InterestRates.java, stringified object reference version */ import org.omg.CORBA.*; // All CORBA applications need these classes. import Interest.*; // The package containing our stubs public class InterestRates
extends _RatesImplBase { |
4. Develop the CORBA server application
Server.java |
/** * Server.java, stringified object reference version */ import org.omg.CORBA.*; // All CORBA applications need these classes. import Interest.*; // The package containing our stubs. import java.io.*; public class Server {
public static void main(String args[]) {
//
create servant and register it with the ORB
//
stringify the ratesRef and dump it in a file
System.out.println("The CORBA Server is up and
running...");
} catch (Exception e) { |
5. Compile the files and run the CORBA Server
E:\MyProjects\corba\Stringification> E:\MyProjects\corba\Stringification>javac *.java E:\MyProjects\corba\Stringification>java Server The Servant Reference has been Stringified... The CORBA Server is up and running... |
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 Client that uses a Stringified reference Page... |
click here to go to My CORBA HomePage... |
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-2000, Gopalan Suresh Raj - All rights reserved. Terms of use. |
All products and companies mentioned at this site are trademarks of their respective owners. |