SupplyServerpublic class SupplyServer extends Object
Methods Summary |
---|
public static void | main(java.lang.String[] argv)Execution of Java programs starts at main()
new SupplyServer().runServer(argv);
| protected void | runServer(java.lang.String[] argv)Do the work of contacting the ORB, registering with it,
binding the Object, and waiting for clients.
try {
// Create and initialize the ORB
ORB orb = ORB.init(argv, null);
// create servant and register it with the ORB
SupplyImpl imp = new SupplyImpl("Fred");
orb.connect(imp);
// get the root naming context
org.omg.CORBA.Object objRef =
orb.resolve_initial_references("NameService");
NamingContext ncRef = NamingContextHelper.narrow(objRef);
// bind the Object Reference in Naming
NameComponent nc = new NameComponent("Supply", "");
NameComponent path[] = {nc};
ncRef.rebind(path, imp);
// Wait for clients to invoke us. This use of Object
// (fully-qualified because of ORG.OMG.CORBA.Object)
// is equivalent to a UNIX pause() system call, that is,
// an indefinite wait.
System.out.println("Server: Waiting for clients...");
java.lang.Object sync = new java.lang.Object();
synchronized (sync) {
sync.wait();
}
} catch (Exception e) {
System.err.println("ERROR: " + e);
e.printStackTrace(System.out);
}
|
|