|
Server.java |
// Building Distributed Object Applications with CORBA // Infowave (Thailand) Co., Ltd. // http://www.waveman.com // Sep 2000 import org.omg.CosNaming.*; public class Server
org.omg.CORBA.Object objPOA = null;
org.omg.PortableServer.POA rootPOA =
null;
org.omg.PortableServer.POA myPOA = null; try {
org.omg.PortableServer.Servant carrier
= null;
// Name Service org.omg.CORBA.Object nsRef = null;
NamingContextExt initContext = null;
// Write object reference to NS org.omg.CORBA.Object initRef = null;
myPOA.the_POAManager().activate();
initContext.rebind(initContext.to_name("Nimitz"), initRef); orb.run();
|
Client.java |
// Building Distributed Object Applications with CORBA // Infowave (Thailand) Co., Ltd. // http://www.waveman.com // Sep 2000 import org.omg.CosNaming.*; public class Client
// Use Name Service org.omg.CORBA.Object nsRef = null;
NamingContextExt initContext = null;
org.omg.CORBA.Object initRef = null;
Ship.AircraftCarrier carrier = null;
// Standard program continues String flight = args.length > 0 ? args[0]: "Ghost Rider 101"; Ship.Aircraft aircraft = null;
String designation = null;
|
Building the server with VisiBroker: Create a directory and place Ship.idl, AircraftCarrierImpl.java, and AircraftImpl.java from the previous page into it. Also place this Server.java in the same directory.
|
prompt> idl2java Ship.idl prompt> vbjc Server.java |
Building the client with VisiBroker: Place Client.java into the same directory as above
|
prompt> idl2java Ship.idl prompt> vbjc Client.java |
Running the program: Three windows will be required.
|
prompt> osagent prompt> start nameserv objects prompt> vbj -DSVCnameroot=objects Server prompt> vbj -DSVCnameroot=objects Client "Sundowner 406" |
Note: It is usually easier to create three BAT files to contain the commands above.
|