[omniORB] Help passing objects

Dietmar May dcmay@object-workshops.com
Mon, 28 Jun 1999 14:30:55 -0400


Duncan,

> Another point is that you should really return person->_this(), rather
> than duplicating the implementation object. It is only an omniORB
> implementation artifact that _duplicate() works in this situation. It
> will no longer work when the POA comes along.

I'll admit, I'm confused. It would be greatly appreciated if you could =
clear a few things up.

Given an object factory scenario:=20


  interface MyInterface;
  interface MyFactory
  {
    MyInterface make_it ();
  };

  MyInterface_ptr _sk_MyFactory::make_it ()
  {
    MyInterface_ptr p_my =3D new MyInterfaceImpl;
    p_boa->obj_is_ready(p_my);
  #if 0 //what's the difference?
    return MyInterface::_duplicate(p_my);
  #else
    return p_my->_this();   //not in a member function
  #endif
  }


_this() returns a duplicated object reference for the target object (or =
more precisely, it returns an object reference upon which =
CORBA::release() must be called). _duplicate() accepts an object =
reference of the target object and returns an object reference upon =
which CORBA::release() must be called. So what is the difference between =
using _this() and _duplicate()?

It seems there are a total of five lines describing "_this()" in the =
CORBA 2.0 spec! Has CORBA 2.2 changed this? Per CORBA 2.0 sec 18.2, it =
appears that _this() is only guaranteed to be available "from within the =
body of a member function". Also, per 18.4.5, "the method code may not =
assume where these two routines [_boa() and _this()] are defined."=20

Within an object factory, what is the impact of these references upon =
its suggested use for duplicating a returned reference? That is, since =
the object is created in a method belonging to a difference interface, =
why is _this() a better choice than _duplicate()?

I can see how in a tie situation, for example, it would be quite =
inappropriate to return _duplicate(this), because 'this' isn't an =
ORB-derived class. One would have to have some other method available, =
such as _this(). But in an object factory creator method, the code has a =
pointer to the actual, ORB-derived object, since the factory method just =
created it.

Also, what makes a difference with the POA?

Regards,
Dietmar