#include <Servant_Base.h>
Inheritance diagram for TAO_ServantBase:
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, long > | ref_count_ |
Reference counter. | |
TAO_Operation_Table * | optable_ |
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_BEGIN_VERSIONED_NAMESPACE_DECL TAO_ServantBase::TAO_ServantBase | ( | void | ) | [protected] |
Default constructor, only derived classes can be created.
Definition at line 50 of file Servant_Base.cpp.
00051 : TAO_Abstract_ServantBase () 00052 , ref_count_ (1) 00053 , optable_ (0) 00054 { 00055 }
TAO_ServantBase::TAO_ServantBase | ( | const TAO_ServantBase & | ) | [protected] |
Copy constructor, protected so no instances can be created.
Definition at line 57 of file Servant_Base.cpp.
00058 : TAO_Abstract_ServantBase () 00059 , ref_count_ (1) 00060 , optable_ (rhs.optable_) 00061 { 00062 }
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.
References ref_count_.
Referenced by TAO::Portable_Server::ServantRetentionStrategyRetain::activate_object(), TAO::Portable_Server::ServantRetentionStrategyRetain::activate_object_with_id(), TAO_Root_POA::get_servant(), TAO_Root_POA::id_to_servant_i(), TAO_Root_POA::reference_to_servant_i(), and TAO::Portable_Server::RequestProcessingStrategyDefaultServant::set_servant().
00313 { 00314 ++this->ref_count_; 00315 }
TAO_Stub * TAO_ServantBase::_create_stub | ( | void | ) | [virtual] |
This is an auxiliary method for _this() and _narrow().
Implements TAO_Abstract_ServantBase.
Reimplemented in TAO_Local_ServantBase.
Definition at line 146 of file Servant_Base.cpp.
References _default_POA(), TAO_Stub::_incr_refcnt(), _interface_repository_id(), TAO_TSS_Resources::instance(), TAO::Portable_Server::POA_Current_Impl::object_key(), TAO_ORB_Core::orb(), TAO_Stub::orb_core(), TAO::Portable_Server::POA_Current_Impl::orb_core(), TAO::Portable_Server::POA_Current_Impl::poa(), TAO_TSS_Resources::poa_current_impl_, TAO::Portable_Server::POA_Current_Impl::priority(), TAO::Portable_Server::POA_Current_Impl::servant(), and TAO_Stub::servant_orb().
Referenced by POA_CORBA::Policy::_this().
00147 { 00148 TAO_Stub *stub = 0; 00149 00150 TAO::Portable_Server::POA_Current_Impl *poa_current_impl = 00151 static_cast<TAO::Portable_Server::POA_Current_Impl *> 00152 (TAO_TSS_Resources::instance ()->poa_current_impl_); 00153 00154 CORBA::ORB_ptr servant_orb = 0; 00155 00156 if (poa_current_impl != 0 00157 && this == poa_current_impl->servant ()) 00158 { 00159 servant_orb = poa_current_impl->orb_core ().orb () ; 00160 00161 stub = 00162 poa_current_impl->poa ()->key_to_stub ( 00163 poa_current_impl->object_key (), 00164 this->_interface_repository_id (), 00165 poa_current_impl->priority ()); 00166 } 00167 else 00168 { 00169 PortableServer::POA_var poa = this->_default_POA (); 00170 00171 CORBA::Object_var object = poa->servant_to_reference (this); 00172 00173 // Get the stub object 00174 stub = object->_stubobj (); 00175 00176 // Increment the reference count since <object> will zap its 00177 // stub object on deletion. 00178 stub->_incr_refcnt (); 00179 00180 servant_orb = stub->orb_core ()->orb (); 00181 } 00182 00183 stub->servant_orb (servant_orb); 00184 return stub; 00185 }
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.
References TAO_Pseudo_Var_T< T >::in(), TAO_ORB_Core::root_poa(), and TAO_ORB_Core_instance().
Referenced by _create_stub(), and POA_CORBA::Policy_tie< T >::_default_POA().
00077 { 00078 CORBA::Object_var object = TAO_ORB_Core_instance ()->root_poa (); 00079 00080 return PortableServer::POA::_narrow (object.in ()); 00081 }
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_Local_ServantBase, and POA_CORBA::Policy.
Referenced by TAO_Object_Adapter::do_dispatch().
int TAO_ServantBase::_find | ( | const char * | opname, | |
TAO_Collocated_Skeleton & | skelfunc, | |||
TAO::Collocation_Strategy | st, | |||
const size_t | length = 0 | |||
) | [virtual] |
Implements TAO_Abstract_ServantBase.
Definition at line 136 of file Servant_Base.cpp.
References ACE_FUNCTION_TIMEPROBE, TAO_Operation_Table::find(), and optable_.
00140 { 00141 ACE_FUNCTION_TIMEPROBE (TAO_SERVANT_BASE_FIND_START); 00142 return this->optable_->find (opname, skelfunc, st, length); 00143 }
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.
References ACE_FUNCTION_TIMEPROBE, TAO_Operation_Table::find(), and optable_.
00130 { 00131 ACE_FUNCTION_TIMEPROBE (TAO_SERVANT_BASE_FIND_START); 00132 return this->optable_->find (opname, skelfunc, length); 00133 }
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.
References CORBA::Object::_nil().
Referenced by TAO::Collocated_Object_Proxy_Broker::_get_component().
00116 { 00117 return CORBA::Object::_nil (); 00118 }
CORBA::InterfaceDef_ptr TAO_ServantBase::_get_interface | ( | void | ) | [virtual] |
Query the Interface Repository for the interface definition.
Implements TAO_Abstract_ServantBase.
Definition at line 97 of file Servant_Base.cpp.
References TAO_IFR_Client_Adapter::get_interface(), TAO_ORB_Core::ifr_client_adapter_name(), ACE_Dynamic_Service< TYPE >::instance(), and TAO_ORB_Core_instance().
Referenced by TAO::Collocated_Object_Proxy_Broker::_get_interface(), and POA_CORBA::Policy::_interface_skel().
00098 { 00099 TAO_IFR_Client_Adapter *adapter = 00100 ACE_Dynamic_Service<TAO_IFR_Client_Adapter>::instance ( 00101 TAO_ORB_Core::ifr_client_adapter_name ()); 00102 00103 if (adapter == 0) 00104 { 00105 throw ::CORBA::INTF_REPOS (); 00106 } 00107 00108 // This doesn't take multiple ORBs into account, but it's being 00109 // used only to resolve the IFR, so we should be ok. 00110 return adapter->get_interface (TAO_ORB_Core_instance ()->orb (), 00111 this->_interface_repository_id ()); 00112 }
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 POA_CORBA::Policy.
Referenced by _create_stub(), TAO::Portable_Server::ServantRetentionStrategyRetain::id_to_reference(), and TAO::Portable_Server::ServantRetentionStrategyRetain::servant_to_reference().
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 POA_CORBA::Policy.
Definition at line 84 of file Servant_Base.cpp.
References ACE_OS::strcmp().
Referenced by TAO::Collocated_Object_Proxy_Broker::_is_a().
00085 { 00086 static char const id[] = "IDL:omg.org/CORBA/Object:1.0"; 00087 return ACE_OS::strcmp (logical_type_id, id) == 0; 00088 }
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.
Referenced by TAO::Collocated_Object_Proxy_Broker::_non_existent().
CORBA::ULong TAO_ServantBase::_refcount_value | ( | void | ) | const [virtual] |
Returns the current reference count value.
Implements TAO_Abstract_ServantBase.
Definition at line 327 of file Servant_Base.cpp.
References ref_count_, and ACE_Atomic_Op< ACE_LOCK, TYPE >::value().
00328 { 00329 return static_cast<CORBA::ULong> (this->ref_count_.value ()); 00330 }
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.
References ref_count_.
Referenced by TAO::Portable_Server::RequestProcessingStrategyServantLocator::cleanup_servant(), TAO::Portable_Server::RequestProcessingStrategyServantActivator::cleanup_servant(), TAO::Portable_Server::RequestProcessingStrategyDefaultServant::cleanup_servant(), and TAO::Portable_Server::RequestProcessingStrategyAOMOnly::cleanup_servant().
00319 { 00320 long const new_count = --this->ref_count_; 00321 00322 if (new_count == 0) 00323 delete this; 00324 }
char * TAO_ServantBase::_repository_id | ( | void | ) | [virtual] |
Get the repository id.
Implements TAO_Abstract_ServantBase.
Definition at line 121 of file Servant_Base.cpp.
References CORBA::string_dup().
Referenced by TAO::Collocated_Object_Proxy_Broker::_repository_id().
00122 { 00123 return CORBA::string_dup (this->_interface_repository_id ()); 00124 }
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.
References TAO_ServerRequest::operation(), TAO_ServerRequest::operation_length(), TAO_ServerRequest::send_no_exception_reply(), TAO_ServerRequest::sync_with_server(), and TAO_ServerRequest::tao_send_reply_exception().
00263 { 00264 TAO_Skeleton skel; 00265 const char *opname = req.operation (); 00266 00267 // It seems that I might have missed s/g here. What if 00268 // it is a one way that is SYNC_WITH_SERVER. 00269 // Add the following line to handle this reply send as well. 00270 00271 // Handle the one ways that are SYNC_WITH_SERVER 00272 if (req.sync_with_server ()) 00273 { 00274 req.send_no_exception_reply (); 00275 } 00276 00277 // Fetch the skeleton for this operation 00278 if (this->_find (opname, 00279 skel, 00280 static_cast <unsigned int> (req.operation_length())) == -1) 00281 { 00282 throw ::CORBA::BAD_OPERATION (); 00283 } 00284 00285 try 00286 { 00287 // Invoke the skeleton, it will demarshal the arguments, invoke 00288 // the right operation on the skeleton class, and marshal any 00289 // results. De/marshaling will only occur in the uncollocated 00290 // case. 00291 skel (req, servant_upcall, derived_this); 00292 00293 // It is our job to send the already marshaled reply, but only 00294 // send if it is expected and it has not already been sent 00295 00296 // Return immediately. Do not send a reply; this is an 00297 // asynchronous upcall. (unless, of course there is a system 00298 // exception. 00299 00300 } 00301 catch (const ::CORBA::Exception& ex) 00302 { 00303 // If an exception was raised we should marshal it and send 00304 // the appropriate reply to the client 00305 req.tao_send_reply_exception (ex); 00306 } 00307 00308 return; 00309 }
TAO_ServantBase & TAO_ServantBase::operator= | ( | const TAO_ServantBase & | ) | [protected] |
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.
References TAO_ServerRequest::collocated(), TAO_ServerRequest::deferred_reply(), TAO_ServerRequest::operation(), TAO_ServerRequest::operation_length(), TAO_ServerRequest::response_expected(), TAO_ServerRequest::send_no_exception_reply(), TAO_ServerRequest::sync_with_server(), TAO_ServerRequest::tao_send_reply(), and TAO_ServerRequest::tao_send_reply_exception().
Referenced by POA_CORBA::Policy::_dispatch().
00190 { 00191 TAO_Skeleton skel; 00192 char const * const opname = req.operation (); 00193 00194 // It seems that I might have missed s/g here. What if 00195 // it is a one way that is SYNC_WITH_SERVER. 00196 // Add the following line to handle this reply send as well. 00197 00198 // Handle the one ways that are SYNC_WITH_SERVER and not collocated 00199 if (req.sync_with_server () && !req.collocated ()) 00200 { 00201 req.send_no_exception_reply (); 00202 } 00203 00204 // Fetch the skeleton for this operation 00205 if (this->_find (opname, 00206 skel, 00207 static_cast <unsigned int> (req.operation_length())) == -1) 00208 { 00209 throw ::CORBA::BAD_OPERATION (); 00210 } 00211 00212 CORBA::Boolean const send_reply = 00213 !req.sync_with_server () 00214 && req.response_expected () 00215 && !req.deferred_reply (); 00216 00217 try 00218 { 00219 // Invoke the skeleton, it will demarshal the arguments, invoke 00220 // the right operation on the skeleton class, and marshal any 00221 // results. De/marshaling will only occur in the uncollocated 00222 // case. 00223 skel (req, servant_upcall, derived_this); 00224 00225 /* 00226 * Dispatch resolution specialization add hook. 00227 * Over-ridden with code to handle optimized dispatch. 00228 */ 00229 //@@ TAO_DISPATCH_RESOLUTION_OPT_ADD_HOOK 00230 00231 // It is our job to send the already marshaled reply, but only 00232 // send if it is expected and it has not already been sent 00233 00234 // We send the reply only if it is NOT a SYNC_WITH_SERVER, a 00235 // response is expected and if the reply is not deferred. 00236 if (send_reply) 00237 { 00238 req.tao_send_reply (); 00239 } 00240 } 00241 catch (const ::CORBA::Exception& ex) 00242 { 00243 // If an exception was raised we should marshal it and send 00244 // the appropriate reply to the client 00245 if (send_reply) 00246 { 00247 if (req.collocated ()) 00248 { 00249 // Report the exception to the collocated client. 00250 throw; 00251 } 00252 else 00253 req.tao_send_reply_exception (ex); 00254 } 00255 } 00256 00257 return; 00258 }
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.
Referenced by _find(), operator=(), and POA_CORBA::Policy::Policy().
ACE_Atomic_Op<TAO_SYNCH_MUTEX, long> TAO_ServantBase::ref_count_ [protected] |
Reference counter.
Definition at line 154 of file Servant_Base.h.
Referenced by _add_ref(), _refcount_value(), and _remove_ref().