[omniORB] Help: Identify object/servant location

Duncan Grisby duncan at grisby.org
Tue Jan 27 16:25:20 GMT 2009


On Tuesday 27 January, Carsten.Agger at tieto.com wrote:

[...]
> This raises a problem: In some cases, a servant may be passed a reference to a
> servant object located on its own service. In this case, the processing needs
> to differ slightly to allow services to be redundant mirrors of the same data.
> What I need is basically: If the object reference is to the same database,
> don’t call remotely via the ORB, process locally, as the servant may be loaded
> here.
> 
> But how do I know it is local or to the same database? I thought of using user
> generated IDs and code the database identifier (server.database) in the object
> ID, but there doesn’t seem to be an easy way to extract the object ID from an
> object pointer, as it seems to be located on the servant’s POA only.

As long as you know which POA the servant is activated in, you can try
calling poa->reference_to_servant(), giving it the object reference. If
that succeeds, you know that the object corresponds to a local servant;
if it fails with a PortableServer::POA::WrongAdapter exception, then you
know it's not an object in that POA (and thus is remote). You might also
get an ObjectNotActive exception, which means the object reference
corresponds to the POA, but that the object id in it is not active.

Cheers,

Duncan.

-- 
 -- Duncan Grisby         --
  -- duncan at grisby.org     --
   -- http://www.grisby.org --



More information about the omniORB-list mailing list