Coding the server with the BOA - ImplBase 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); 
      }

      Ship.AircraftCarrier carrier = new AircraftCarrierImpl("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 extends Ship._AircraftCarrierImplBase {
   public AircraftCarrierImpl(String name) {
      super(name);
   }

   public AircraftCarrierImpl() {
      super();
   }

   public Ship.Aircraft launch(String name) {
      Ship.Aircraft aircraft = new AircraftImpl(name);
      _boa().obj_is_ready(aircraft);

      System.out.println(aircraft + " launched 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 extends Ship._AircraftImplBase {
   private String _codeNumber;

   public AircraftImpl(String codeNumber) {
      super(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;
      else if (direction.compareTo("headdown") == 0)
         altiude.value -= 1000;

      // 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"