|
Server.java |
// Building Distributed Object Applications with CORBA // Infowave (Thailand) Co., Ltd. // http://www.waveman.com // Jan 1998 import java.io.*;
public class Server
org.omg.CORBA.BOA boa = null;
// TIE uses these two new lines AircraftCarrierImpl new_carrier = new
AircraftCarrierImpl(boa);
try {
org.omg.CORBA.Object initRef = null;
NamingContext initContext = null;
NameComponent[] name = new NameComponent[1]; NamingContext objContext = null;
try {
System.out.println(carrier + " ready for launch !!!"); try {
|
Client.java |
// Building Distributed Object Applications with CORBA // Infowave (Thailand) Co., Ltd. // http://www.waveman.com // Jan 1998 import org.omg.CosNaming.*; public class Client
org.omg.CORBA.Object initRef = null;
NamingContext initContext = null;
NameComponent[] name = new NameComponent[3];
org.omg.CORBA.Object objRef = null;
Ship.AircraftCarrier carrier = null;
// Standard program continues
Ship.Aircraft aircraft = null;
String designation = aircraft.codeNumber(); System.out.println("Aircraft " + designation + " is airborne"); org.omg.CORBA.IntHolder alt = new org.omg.CORBA.IntHolder(10000); try {
try {
}
|
Building the server with VisiBroker: Create a directory and place Ship.idl, Server.java, AircraftCarrierImpl.java,
and AircraftImpl.java into it.
|
prompt> idl2java Ship.idl prompt> vbjc Server.java |
Building the client with VisiBroker: Place Client.java into the same directory as above or another directory together with Ship.idl
|
prompt> idl2java Ship.idl prompt> vbjc Client.java |
Running the program: Three windows will be required
|
prompt> osagent prompt> vbj -DJDKrenameBug -DORBservices=CosNaming com.visigenic.vbroker.services.CosNaming.ExtFactory objects navy.log prompt> vbj -DORBservices=CosNaming -DSVCnameroot=objects Server prompt> vbj -DORBservices=CosNaming -DSVCnameroot=objects Client "SunDowner
102"
|
Note: It is usually easier to create three BAT files to contain the commands above.
|