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();
}