CORBA 2.3.7 Programmer's Reference
Servant Reference Counting
The OMG specification for CORBA 2.3 defines two options for servant reference counting:
Reference counting using the RefCountServantBase mix-in class●
No reference counting●
The NonStop CORBA 2.3 product supports both these options and adds a third: reference counting
within the CORBA::Object associated with the servant. This option provides backward compatibility
with earlier versions of the NonStop CORBA product (then called NonStop DOM). The ORB can detect
whether or not the servant is derived from RefCountServantBase. If so, then the application is
using OMG standard reference counting. If not, then the application is using CORBA::Object
reference counting (the default). Therefore, a properly working NonStop DOM 2.0 servant will work as
expected under CORBA 2.3 because, by default, CORBA 2.3 is backward compatible with NonStop
DOM 2.0. If your application is using no reference counting at all for a servant, the servant must override
the method Servant::_uses_which_ref_type() with an implementation that returns a value of
zero.
NSDOM_ServantBase::NSDOM_Ref_Type
NSDOM_ServantBase::_uses_which_ref_type()
{
return Uses_NSDOM_ref_count;
// must be overridden by OMG compliant programs which do not use
// reference counting.
}
void
NSDOM_ServantBase::_add_nsd_ref()
{
if (_uses_which_ref_type() == Uses_NSDOM_ref_count)
{
CORBA::Object::_duplicate( this->_this_reference() );
} else
this->_add_ref();
}
void
NSDOM_ServantBase::_remove_nsd_ref()
{
if (_uses_which_ref_type() == Uses_NSDOM_ref_count)
{
CORBA::release( this->_this_reference() );
} else
this->_remove_ref();
}