//naming.java // Gerard Rodriguez, Feb 1998 // // naming service for Visigenic Objects. It Publishes the object in the // Visigenic naming service (gatekeeper) and publishes the same object // in the new ilu version 12 Infobus naming service import java.lang.*; import java.net.*; import java.io.*; public class naming { public static final String VISI_URL = "http://Eel:15000/"; // Change that to wherever the gatekeeper is" public static final String INFOBUS_NAMING_SERVICE = "http://www-diglib.stanford.edu/cgi-bin/testbed/cosnaming2/cosnaming.py"; // Change that to whatever the Infobus web naming server is public static void PublishInfobus (org.omg.CORBA.Object proxy, String name, String context, String typename, String type, org.omg.CORBA.ORB orb) { // This is the method that gets called when you want to Publish // the object in Visigenic and Infobus. It has the CORBA object, // the name of the service, the context, the typename of the object, // and the type itself (are they the same?) // and the ORB (needed to create the Visigenic naming resolver) String url = VISI_URL; url = url.concat(name); url = url.concat(".ior"); try { System.out.println("Resolving the url"); com.visigenic.vbroker.URLNaming.Resolver resolver = com.visigenic.vbroker.URLNaming.ResolverHelper.narrow( orb.resolve_initial_references("URLNamingResolver")); resolver.force_register_url(url,proxy); String pObject = orb.object_to_string(proxy); PublishInfobusCall(name, context, typename, type, pObject); } catch (Exception e) { System.err.println(e); } } public static void PublishVisi (org.omg.CORBA.Object proxy, String name, org.omg.CORBA.ORB orb) { // This is the method that gets called when you want to Publish // the object only in Visigenic. It has the CORBA object, // the name of the service, and the ORB (needed to create the resolver) String url = VISI_URL; url = url.concat(name); url = url.concat(".ior"); try { System.out.println("Resolving the url"); com.visigenic.vbroker.URLNaming.Resolver resolver = com.visigenic.vbroker.URLNaming.ResolverHelper.narrow( orb.resolve_initial_references("URLNamingResolver")); resolver.force_register_url(url,proxy); } catch (Exception e) { System.err.println(e); } } public static void PublishInfobusCall (String name ,String context, String typename, String type, String pObject) { // Publish in the InfoBus web naming server String url; String status = null; url = ""; try { url = url.concat(INFOBUS_NAMING_SERVICE); url = url.concat("?method=Bind&pName="); url = url.concat(name); url = url.concat("&pContext="); url = url.concat(context); url = url.concat("&pSBH="); url = url.concat(pObject); url = url.concat("&pTypeID="); url = url.concat(typename); url = url.concat("&pType="); url = url.concat(type); System.out.println("URL: " + url); URL bUrl = new URL(url); DataInputStream bUrlIn = new DataInputStream(bUrl.openStream()); status = bUrlIn.readLine(); status = status.trim(); bUrlIn.close(); } catch (Exception e) { System.out.println(e); } if (!(status.equals("Success"))) { System.out.println("Cannot bind:" + status); } else { System.out.println("Published!!!!"); } } }