/* File: Vctr2Server.java * Author: E. W. Grundke * * Comments: Server for the 2-dimensional vector demo. * * To run this on borg under java 1.3: * /opt/java/j2sdk1_3_1_02/bin/idlj -fserver VecRotn.idl * /opt/java/j2sdk1_3_1_02/bin/javac *.java * /opt/java/j2sdk1_3_1_02/bin/tnameserv -ORBInitialPort 50505 & * /opt/java/j2sdk1_3_1_02/bin/java Vctr2Server * On locutus, replace /opt/java/j2sdk1_3_1_02/bin by /usr/j2se/bin. */ import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; import java.util.Properties; public class Vctr2Server { public static void main(String args[]) { try{ // create and initialize an ORB on port number 50505: Properties props = new Properties(); props.put("org.omg.CORBA.ORBInitialPort", "50505"); ORB orb = ORB.init((String[])null, props); // create servant and register it with the ORB Vctr2Servant svt = new Vctr2Servant(orb); orb.connect(svt); // get the root naming context org.omg.CORBA.Object obj = orb.resolve_initial_references("NameService"); // narrow() does typecasting for CORBA objects NamingContext naming = NamingContextHelper.narrow(obj); // bind the Object Reference in naming context NameComponent nc = new NameComponent("Rotator", ""); NameComponent path[] = {nc}; naming.rebind(path, svt); // wait forever 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); } } }