[omniORB] Help passing objects

Dietmar May dcmay@object-workshops.com
Sun, 27 Jun 1999 14:15:43 -0400


Jonathon,

> What am I doing wrong here? this approach was given in the book
> "Corba for dummies", which uses Orbix. Since I am really new to this,
> could one of you out there point me in the right direction?=20

Just 'cause it works with Orbix doesn't mean that it will with other =
ORBs. There are a number of server side details that are left up to the =
ORB vendor. Which of course means that sever code is not fully portable =
across ORBs.

> Something_ptr
> Broker_impl::CreateSomething(const char * name)
> {
>   Something_impl *person =3D new Something_impl(name);
>=20
>   return Something::_duplicate(person);
> }

omniORB requires a call to p_Boa->obj_is_ready(person), where "p_Boa" is =
a pointer to the BOA (basic object adapter) object returned by the ORB =
during server initialization. This can usually be done in the top-level =
(most derived) constructor of the object, or in the object factory =
creating method.

Server initialization is typically done in main():

    p_Orb =3D CORBA::ORB_init(argc, argv, "omniORB2");
    p_Boa =3D p_Orb->BOA_init(argc, argv, "omniORB2_BOA");

Also, to handle client requests, your server must call:

    p_Boa->impl_is_ready((CORBA::ImplementationDef_ptr)0);

Lastly, you'll need to establish a strategy for object lifetime. Client =
reference counts have nothing to do with server reference counts. You'll =
need to define a way to keep your objects alive for as long as you need =
them. We add them to an STL container of Object_var pointers and remove =
them when appropriate. For some reason that I haven't looked into, we =
need to perform an extra (seemingly unnecessary) call to _duplicate, or =
the object gets released while it's being returned from the creating =
function.

Hope this is helpful.

Regards,
Dietmar