Coding the server with the BOA - TIE approach 
 

Server.java
 

// Building Distributed Object Applications with CORBA
// Infowave (Thailand) Co., Ltd.
// http://www.waveman.com
// Jan 1998

public class Server {
   public static void main(String[] args) {
      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); 
      }

      org.omg.CORBA.BOA boa = null;
      try {
         boa = orb.BOA_init();
      }
      catch (org.omg.CORBA.SystemException se) { 
         System.err.println("BOA init failure " + se); 
         System.exit(1); 
      }

      // TIE uses these two new lines

      AircraftCarrierImpl new_carrier = new AircraftCarrierImpl(boa);
      Ship.AircraftCarrier carrier = new Ship._tie_AircraftCarrier(new_carrier, "Nimitz");

      try {
         boa.obj_is_ready(carrier);
      }
      catch (org.omg.CORBA.SystemException se) { 
         System.err.println("Object Ready failure " + se); 
         System.exit(1); 
      }

      System.out.println(carrier + " ready for launch !!!");

      try {
         boa.impl_is_ready();
      }
      catch (org.omg.CORBA.SystemException se) { 
         System.err.println("Impl Ready failure " + se); 
         System.exit(1); 
      }
   }
}
 


AircraftCarrierImpl.java
 

// Building Distributed Object Applications with CORBA
// Infowave (Thailand) Co., Ltd.
// http://www.waveman.com
// Jan 1998

public class AircraftCarrierImpl implements Ship.AircraftCarrierOperations {

   // data member and constructor for TIE

   private org.omg.CORBA.BOA _boa;
   public AircraftCarrierImpl(org.omg.CORBA.BOA boa) {
      _boa = boa;
   }

   public Ship.Aircraft launch(String name) {
     AircraftImpl new_aircraft = new AircraftImpl(name);
      Ship.Aircraft aircraft = new Ship._tie_Aircraft(new_aircraft);

      _boa.obj_is_ready(aircraft);

      System.out.println(aircraft + " on Catapult 2");

      return aircraft;
   }
}
 


AircraftImpl.java
 

// Building Distributed Object Applications with CORBA
// Infowave (Thailand) Co., Ltd.
// http://www.waveman.com
// Jan 1998

public class AircraftImpl implements Ship.AircraftOperations {

   private String _codeNumber;

   public AircraftImpl(String codeNumber) {
      _codeNumber = codeNumber;
   }

   public String codeNumber() {
      return _codeNumber;
   }

   public void attitude(org.omg.CORBA.IntHolder altiude, String direction) {
      if (direction.compareTo("headup") == 0) {
         altiude.value += 1000;
         System.out.println("Going UP !!! " + altiude.value);
      }
      else if (direction.compareTo("headdown") == 0) {
         altiude.value -= 1000;
         System.out.println("Going DOWN !!! " + altiude.value);
      }
      else System.out.println("No CHANGE !!! " + altiude.value);
 
      // otherwise no change in altitude
   }
}
 


Building the server:

Create a directory and place Ship.idl, Server.java, AircraftCarrierImpl.java, and AircraftImpl.java into it.
 


prompt> idl2java Ship.idl
prompt> vbjc Server.java
 

Running the program:

You should have previously built the client.
Now start the Smart Agent and server in one window, client in another window
 


prompt> osagent
prompt> vbj Server
 
prompt> vbj Client Nimitz "Ghost 202"