[omniORB] Interface repository
Mair Quentin
Q.Mair@gcal.ac.uk
Fri, 18 May 2001 09:46:48 +0100
Probably not very good code (please no flame) but works...
in orminORB.cfg:
with omniifr running on <host> <port>
ORBInitRef InterfaceRepository=corbaloc::<host>:<port>/DefaultRepository
#!/usr/bin/env python
# Simple IR Parser
import sys, omniORB
# Import the CORBA module
from omniORB import CORBA
if len(sys.argv) != 2:
print "Usage: %s <Scoped Interface Name>" % (sys.argv[0])
sys.exit(1)
else: interface = sys.argv[1]
# For OmniORBpy you have to explicitly load the stubs
# for the IR. This is to keep the default stubs small.
omniORB.importIRStubs()
# Initialise the ORB
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
# Obtain a reference to the interface repository
irep = orb.resolve_initial_references("InterfaceRepository")
rootRep = irep._narrow(CORBA.Repository)
if rootRep is None:
print "Failed to narrow the repository"
sys.exit(1)
print "Interface is '", interface, "'"
print
try:
c = rootRep.lookup(interface)
iv = c._narrow(CORBA.InterfaceDef)
full = iv.describe_interface()
except:
print "Couldn't find Interface?, Interface:", interface
sys.exit(1)
for opobj in full.operations:
print "operation:", opobj.name
print "result:", opobj.result.kind()
print "parameters: "
for parobj in opobj.parameters:
print "%s (%s, %s) " % (parobj.name, parobj.type.kind(), parobj.mode)
print "exceptions raised: "
for excobj in opobj.exceptions:
print excobj.name
print
Quentin Mair
Lecturer
Department of Computing
City Campus
Glasgow Caledonian University
Glasgow
Scotland
G4 0BA
e-mail: qma@gcal.ac.uk
tel: 0044-141-331-3283
fax: 0044-141-331-8445