[omniORB] how to use _dispose() in factory?

Dietmar May dcmay@object-workshops.com
Mon, 7 Sep 1998 20:09:10 -0700


Hi Zsolt,

> However, I get a compiler error for me->_dispose(), saying that there
> is no such member. I see that the _dispose() is defined in the
> skeleton class _sk_BaseObjectFactory which inherits from 
> BaseObjectFactory. So it looks like, that I should call _dispose()
> on my BaseObjectImp object and not on the ancestor BaseObject.
> But the signatures as generated require me to use BaseObject_ptr
> types. Can I just cast it in the destroyObject() method?
> Or should I return a casted the_new_obj pointer from createObject() 
> and then cast it back in the destroyObject()? 
> Or is there another (clean) way to do this?

You might try saving the BOA during initialization, and then call
dispose() using the BOA.

static CORBA::BOA_ptr p_BOA = CORBA::BOA::_nil();

extern  CORBA::BOA_ptr  get_boa () { return p_BOA; }

void main()
{
   ...
   p_BOA = p_Orb->BOA_init(argc, argv, (char*)Z(BOA_NAME));
   ...
   p_BOA->impl_is_ready(...);
}

Then, 

void BaseObjectFactoryImp::destroyObject( modest::BaseObject_ptr  me )
{
    get_boa()->dispose(me);  //decrements ref count from
object_is_ready()
}

This is effectively what we do with our Object Factory implementation.
(It should also make your server a little more portable, since the
_dispose() method is not standard CORBA, but BOA->dispose() is).

Regards,
Dietmar May
Software Architect
Object Workshops, Inc.