|
Downloads: The following examples were tested with Javasoft JDK 1.3 and Inprise VisiBroker for Java 4.1 on a Win98 machine. Getting Started: Win98 system environment settings for JavaSoft JDK1.3 for directory C:\jdk1.3:
|
REM SET PATH=C:\jdk1.3\bin;%PATH% SET CLASSPATH=C:\progra~1\javasoft\jre\1.3\lib\rt.jar;%CLASSPATH% REM |
Win98 system environment settings for Inprise VisiBroker for Java 4.1 (including Naming and Event Service). This assumes that the installation directory is C:\Inprise\vbroker: |
REM VisiBroker for Java 4.1 REM SET VBROKER_ADM=C:\Inprise\vbroker\adm SET PATH=C:\Inprise\vbroker\bin;%PATH% REM |
Introduction: This example uses a very basic IDL file. Ship.idl
|
// Ship.idl module Ship { interface Aircraft {
interface AircraftCarrier {
};
|
Server.java |
// Building Distributed Object Applications with CORBA // Infowave (Thailand) Co., Ltd. // http://www.waveman.com // Jan 2000 import java.io.*;
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;
// Write object reference to an IOR file org.omg.CORBA.Object initRef = null;
FileWriter output =
new FileWriter("ns.ior");
myPOA.the_POAManager().activate();
|
Client.java |
// Building Distributed Object Applications with CORBA // Infowave (Thailand) Co., Ltd. // http://www.waveman.com // Jan 1998 import java.io.*;
public class Client
// Read IOR from file 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;
|
AircraftCarrierImpl.java |
// Building Distributed Object Applications with CORBA // Infowave (Thailand) Co., Ltd. // http://www.waveman.com // Sep 2000 public class AircraftCarrierImpl extends Ship.AircraftCarrierPOA
private org.omg.PortableServer.POA _rootPOA; public AircraftCarrierImpl(org.omg.PortableServer.POA rootPOA)
public Ship.Aircraft launch(String name)
org.omg.PortableServer.Servant aircraft
= new AircraftImpl(name);
System.out.println(name + " on Catapult 2"); Ship.Aircraft _aircraft = null;
|
AircraftImpl.java |
// Building Distributed Object Applications with CORBA // Infowave (Thailand) Co., Ltd. // http://www.waveman.com // Sep 2000 public class AircraftImpl extends Ship.AircraftPOA
public AircraftImpl()
public AircraftImpl(String codeNumber)
public String codeNumber()
|
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
|
prompt> idl2java Ship.idl prompt> vbjc Client.java |
Running the program: Now start the Smart Agent and server in one window, client in another window
|
prompt> osagent prompt> vbj Server prompt> vbj Client "Jolly 700" |