Discussion:
[omniORB] Custom Servant Manager in Python
Stephan February
2006-10-09 22:36:34 UTC
Permalink
Hello
8>8>8>8>8>8>8>8>8>8
FORTUNE_PATH="/usr/bin/fortune"

class CookieServer_i (Fortune__POA.CookieServer):
def get_cookie(self):
pipe = os.popen(FORTUNE_PATH)
cookie = pipe.read()
if pipe.close():
cookie = "Oh dear, could'nt get a fortune\n"
return cookie


class ResynServantManager(PortableServer__POA.ServantLocator):

cookieServer = CookieServer_i()

def preinvoke(self, oid, poa, operation, cookie):
print "preinvoke : "
return cookieServer

def postinvoke(self, oid, adapter, operation, the_cookie, the_servant):
print "postinvoke :"

orb = CORBA.ORB_init(sys.argv)
poa = orb.resolve_initial_references("RootPOA")

poaManager = poa._get_the_POAManager()

## NOTE: Deleted Naming Service Registration Code for brevity

# Setup RESYN POA
policies =[ poa.create_servant_retention_policy(PortableServer.NON_RETAIN),
poa.create_request_processing_policy(PortableServer.USE_SERVANT_MANAGER
),
poa.create_id_assignment_policy(PortableServer.USER_ID),
poa.create_implicit_activation_policy(
PortableServer.NO_IMPLICIT_ACTIVATION),
poa.create_thread_policy(PortableServer.ORB_CTRL_MODEL)]


resyn_servman = ResynServantManager()
resyn_poa = poa.create_POA("RESYN", poaManager, policies)

resyn_poa.set_servant_manager(resyn_servman._this())

#Activate the POA
poaManager.activate()

#Block until ORB is shutdown
orb.run()
8>8>8>8>8>8>8>8>8>8
My problem is that the code never progresses past
resyn_poa.set_servant_manager()
i.e. it blocks at "set_servant_manager()" never activating the POA, and
therefore my requests don't get served.

If I call "poaManager.activate()" before the "set_servant_manager()" then
things seem to work OK, except that ResynServantManager() is not used to
"locate" my CookieServer objects.

I would like to know if anyone can help explain to me why my "RESYN" POA and
ResynServantManager() is never used for locating my CookieServer objects.
What am I missing/doing wrong.

Regards and thanks
Stephan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20061010/70303318/attachment.htm
Duncan Grisby
2006-10-12 23:49:16 UTC
Permalink
[...]
Post by Stephan February
resyn_servman = ResynServantManager()
resyn_poa = poa.create_POA("RESYN", poaManager, policies)
resyn_poa.set_servant_manager(resyn_servman._this())
What's happening is that the set_servant_manager call is doing a _narrow
on the ServantManager object behind the scenes, to make sure it is the
right subclass (ServantLocator in your case). The _narrow involves a
CORBA call to the _is_a operation, which goes through the POA. You
haven't activated the Root POA (where the ServantLocator is activated),
so it blocks waiting for you to activate it.

All you need to do is activate the Root POA's POAManager before calling
set_servant_manager, and it will work fine.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Continue reading on narkive:
Loading...