import org.omg.CosNaming.*; // naming service import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; import java.util.*; import Arith.*; public class MathServer { public static void main(String args[]) { try{ // Create and initialize the ORB ORB orb = ORB.init(args, null); // Create the servant and register it with the ORB MultiplyServant mulRef = new MultiplyServant(); orb.connect(mulRef); // 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("Multiply", " "); NameComponent path[] = {nc}; ncRef.rebind(path, mulRef); System.out.println("server started...."); // Wait for invocations from 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); } } } class MultiplyServant extends _MultiplicationImplBase { public void multiply(double x, double y, org.omg.CORBA.DoubleHolder result) { result.value = x * y; } }