[omniORB] Help passing objects

Duncan Grisby dgrisby@uk.research.att.com
Mon, 28 Jun 1999 09:08:27 +0100


On Friday 25 June, Jonathan Gallmeier wrote:

[...]

> Something_ptr
> Broker_impl::CreateSomething(const char * name)
> {
>   Something_impl *person = new Something_impl(name);
> 
>   return Something::_duplicate(person);
> }
> 
> It appears that the _duplicate(person) causes an exception.
> The server creates a broker object, the client uses the broker object
> to call CreateSomething and get back a Something object to do more work
> (get the name, etc.)

What exception does _duplicate() throw?  The most likely explanation
is that you are not calling boa->obj_is_ready() on the new
implementation object. You should do this either in the constructor of
Something_impl(), or in the CreateSomething() operation (see David
Riddoch's recent post for an explanation as to why you might not want
to call it from the constructor).

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.

Cheers,

Duncan.

-- 
 -- Duncan Grisby  \  Research Engineer  --
  -- AT&T Laboratories Cambridge          --
   -- http://www.uk.research.att.com/~dpg1 --