example code



Does anybody talk to a CORBA NameServer? got any example code?

I'm using ORBit-0.5.13 and CORBA-ORBit-0.4.3 w/ Huw Rogers patch.

I've got this hack working, but nothing clean like the python version
below...

Thanks,
Jason

#!/usr/bin/perl -w
BEGIN { unshift @ARGV, qw(-ORBIIOPIPv4 1); }

use CORBA::ORBit idl => [ qw(Foo.idl) ];
use Error qw(:try);
use strict;

my $orb = CORBA::ORB_init("orbit-local-orb");

my $ns_ior = `GET http://foo.bar/corba/NS/foo`;
chomp $ns_ior;
my $manager_name = 'foo/Manager';
my $ior = `/usr/bin/name-client $ns_ior resolve $manager_name`;
chomp $ior;
print $ior, "\n";

my $my_client = $orb->string_to_object($ior);

try {
	$my_client->Run;
} otherwise {
	die "Error Running\n";
};


#!/usr/bin/env python
#  ./foo.py -ORBNamingIOR=IOR:...

import sys, CORBA, CosNaming, Foo

sys.argv.extend(["-ORBIIOPIPv4=1"])

orb = CORBA.ORB_init(sys.argv)

try:
    obj = orb.resolve_initial_references("NameService")

    try:
        ns = obj._narrow(CosNaming.NamingContext)

        try:
            nc = CosNaming.NameComponent
            name = [nc(id = "Foo", kind = "")]
            Foo = ns.resolve(name)

        except:
            print "Unable to locate 'Foo' in the Name Service"

    except:
        print "Unable to narrow the Name Service"

except:
    print "(not found)"
    print "Unable to register in the Name Service"


Foo.Run();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]