deactivate servants [was: Re: __fini() and __destroy()]



Frank Rehberger wrote:

> Jules Colding wrote:
>
>> Hi,
>>
>> I am in doubt about the *__fini() and *__destroy() functions. Is
>> *__destroy() invoked automatically by the POA manager when *__fini() is
>> called or how is it?
>>  
>>
> Yes, the name  *__destroy is for historical reasons, should be renamed
> to *__fini to make things more clear ;)
>
>> The reason I am confused is that the *__destroy() function in the ORBit2
>> tutorial v1.1 actually calls *__fini() at the end, so it would seem
>> rather circular..
>

Had a look at the sample code (the actual C code), everything looks fine 
there, ie. sample code of "calculator":

static void
impl_Calculator__destroy(impl_POA_Calculator * servant,
			 CORBA_Environment * ev)
{
   CORBA_Object_release((CORBA_Object) servant->poa, ev);
 
   /* No further remote method calls are delegated to 
    * servant and you may free your private attributes. */
   /* ------ free private attributes here ------ */
   /* ------ ---------- end ------------- ------ */

   POA_Calculator__fini((PortableServer_Servant) servant, ev);
}


With intention to destroy servant some instance of inherited class 
"impl_Calculator", user must invoke special function on POA container:

void
PortableServer_POA_deactivate_object (PortableServer_POA             poa,
                                      const PortableServer_ObjectId *oid,
                                      CORBA_Environment             *ev)

the associated servant will be deactivated and ORBit2's POA container 
will call the __fini operation (destructor) of specific servant, in case 
of example "calculator" it would be the C function 
"impl_Calculator__destroy",  cause of inheritance further destructors of 
super classes must be called, too, in this case destructor 
"POA_Calculator__fini", having a look into generated file 
"calculator-skels.c"  you will notice:

void
POA_Calculator__fini(PortableServer_Servant servant, CORBA_Environment * 
env)
{
   PortableServer_ServantBase__fini(servant, env);
}

And finally the destructor of super class "PortableServer_ServantBase" 
looks like:

PortableServer_ServantBase__fini (PortableServer_Servant  servant,
                                  CORBA_Environment      *ev)
{
        poa_sys_exception_if_fail (servant != NULL, ex_CORBA_BAD_PARAM);
}


No circalur calls ;)  But you are right, there should be some sample 
code demonstrating usage of function 
"PortableServer_POA_deactivate_object" ;)

Best regards, Frank





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]