AW: [omniORB] Beginner's question about corbaloc

Duncan Grisby duncan at grisby.org
Fri Nov 12 18:59:40 GMT 2004


On Friday 12 November, fischer.c at atlas.de wrote:

> After activating the servant by activate_object_with_id() you are calling
> _this() to create an object reference.
> This call is obsolete and may also lead to some strange side effects.

_this() is not obsolete. It can have some strange effects if you
don't understand it, though...

> You should simply remove it, because the object references that it
> returns is not used at all and is not the one you expect.

It's true that in this case the return value is not used, so it can be
removed.

> To go into more detail, _this() activates your servant in the POA
> returned by the virtual ServantBase method _default_POA(). As long
> as you don't override this method, it will return the root POA. As a
> consequence calling _this() in the way you do ends up with your
> servant activated twice, once in omniINSPOA and once in the root
> POA.

That's not true. If the servant has just one activation, which in this
case it does, _this() returns the existing object reference (in the
omniINSPOA), rather than doing a new activation.

To be paranoid, it's often a good idea to define _default_POA() to
return the correct POA, but it is not always necessary to do so.

> Moreover the object reference returned by _this() is not identical
> to the one used by your client, because it actually created a
> different object.

Not true.

> If you need the object reference of the correct object somewhere in
> your server's code, i.e. for registration in a naming service, you
> should create it by the following call:
>
> CORBA::Object_var obj = poa->id_to_reference(oid);

The problem with that is that you then have to narrow it to the right
type, whereas _this() already returns the correct most derived type.

Cheers,

Duncan.

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



More information about the omniORB-list mailing list