Listing 5: The ChartServer class

public class ChartServer
{
  public static ORB orb;

  //The main
  public static void main(String args[])
  {
  try
  {
    // Initialize the ORB.
    System.out.println("Initializing the ORB");

    orb = ORB.init(args, null);
    org.omg.CORBA.Object poa_obj = orb.resolve_initial_references("RootPOA");
    org.omg.PortableServer.POA root_poa = 
      org.omg.PortableServer.POAHelper.narrow(poa_obj);

    // Create servants, activate them, export the IOR.

    System.out.println("Creating objects");
    ChartServerImpl chartImpl = new ChartServerImpl();
    byte[] oid = root_poa.activate_object(chartImpl);
    createIOR(root_poa, oid, "chart.ior", if_ChartServerHelper.id());

    // Activate the POA Manager to allow new requests to arrive
  ...........

    // Give control to the ORB to let it process incoming requests
  ...........
  }
  catch (//exceptions)
  {
      //display message
  }
  }

  /**
   * This function takes a poa and object id, builds an object
   * reference (IOR) representing that object, and exports the object
   * reference to a file.
   */

   public static void createIOR(POA poa, byte[] oid, String filename, 
     String type_id)
   {
  .....................

   }

}
— End of Listing —