FileDocCategorySizeDatePackage
ServerMain.javaAPI DocExample1349Tue Mar 21 16:29:34 GMT 2000tuning.distrib.corba

ServerMain

public class ServerMain extends Object

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

        try{
            // create and initialize the ORB
            ORB orb = ORB.init(args, null);
 
            // create servant and register it with the ORB
            ServerObjectImpl serverRef = new ServerObjectImpl();
            orb.connect(serverRef);
 
            // 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("ServerObject", "");
            NameComponent path[] = {nc};
            ncRef.rebind(path, serverRef);
 
            // wait for invocations from clients
            System.out.println("Server now waiting for client invocations");
            java.lang.Object sync = new java.lang.Object();
            synchronized (sync) {
                sync.wait();
            }
 
        } catch (Exception e) {
            System.err.println("ERROR: " + e);
            e.printStackTrace(System.out);
        }