[omniORB] corbaloc/corbaname

Nick Murtagh murtaghn@tcd.ie
Wed, 6 Feb 2002 22:22:02 +0000


On Wednesday 06 February 2002 22:03, Richard Hardgrave wrote:
> I guess I'm still a bit foggy on exactly how to
> use the corbaloc/corbaname URIs.
> First off, I'm using omniORB 3.0.3, on Solaris 2.5.1.

I use it like this, which works:

assuming you have connected to the orb, and have something like

  const char *corbaname = (const char *)"corbaname::myserver.com";

then you do (omitting exception handling)

  CORBA::Object_var obj;
  obj = orb -> string_to_object(corbaname);

  // Narrow the reference returned.
  rootContext = CosNaming::NamingContext::_narrow(obj);

  // Create a name object
  CosNaming::Name name;
  name.length(2);
  name[0].id = (const char *) "put";
  name[0].kind = (const char *) "something";
  name[1].id = (const char *) "interesting";
  name[1].kind = (const char*) "here";

  newobj = rootContext -> resolve(name);

I use this so much I put it in it's own function. This may not
be the only way you can use corbaname, but it works for
me and I'm happy enough with it :) This is (I think) a modified
version of one of the omniORB examples.

Nick