/*
* This example is from the book "Java Enterprise in a Nutshell".
* Copyright (c) 1999 by O'Reilly & Associates.
* You may distribute this source code for non-commercial purposes only.
* You may study, modify, and use this example for any purpose, as long as
* this notice is retained. Note that this example is provided "as is",
* WITHOUT WARRANTY of any kind either expressed or implied.
*/
//
// CORBA example 9: Initialize a remote object and generate an IOR.
//
import org.omg.CORBA.*;
public class ServerInit {
public static void main(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();
// Register the local object with the ORB
myORB.connect(impl);
// Get a stringified reference to the object
String sor = myORB.object_to_string(impl);
System.out.println("ThisOrThatServer IOR: " + sor);
// Go into a wait state, waiting for clients to connect
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();
}
}
}
|