CS 696 Emerging Technologies: Distributed Objects |
---|
protected static NamingContext getRootContext() throws org.omg.CORBA.ORBPackage.InvalidName { org.omg.CORBA.Object initNCRef = ORB.init().resolve_initial_references("NameService"); return NamingContextHelper.narrow(initNCRef); }
NamingContext rootContext = NamingContextHelper.bind( "root:NS", hostName );
import IE.Iona.OrbixWeb._CORBA; import IE.Iona.OrbixWeb.CORBA.ORB; public class GreeterServer { public static void main (String args[]) { org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(); try { Greeter upTown = new _tie_Greeter( new TieGreeter( "Upton"), "up"); Greeter beach = new _tie_Greeter( new TieGreeter( "Bob"), "low"); Greeter mountain = new InheritedGreeter( "Mike", "high"); Greeter general = new InheritedGreeter( "Gloria"); _CORBA.Orbix.impl_is_ready( "Visitor", _CORBA.IT_INFINITE_TIMEOUT); System.out.println("Server going Down"); } catch ( org.omg.CORBA.SystemException corbaError) { System.out.println("Exception " + corbaError); } } }
import IE.Iona.OrbixWeb._OrbixWeb; import IE.Iona.OrbixWeb._CORBA ; import org.omg.CORBA.ORB; import org.omg.CORBA.SystemException ; import org.omg.CORBA.CosNaming.* ; import org.omg.CORBA.CosNaming.NamingContextPackage.*; public class RegisterInNS { public static void main(String args[]) throws Exception { org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(); NamingContext rootContext = getRootContext( orb ); NameComponent[] ca = new NameComponent[1]; ca[0] = new NameComponent("Califorina", ""); NamingContext stateContext = rootContext.bind_new_context( ca ); NameComponent[] city = new NameComponent[1]; city[0] = new NameComponent("Del Mar", ""); stateContext.bind( city, getGreeter( "low") ); city[0] = new NameComponent("Julian", ""); stateContext.bind( city, getGreeter( "high") ); city[0] = new NameComponent("San Diego", ""); stateContext.bind( city, getGreeter( "up") ); }
protected static Greeter getGreeter( String marker ) { String hostname = "eli.sdsu.edu"; String serverLabel = ":Visitor"; return GreeterHelper.bind(marker + serverLabel, hostname); } protected static NamingContext getRootContext( ORB myOrb) throws org.omg.CORBA.ORBPackage.InvalidName { org.omg.CORBA.Object initNCRef = myOrb.resolve_initial_references("NameService"); return NamingContextHelper.narrow(initNCRef); } }
import IE.Iona.OrbixWeb._OrbixWeb; import IE.Iona.OrbixWeb._CORBA ; import org.omg.CORBA.ORB; import org.omg.CORBA.SystemException ; import org.omg.CORBA.CosNaming.* ; import org.omg.CORBA.CosNaming.NamingContextPackage.*; public class SimpleNSClient { public static void main (String args[]) { org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(); Greeter californiaGreeter; NamingContext rootContext; try { rootContext = getRootContext(); NameComponent[] ca = new NameComponent[2]; ca[0] = new NameComponent("Califorina", ""); ca[1] = new NameComponent("Julian", ""); org.omg.CORBA.Object greeterRef = rootContext.resolve( ca ); californiaGreeter = GreeterHelper.narrow( greeterRef); System.out.println( californiaGreeter.name()); } catch ( Exception corbaError) { System.out.println("Exception " + corbaError); } } protected static NamingContext getRootContext() throws org.omg.CORBA.ORBPackage.InvalidName { org.omg.CORBA.Object initNCRef = ORB.init().resolve_initial_references("NameService"); return NamingContextHelper.narrow(initNCRef); } }