FileDocCategorySizeDatePackage
ServerNamingInit.javaAPI DocExample1798Wed Apr 05 11:25:42 BST 2000None

ServerNamingInit

public class ServerNamingInit extends Object
ServerNamingInit: Register a local CORBA ThisOrThatServer directly with a COS Naming Service. Example 4-8, Java Enterprise in a Nutshell, 1st ed. Author: Jim Farley

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)

    try {
      // Obtain ORB reference
      ORB myORB = ORB.init(argv, null); 

      // Make a ThisOrThatServer object to register with the ORB
      ThisOrThatServer impl = new ThisOrThatServerImpl();

      // Get the root name context
      org.omg.CORBA.Object objRef = 
        myORB.resolve_initial_references("NameService");
      NamingContext nc = NamingContextHelper.narrow(objRef);

      // Register the local object with the Name Service
      NameComponent ncomp = new NameComponent("ThisOrThatServer", "");
      NameComponent[] name = {ncomp};
      nc.rebind(name, impl);

      // Go into a wait state, waiting for clients to connect
      System.out.println("Waiting for clients...");
      java.lang.Object dummy = new String("I wait...");
      synchronized (dummy) {
        dummy.wait();
      }
    }
    catch (Exception e) {
      System.out.println("An error occurred while initializing server object:");
      e.printStackTrace();
    }