Base class for skeletons and servants. More...
#include <Servant_Base.h>
Public Member Functions | |
virtual | ~TAO_ServantBase (void) |
Destructor. | |
virtual PortableServer::POA_ptr | _default_POA (void) |
Returns the default POA for this servant. | |
virtual CORBA::Boolean | _is_a (const char *logical_type_id) |
Local implementation of the CORBA::Object::_is_a method. | |
virtual CORBA::Boolean | _non_existent (void) |
Default _non_existent: always returns false. | |
virtual CORBA::InterfaceDef_ptr | _get_interface (void) |
Query the Interface Repository for the interface definition. | |
virtual CORBA::Object_ptr | _get_component (void) |
Default _get_component: always returns CORBA::Object::_nil(). | |
virtual char * | _repository_id (void) |
Get the repository id. | |
virtual TAO_Stub * | _create_stub (void) |
This is an auxiliary method for _this() and _narrow(). | |
virtual void | _dispatch (TAO_ServerRequest &request, void *servant_upcall)=0 |
virtual int | _find (const char *opname, TAO_Skeleton &skelfunc, const size_t length=0) |
virtual int | _find (const char *opname, TAO_Collocated_Skeleton &skelfunc, TAO::Collocation_Strategy st, const size_t length=0) |
virtual const char * | _interface_repository_id (void) const =0 |
Get this interface's repository id (TAO specific). | |
Reference Counting Operations | |
virtual void | _add_ref (void) |
Increase reference count by one. | |
virtual void | _remove_ref (void) |
virtual CORBA::ULong | _refcount_value (void) const |
Protected Member Functions | |
TAO_ServantBase (void) | |
Default constructor, only derived classes can be created. | |
TAO_ServantBase (const TAO_ServantBase &) | |
Copy constructor, protected so no instances can be created. | |
TAO_ServantBase & | operator= (const TAO_ServantBase &) |
Assignment operator. | |
virtual void | synchronous_upcall_dispatch (TAO_ServerRequest &req, void *servant_upcall, void *derived_this) |
virtual void | asynchronous_upcall_dispatch (TAO_ServerRequest &req, void *servant_upcall, void *derived_this) |
Protected Attributes | |
ACE_Atomic_Op< TAO_SYNCH_MUTEX, unsigned long > | ref_count_ |
Reference counter. | |
TAO_Operation_Table * | optable_ |
Base class for skeletons and servants.
The POA spec requires that all servants inherit from this class' base class.
An instance of a servant class derived from ServantBase initially has a reference count of one. Invoking _add_ref on the servant instance increases its reference count by one. Invoking _remove_ref on the servant instance decreases its reference count by one; if the resulting reference count equals zero, _remove_ref invokes delete on its this pointer in order to destroy the servant. For ORBs that operate in multi-threaded environments, the implementations of _add_ref and _remove_ref that the ServantBase class provides shall be thread-safe.
Like ServantBase supports copy construction and the default assignment operation. Copy construction always sets the reference count of the new servant instance to one. The default assignment implementation merely returns *this and does not affect the reference count.
Definition at line 61 of file Servant_Base.h.
TAO_ServantBase::~TAO_ServantBase | ( | void | ) | [virtual] |
TAO_ServantBase::TAO_ServantBase | ( | void | ) | [protected] |
Default constructor, only derived classes can be created.
Definition at line 50 of file Servant_Base.cpp.
: TAO_Abstract_ServantBase () , ref_count_ (1) , optable_ (0) { }
TAO_ServantBase::TAO_ServantBase | ( | const TAO_ServantBase & | rhs | ) | [protected] |
Copy constructor, protected so no instances can be created.
Definition at line 57 of file Servant_Base.cpp.
: TAO_Abstract_ServantBase () , ref_count_ (1) , optable_ (rhs.optable_) { }
void TAO_ServantBase::_add_ref | ( | void | ) | [virtual] |
Increase reference count by one.
Implements TAO_Abstract_ServantBase.
Definition at line 312 of file Servant_Base.cpp.
{ ++this->ref_count_; }
TAO_Stub * TAO_ServantBase::_create_stub | ( | void | ) | [virtual] |
This is an auxiliary method for _this() and _narrow().
Implements TAO_Abstract_ServantBase.
Reimplemented in TAO_DynamicImplementation, and TAO_Local_ServantBase.
Definition at line 146 of file Servant_Base.cpp.
{ TAO_Stub *stub = 0; TAO::Portable_Server::POA_Current_Impl *poa_current_impl = static_cast<TAO::Portable_Server::POA_Current_Impl *> (TAO_TSS_Resources::instance ()->poa_current_impl_); CORBA::ORB_ptr servant_orb = 0; if (poa_current_impl != 0 && this == poa_current_impl->servant ()) { servant_orb = poa_current_impl->orb_core ().orb () ; stub = poa_current_impl->poa ()->key_to_stub ( poa_current_impl->object_key (), this->_interface_repository_id (), poa_current_impl->priority ()); } else { PortableServer::POA_var poa = this->_default_POA (); CORBA::Object_var object = poa->servant_to_reference (this); // Get the stub object stub = object->_stubobj (); // Increment the reference count since <object> will zap its // stub object on deletion. stub->_incr_refcnt (); servant_orb = stub->orb_core ()->orb (); } stub->servant_orb (servant_orb); return stub; }
PortableServer::POA_ptr TAO_ServantBase::_default_POA | ( | void | ) | [virtual] |
Returns the default POA for this servant.
Reimplemented in POA_CORBA::Policy_tie< T >.
Definition at line 76 of file Servant_Base.cpp.
{ CORBA::Object_var object = TAO_ORB_Core_instance ()->root_poa (); return PortableServer::POA::_narrow (object.in ()); }
virtual void TAO_ServantBase::_dispatch | ( | TAO_ServerRequest & | request, | |
void * | servant_upcall | |||
) | [pure virtual] |
Dispatches a request to the object: find the operation, cast the type to the most derived type, demarshall all the parameters from the request and finally invokes the operation, storing the results and out parameters (if any) or the exceptions thrown into request.
Implements TAO_Abstract_ServantBase.
Implemented in TAO_DynamicImplementation, TAO_Local_ServantBase, and POA_CORBA::Policy.
int TAO_ServantBase::_find | ( | const char * | opname, | |
TAO_Skeleton & | skelfunc, | |||
const size_t | length = 0 | |||
) | [virtual] |
Please see documentation in tao/Abstract_Servant_Base.h for details.
Implements TAO_Abstract_ServantBase.
Definition at line 127 of file Servant_Base.cpp.
{ ACE_FUNCTION_TIMEPROBE (TAO_SERVANT_BASE_FIND_START); return this->optable_->find (opname, skelfunc, length); }
int TAO_ServantBase::_find | ( | const char * | opname, | |
TAO_Collocated_Skeleton & | skelfunc, | |||
TAO::Collocation_Strategy | s, | |||
const size_t | length = 0 | |||
) | [virtual] |
Find an operation in the operation table and return a TAO_Collocated_Skeleton which can be used to make upcalls onto collocated servants.
Implements TAO_Abstract_ServantBase.
Definition at line 136 of file Servant_Base.cpp.
{ ACE_FUNCTION_TIMEPROBE (TAO_SERVANT_BASE_FIND_START); return this->optable_->find (opname, skelfunc, st, length); }
CORBA::Object_ptr TAO_ServantBase::_get_component | ( | void | ) | [virtual] |
Default _get_component: always returns CORBA::Object::_nil().
Implements TAO_Abstract_ServantBase.
Definition at line 115 of file Servant_Base.cpp.
{ return CORBA::Object::_nil (); }
CORBA::InterfaceDef_ptr TAO_ServantBase::_get_interface | ( | void | ) | [virtual] |
Query the Interface Repository for the interface definition.
Implements TAO_Abstract_ServantBase.
Reimplemented in TAO_DynamicImplementation.
Definition at line 97 of file Servant_Base.cpp.
{ TAO_IFR_Client_Adapter *adapter = ACE_Dynamic_Service<TAO_IFR_Client_Adapter>::instance ( TAO_ORB_Core::ifr_client_adapter_name ()); if (adapter == 0) { throw ::CORBA::INTF_REPOS (); } // This doesn't take multiple ORBs into account, but it's being // used only to resolve the IFR, so we should be ok. return adapter->get_interface (TAO_ORB_Core_instance ()->orb (), this->_interface_repository_id ()); }
virtual const char* TAO_ServantBase::_interface_repository_id | ( | void | ) | const [pure virtual] |
Get this interface's repository id (TAO specific).
Implements TAO_Abstract_ServantBase.
Implemented in TAO_DynamicImplementation, and POA_CORBA::Policy.
CORBA::Boolean TAO_ServantBase::_is_a | ( | const char * | logical_type_id | ) | [virtual] |
Local implementation of the CORBA::Object::_is_a method.
Implements TAO_Abstract_ServantBase.
Reimplemented in TAO_DynamicImplementation, and POA_CORBA::Policy.
Definition at line 84 of file Servant_Base.cpp.
{ static char const id[] = "IDL:omg.org/CORBA/Object:1.0"; return ACE_OS::strcmp (logical_type_id, id) == 0; }
CORBA::Boolean TAO_ServantBase::_non_existent | ( | void | ) | [virtual] |
Default _non_existent: always returns false.
Implements TAO_Abstract_ServantBase.
Definition at line 91 of file Servant_Base.cpp.
{ return false; }
CORBA::ULong TAO_ServantBase::_refcount_value | ( | void | ) | const [virtual] |
Returns the current reference count value.
Implements TAO_Abstract_ServantBase.
Definition at line 329 of file Servant_Base.cpp.
{ return this->ref_count_.value (); }
void TAO_ServantBase::_remove_ref | ( | void | ) | [virtual] |
Decreases reference count by one; if the resulting reference count equals zero, _remove_ref invokes delete on its this pointer in order to destroy the servant.
Implements TAO_Abstract_ServantBase.
Definition at line 318 of file Servant_Base.cpp.
{ unsigned long const new_count = --this->ref_count_; if (new_count == 0) { delete this; } }
char * TAO_ServantBase::_repository_id | ( | void | ) | [virtual] |
Get the repository id.
Implements TAO_Abstract_ServantBase.
Definition at line 121 of file Servant_Base.cpp.
{ return CORBA::string_dup (this->_interface_repository_id ()); }
void TAO_ServantBase::asynchronous_upcall_dispatch | ( | TAO_ServerRequest & | req, | |
void * | servant_upcall, | |||
void * | derived_this | |||
) | [protected, virtual] |
Definition at line 260 of file Servant_Base.cpp.
{ TAO_Skeleton skel; const char *opname = req.operation (); // It seems that I might have missed s/g here. What if // it is a one way that is SYNC_WITH_SERVER. // Add the following line to handle this reply send as well. // Handle the one ways that are SYNC_WITH_SERVER if (req.sync_with_server ()) { req.send_no_exception_reply (); } // Fetch the skeleton for this operation if (this->_find (opname, skel, static_cast <unsigned int> (req.operation_length())) == -1) { throw ::CORBA::BAD_OPERATION (); } try { // Invoke the skeleton, it will demarshal the arguments, invoke // the right operation on the skeleton class, and marshal any // results. De/marshaling will only occur in the uncollocated // case. skel (req, servant_upcall, derived_this); // It is our job to send the already marshaled reply, but only // send if it is expected and it has not already been sent // Return immediately. Do not send a reply; this is an // asynchronous upcall. (unless, of course there is a system // exception. } catch (const ::CORBA::Exception& ex) { // If an exception was raised we should marshal it and send // the appropriate reply to the client req.tao_send_reply_exception (ex); } return; }
TAO_ServantBase & TAO_ServantBase::operator= | ( | const TAO_ServantBase & | rhs | ) | [protected] |
Assignment operator.
Definition at line 65 of file Servant_Base.cpp.
void TAO_ServantBase::synchronous_upcall_dispatch | ( | TAO_ServerRequest & | req, | |
void * | servant_upcall, | |||
void * | derived_this | |||
) | [protected, virtual] |
Implements TAO_Abstract_ServantBase.
Definition at line 187 of file Servant_Base.cpp.
{ TAO_Skeleton skel; char const * const opname = req.operation (); // It seems that I might have missed s/g here. What if // it is a one way that is SYNC_WITH_SERVER. // Add the following line to handle this reply send as well. // Handle the one ways that are SYNC_WITH_SERVER and not collocated if (req.sync_with_server () && !req.collocated ()) { req.send_no_exception_reply (); } // Fetch the skeleton for this operation if (this->_find (opname, skel, static_cast <unsigned int> (req.operation_length())) == -1) { throw ::CORBA::BAD_OPERATION (); } CORBA::Boolean const send_reply = !req.sync_with_server () && req.response_expected () && !req.deferred_reply (); try { // Invoke the skeleton, it will demarshal the arguments, invoke // the right operation on the skeleton class, and marshal any // results. De/marshaling will only occur in the uncollocated // case. skel (req, servant_upcall, derived_this); /* * Dispatch resolution specialization add hook. * Over-ridden with code to handle optimized dispatch. */ //@@ TAO_DISPATCH_RESOLUTION_OPT_ADD_HOOK // It is our job to send the already marshaled reply, but only // send if it is expected and it has not already been sent // We send the reply only if it is NOT a SYNC_WITH_SERVER, a // response is expected and if the reply is not deferred. if (send_reply) { req.tao_send_reply (); } } catch (const ::CORBA::Exception& ex) { // If an exception was raised we should marshal it and send // the appropriate reply to the client if (send_reply) { if (req.collocated ()) { // Report the exception to the collocated client. throw; } else req.tao_send_reply_exception (ex); } } return; }
TAO_Operation_Table* TAO_ServantBase::optable_ [protected] |
The operation table for this servant. It is initialized by the most derived class.
Definition at line 158 of file Servant_Base.h.
ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> TAO_ServantBase::ref_count_ [protected] |
Reference counter.
Definition at line 154 of file Servant_Base.h.