#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.
|
Destructor.
Definition at line 71 of file Servant_Base.cpp.
00072 { 00073 } |
|
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 } |
|
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 } |
|
Increase reference count by one.
Implements TAO_Abstract_ServantBase. Definition at line 313 of file Servant_Base.cpp.
00314 { 00315 ++this->ref_count_; 00316 } |
|
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_, PortableServer::POA_var, 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 } 00168 else 00169 { 00170 PortableServer::POA_var poa = this->_default_POA (); 00171 00172 CORBA::Object_var object = poa->servant_to_reference (this); 00173 00174 // Get the stub object 00175 stub = object->_stubobj (); 00176 00177 // Increment the reference count since <object> will zap its 00178 // stub object on deletion. 00179 stub->_incr_refcnt (); 00180 00181 servant_orb = stub->orb_core ()->orb (); 00182 } 00183 00184 stub->servant_orb (servant_orb); 00185 return stub; 00186 } |
|
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_ORB_Core::root_poa(), and TAO_ORB_Core_instance(). Referenced by _create_stub().
00077 { 00078 CORBA::Object_var object = TAO_ORB_Core_instance ()->root_poa (); 00079 00080 return PortableServer::POA::_narrow (object.in ()); 00081 } |
|
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. |
|
Implements TAO_Abstract_ServantBase. Definition at line 136 of file Servant_Base.cpp. References ACE_FUNCTION_TIMEPROBE, TAO_Operation_Table::find(), optable_, and TAO_Collocated_Skeleton.
00140 { 00141 ACE_FUNCTION_TIMEPROBE (TAO_SERVANT_BASE_FIND_START); 00142 return this->optable_->find (opname, skelfunc, st, length); 00143 } |
|
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(), optable_, and TAO_Skeleton. Referenced by asynchronous_upcall_dispatch(), and synchronous_upcall_dispatch().
00130 { 00131 ACE_FUNCTION_TIMEPROBE (TAO_SERVANT_BASE_FIND_START); 00132 return this->optable_->find (opname, skelfunc, length); 00133 } |
|
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().
00116 { 00117 return CORBA::Object::_nil (); 00118 } |
|
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(), ACE_Dynamic_Service< TYPE >::instance(), and TAO_ORB_Core_instance(). Referenced by 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 } |
|
Get this interface's repository id (TAO specific).
Implements TAO_Abstract_ServantBase. Implemented in POA_CORBA::Policy. Referenced by _create_stub(). |
|
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().
00085 { 00086 static char const id[] = "IDL:omg.org/CORBA/Object:1.0"; 00087 return ACE_OS::strcmp (logical_type_id, id) == 0; 00088 } |
|
Default _non_existent: always returns false.
Implements TAO_Abstract_ServantBase. Definition at line 91 of file Servant_Base.cpp.
00092 { 00093 return false; 00094 } |
|
Returns the current reference count value. Implements TAO_Abstract_ServantBase. Definition at line 328 of file Servant_Base.cpp. References ACE_Atomic_Op< TAO_SYNCH_MUTEX, long >::value().
00329 { 00330 return static_cast<CORBA::ULong> (this->ref_count_.value ()); 00331 } |
|
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 319 of file Servant_Base.cpp.
00320 { 00321 long const new_count = --this->ref_count_; 00322 00323 if (new_count == 0) 00324 delete this; 00325 } |
|
Get the repository id.
Implements TAO_Abstract_ServantBase. Definition at line 121 of file Servant_Base.cpp. References CORBA::string_dup().
00122 { 00123 return CORBA::string_dup (this->_interface_repository_id ()); 00124 } |
|
Definition at line 261 of file Servant_Base.cpp. References _find(), TAO_ServerRequest::operation(), TAO_ServerRequest::operation_length(), TAO_ServerRequest::send_no_exception_reply(), TAO_ServerRequest::sync_with_server(), TAO_ServerRequest::tao_send_reply_exception(), and TAO_Skeleton.
00264 { 00265 TAO_Skeleton skel; 00266 const char *opname = req.operation (); 00267 00268 // It seems that I might have missed s/g here. What if 00269 // it is a one way that is SYNC_WITH_SERVER. 00270 // Add the following line to handle this reply send as well. 00271 00272 // Handle the one ways that are SYNC_WITH_SERVER 00273 if (req.sync_with_server ()) 00274 { 00275 req.send_no_exception_reply (); 00276 } 00277 00278 // Fetch the skeleton for this operation 00279 if (this->_find (opname, 00280 skel, 00281 static_cast <unsigned int> (req.operation_length())) == -1) 00282 { 00283 throw ::CORBA::BAD_OPERATION (); 00284 } 00285 00286 try 00287 { 00288 // Invoke the skeleton, it will demarshal the arguments, invoke 00289 // the right operation on the skeleton class, and marshal any 00290 // results. De/marshaling will only occur in the uncollocated 00291 // case. 00292 skel (req, servant_upcall, derived_this); 00293 00294 // It is our job to send the already marshaled reply, but only 00295 // send if it is expected and it has not already been sent 00296 00297 // Return immediately. Do not send a reply; this is an 00298 // asynchronous upcall. (unless, of course there is a system 00299 // exception. 00300 00301 } 00302 catch (const ::CORBA::Exception& ex) 00303 { 00304 // If an exception was raised we should marshal it and send 00305 // the appropriate reply to the client 00306 req.tao_send_reply_exception (ex); 00307 } 00308 00309 return; 00310 } |
|
Assignment operator.
Definition at line 65 of file Servant_Base.cpp. References optable_.
|
|
Implements TAO_Abstract_ServantBase. Definition at line 188 of file Servant_Base.cpp. References _find(), 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(), TAO_ServerRequest::tao_send_reply_exception(), and TAO_Skeleton. Referenced by POA_CORBA::Policy::_dispatch().
00191 { 00192 TAO_Skeleton skel; 00193 char const * const opname = req.operation (); 00194 00195 // It seems that I might have missed s/g here. What if 00196 // it is a one way that is SYNC_WITH_SERVER. 00197 // Add the following line to handle this reply send as well. 00198 00199 // Handle the one ways that are SYNC_WITH_SERVER and not collocated 00200 if (req.sync_with_server () && !req.collocated ()) 00201 { 00202 req.send_no_exception_reply (); 00203 } 00204 00205 // Fetch the skeleton for this operation 00206 if (this->_find (opname, 00207 skel, 00208 static_cast <unsigned int> (req.operation_length())) == -1) 00209 { 00210 throw ::CORBA::BAD_OPERATION (); 00211 } 00212 00213 CORBA::Boolean const send_reply = 00214 !req.sync_with_server () 00215 && req.response_expected () 00216 && !req.deferred_reply (); 00217 00218 try 00219 { 00220 // Invoke the skeleton, it will demarshal the arguments, invoke 00221 // the right operation on the skeleton class, and marshal any 00222 // results. De/marshaling will only occur in the uncollocated 00223 // case. 00224 skel (req, servant_upcall, derived_this); 00225 00226 /* 00227 * Dispatch resolution specialization add hook. 00228 * Over-ridden with code to handle optimized dispatch. 00229 */ 00230 //@@ TAO_DISPATCH_RESOLUTION_OPT_ADD_HOOK 00231 00232 // It is our job to send the already marshaled reply, but only 00233 // send if it is expected and it has not already been sent 00234 00235 // We send the reply only if it is NOT a SYNC_WITH_SERVER, a 00236 // response is expected and if the reply is not deferred. 00237 if (send_reply) 00238 { 00239 req.tao_send_reply (); 00240 } 00241 } 00242 catch (const ::CORBA::Exception& ex) 00243 { 00244 // If an exception was raised we should marshal it and send 00245 // the appropriate reply to the client 00246 if (send_reply) 00247 { 00248 if (req.collocated ()) 00249 { 00250 // Report the exception to the collocated client. 00251 throw; 00252 } 00253 else 00254 req.tao_send_reply_exception (ex); 00255 } 00256 } 00257 00258 return; 00259 } |
|
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(), and operator=(). |
|
Reference counter.
Definition at line 154 of file Servant_Base.h. |