[omniORB] converting servant * to objref in BOA
Stefan Seefeld
seefelds@MAGELLAN.UMontreal.CA
Thu, 09 Nov 2000 10:58:53 -0500
Andy Faibishenko wrote:
>
> I have some code which does the following.
>
> I have a class A which I pass into a remote CORBA interface. The code on the remote side then calls back on a method in class A.
>
> I've declared A as follows
>
> class A : public _sk_A
> {
> ...
> }
>
> Then when I call the remote interface, I invoke
> A a;
> remoteObjRef->CallMeBack(&a);
uh, oh. That looks extremely dangerous !
First of all, as you already noted, is a pointer to a *not* the same as a reference to a. Please
stay
with the standard, which requires the use of A_ptr or A_var. (look for ORB specific example code
which
shows how to construct them - as you use the BOA it is pretty much ORB specific)
Second, you use a stack based object 'a'. You should read about the distinction of CORBA objects and
servants, and the respective lifecycles. You'll understand that you should (almost) never destruct
the
object yourself (either explicitely or by simply letting the object go out of scope), as the object
adapter (the BOA in your case) may still hold a reference to it.
Regards, Stefan
_______________________________________________________
Stefan Seefeld
Departement de Physique
Universite de Montreal
email: seefelds@magellan.umontreal.ca
_______________________________________________________
...ich hab' noch einen Koffer in Berlin...