// Building Distributed Object Applications with CORBA
// Infowave (Thailand) Co., Ltd.
// http://www.waveman.com
// Jan 1998
public class Client {
public static void main(String[] args) {
if(args.length != 2) {
System.out.println("Usage:
vbj Client <carrier-name> <aircraft-name>\n");
return;
}
String carrierName = args[0];
String aircraftName = args[1];
org.omg.CORBA.Object carrier = null;
org.omg.CORBA.Object aircraft = null;
org.omg.CORBA.ORB orb = null;
try {
orb = org.omg.CORBA.ORB.init(args,
null);
}
catch (org.omg.CORBA.SystemException
se) {
System.err.println("ORB
init failure " + se);
System.exit(1);
}
{ // scope
try {
carrier = orb.bind("IDL:Ship/AircraftCarrier:1.0", carrierName, null, null);
}
catch (org.omg.CORBA.SystemException
se) {
System.err.println("ORB init failure " + se);
System.exit(1);
}
org.omg.CORBA.Request
request = carrier._request("launch");
request.add_in_arg().insert_string(aircraftName);
request.set_return_type(orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_objref));
request.invoke();
aircraft = request.result().value().extract_Object();
}
{ // scope
org.omg.CORBA.Request
request = aircraft._request("codeNumber");
request.set_return_type(orb.get_primitive_tc(org.omg.CORBA.TCKind.tk_string));
request.invoke();
String designation
= request.result().value().extract_string();
System.out.println
("Aircraft " + designation + " is coming your way");
}
{ // scope
org.omg.CORBA.Request
request = aircraft._request("attitude");
int altitude = 10000;
org.omg.CORBA.Any
ioAltitude = request.add_inout_arg();
ioAltitude.insert_long(altitude);
String direction =
"headup";
request.add_in_arg().insert_string(direction);
request.invoke();
altitude = ioAltitude.extract_long();
System.out.println
("Aircraft is heading up to " + altitude + " Feet.");
}
}
}