[omniORB] Destroying object implementions in a factory etc
Andy Weber
Andy@arcontech.com
Wed, 5 Jul 2000 13:13:31 +0100
Hi,
I have the following IDL:
interface RecordData
{
...
};
interface InstrumentDataFactory
{
RecordData createRecordData(); // get a RecordData object
void destroyRecordData( in RecordData recData); // destroy it
};
The server implements both InstrumentDataFactory and RecordData. The
code for createRecordData() is
RecordData * InstrumentDataFactory_i::createRecordData()
{
RecordData_i *myimpl = new RecordData_i();
tRecordData *myobj = new tRecordData(myimpl);
myobj->_obj_is_ready(CORBA::BOA::getBOA());
RecordData_var myobjRef = myobj->_this();
return myobjRef._retn();
}
where tRecordData is a typedef for _tie_RecordData<RecordData_i,1>.
After much head-scratching and experiment, I have managed to write
destroyRecordData, as follows:
void InstrumentDataFactory_i::destroyRecordData(RecordData_ptr recData)
{
RecordData_Helper::duplicate( recData);
CORBA::BOA::getBOA()->dispose( recData);
}
This works, calling the implementation's destructor, etc, and there are
no memory leaks. But is this the right/only way to do it?
Secondly, if the client dies/disappears (without calling
destroyRecordData), can the ORB notify the server implementation that
this has happened so that the implementation can clean itself up? (When
I try this in my test app, I am currently left with a 'dangling'
object.)
I can see from the omniORB documentation that this issue has been
addressed from the client's point of view, but I can't find anything of
relevance to servers.
Andy Weber
--
Andy Weber
Arcontech Ltd Phone +44 (0) 20 7405 2111
31-35 Kirby Street Fax +44 (0) 20 7831 6667
London EC1N 8TE E-mail andy@arcontech.com