TAO::Portable_Server::RequestProcessingStrategyServantLocator Class Reference

#include <RequestProcessingStrategyServantLocator.h>

Inheritance diagram for TAO::Portable_Server::RequestProcessingStrategyServantLocator:

Inheritance graph
[legend]
Collaboration diagram for TAO::Portable_Server::RequestProcessingStrategyServantLocator:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RequestProcessingStrategyServantLocator (void)
virtual void strategy_cleanup (void)
PortableServer::ServantManager_ptr get_servant_manager (void)
void set_servant_manager (PortableServer::ServantManager_ptr imgr)
virtual TAO_SERVANT_LOCATION locate_servant (const PortableServer::ObjectId &system_id, PortableServer::Servant &servant)
virtual void post_invoke_servant_cleanup (const PortableServer::ObjectId &system_id, const TAO::Portable_Server::Servant_Upcall &servant_upcall)
virtual PortableServer::Servant locate_servant (const char *operation, const PortableServer::ObjectId &system_id, TAO::Portable_Server::Servant_Upcall &servant_upcall, TAO::Portable_Server::POA_Current_Impl &poa_current_impl, bool &wait_occurred_restart_call)
virtual void cleanup_servant (PortableServer::Servant servant, const PortableServer::ObjectId &user_id)
virtual void etherealize_objects (CORBA::Boolean etherealize_objects)

Private Attributes

PortableServer::ServantLocator_var servant_locator_

Detailed Description

Definition at line 35 of file RequestProcessingStrategyServantLocator.h.


Constructor & Destructor Documentation

TAO::Portable_Server::RequestProcessingStrategyServantLocator::RequestProcessingStrategyServantLocator ( void   ) 

Definition at line 24 of file RequestProcessingStrategyServantLocator.cpp.

00025     {
00026     }


Member Function Documentation

void TAO::Portable_Server::RequestProcessingStrategyServantLocator::cleanup_servant ( PortableServer::Servant  servant,
const PortableServer::ObjectId user_id 
) [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 167 of file RequestProcessingStrategyServantLocator.cpp.

References TAO_ServantBase::_remove_ref().

00170     {
00171       if (servant)
00172         {
00173           // ATTENTION: Trick locking here, see class header for details
00174           Non_Servant_Upcall non_servant_upcall (*this->poa_);
00175           ACE_UNUSED_ARG (non_servant_upcall);
00176 
00177           servant->_remove_ref ();
00178         }
00179 
00180       // This operation causes the association of the Object Id specified
00181       // by the oid parameter and its servant to be removed from the
00182       // Active Object Map.
00183       if (this->poa_->unbind_using_user_id (user_id) != 0)
00184         {
00185           throw ::CORBA::OBJ_ADAPTER ();
00186         }
00187     }

void TAO::Portable_Server::RequestProcessingStrategyServantLocator::etherealize_objects ( CORBA::Boolean  etherealize_objects  )  [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 190 of file RequestProcessingStrategyServantLocator.cpp.

00192     {
00193     }

PortableServer::ServantManager_ptr TAO::Portable_Server::RequestProcessingStrategyServantLocator::get_servant_manager ( void   )  [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 42 of file RequestProcessingStrategyServantLocator.cpp.

00043     {
00044       return PortableServer::ServantManager::_duplicate (this->servant_locator_.in ());
00045     }

PortableServer::Servant TAO::Portable_Server::RequestProcessingStrategyServantLocator::locate_servant ( const char *  operation,
const PortableServer::ObjectId system_id,
TAO::Portable_Server::Servant_Upcall servant_upcall,
TAO::Portable_Server::POA_Current_Impl poa_current_impl,
bool &  wait_occurred_restart_call 
) [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 87 of file RequestProcessingStrategyServantLocator.cpp.

References CORBA::COMPLETED_NO, TAO_Root_POA::find_servant(), TAO::Portable_Server::Servant_Upcall::locator_cookie(), TAO_Object_Adapter::lock(), TAO_Root_POA::object_adapter(), TAO::Portable_Server::Servant_Upcall::OBJECT_ADAPTER_LOCK_RELEASED, TAO::Portable_Server::POA_Current_Impl::object_id(), CORBA::OMGVMCID, TAO::Portable_Server::Servant_Upcall::operation(), TAO::Portable_Server::RequestProcessingStrategy::poa_, ACE_Lock::release(), servant_locator_, TAO::Portable_Server::Servant_Upcall::state(), and TAO::Portable_Server::RequestProcessingStrategyServantManager::validate_servant_manager().

00093     {
00094       PortableServer::Servant servant = this->poa_->find_servant (system_id,
00095                                                                   servant_upcall,
00096                                                                   poa_current_impl);
00097 
00098       if (servant != 0)
00099         {
00100           return servant;
00101         }
00102 
00103       // If the POA has the USE_SERVANT_MANAGER policy, a servant manager
00104       // has been associated with the POA so the POA will invoke incarnate
00105       // or preinvoke on it to find a servant that may handle the
00106       // request. (The choice of method depends on the NON_RETAIN or
00107       // RETAIN policy of the POA.) If no servant manager has been
00108       // associated with the POA, the POA raises the OBJ_ADAPTER system
00109       // exception.
00110       //
00111       // If a servant manager is located and invoked, but the servant
00112       // manager is not directly capable of incarnating the object, it
00113       // (the servant manager) may deal with the circumstance in a variety
00114       // of ways, all of which are the application's responsibility.  Any
00115       // system exception raised by the servant manager will be returned
00116       // to the client in the reply. In addition to standard CORBA
00117       // exceptions, a servant manager is capable of raising a
00118       // ForwardRequest exception. This exception includes an object
00119       // reference.
00120       //
00121 
00122       this->validate_servant_manager (this->servant_locator_.in ());
00123 
00124       // No serialization of invocations of preinvoke or
00125       // postinvoke may be assumed; there may be multiple
00126       // concurrent invocations of preinvoke for the same
00127       // ObjectId.
00128       //
00129       // The same thread will be used to preinvoke the object,
00130       // process the request, and postinvoke the object.
00131 
00132       // @@ Note that it is possible for some other thread to
00133       // reset the servant locator once the lock is released.
00134       // However, this possiblility also exists for postinvoke()
00135       // which is also called outside the lock.
00136 
00137       // Release the object adapter lock.
00138       this->poa_->object_adapter().lock ().release ();
00139 
00140       // We have released the object adapter lock.  Record this
00141       // for later use.
00142       servant_upcall.state (TAO::Portable_Server::Servant_Upcall::OBJECT_ADAPTER_LOCK_RELEASED);
00143 
00144       PortableServer::ServantLocator::Cookie cookie = 0;
00145       servant =
00146         this->servant_locator_->preinvoke (poa_current_impl.object_id (),
00147                                            this->poa_,
00148                                            operation,
00149                                            cookie);
00150 
00151       if (servant == 0)
00152         {
00153           throw ::CORBA::OBJ_ADAPTER (CORBA::OMGVMCID | 7, CORBA::COMPLETED_NO);
00154         }
00155 
00156       // Remember the cookie
00157       servant_upcall.locator_cookie (cookie);
00158 
00159       // Remember operation name.
00160       servant_upcall.operation (operation);
00161 
00162       // Success
00163       return servant;
00164     }

TAO_SERVANT_LOCATION TAO::Portable_Server::RequestProcessingStrategyServantLocator::locate_servant ( const PortableServer::ObjectId system_id,
PortableServer::Servant servant 
) [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 68 of file RequestProcessingStrategyServantLocator.cpp.

References CORBA::is_nil(), TAO::Portable_Server::RequestProcessingStrategy::poa_, TAO_Root_POA::servant_present(), TAO_SERVANT_MANAGER, and TAO_SERVANT_NOT_FOUND.

00071     {
00072       TAO_SERVANT_LOCATION  location =
00073         this->poa_->servant_present (system_id, servant);
00074 
00075       if (location == TAO_SERVANT_NOT_FOUND)
00076         {
00077           if (!CORBA::is_nil (this->servant_locator_.in ()))
00078             {
00079               location = TAO_SERVANT_MANAGER;
00080             }
00081         }
00082 
00083       return location;
00084     }

void TAO::Portable_Server::RequestProcessingStrategyServantLocator::post_invoke_servant_cleanup ( const PortableServer::ObjectId system_id,
const TAO::Portable_Server::Servant_Upcall servant_upcall 
) [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 196 of file RequestProcessingStrategyServantLocator.cpp.

References CORBA::is_nil(), TAO::Portable_Server::Servant_Upcall::locator_cookie(), TAO::Portable_Server::Servant_Upcall::operation(), TAO::Portable_Server::Servant_Upcall::servant(), and servant_locator_.

00199     {
00200       // @todo This method seems to misbehave according to the corba spec, see
00201       // section 11.3.7.2. It says that when postinvoke raises an system
00202       // exception the methods normal return is overrriden, the request completes
00203       // with the exception
00204 
00205       if (!CORBA::is_nil (this->servant_locator_.in ()) &&
00206           servant_upcall.servant())
00207         {
00208           try
00209             {
00210               servant_locator_->postinvoke (system_id,
00211                                             this->poa_,
00212                                             servant_upcall.operation (),
00213                                             servant_upcall.locator_cookie (),
00214                                             servant_upcall.servant ());
00215             }
00216           catch (const ::CORBA::Exception&)
00217             {
00218               // Ignore errors from servant locator ....
00219             }
00220         }
00221     }

void TAO::Portable_Server::RequestProcessingStrategyServantLocator::set_servant_manager ( PortableServer::ServantManager_ptr  imgr  )  [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 48 of file RequestProcessingStrategyServantLocator.cpp.

References CORBA::COMPLETED_NO, CORBA::is_nil(), CORBA::OMGVMCID, servant_locator_, and TAO::Portable_Server::RequestProcessingStrategyServantManager::validate_servant_manager().

00050     {
00051       // This operation sets the default servant manager associated with the
00052       // POA. This operation may only be invoked once after a POA has been
00053       // created. Attempting to set the servant manager after one has already
00054       // been set will result in the BAD_INV_ORDER system exception with
00055       // standard minor code 6 being raised (see 11.3.9.12 of the corba spec)
00056       if (!CORBA::is_nil (this->servant_locator_.in ()))
00057         {
00058           throw ::CORBA::BAD_INV_ORDER (CORBA::OMGVMCID | 6,
00059                                         CORBA::COMPLETED_NO);
00060         }
00061 
00062       this->servant_locator_ = PortableServer::ServantLocator::_narrow (imgr);
00063 
00064       this->validate_servant_manager (this->servant_locator_.in ());
00065     }

void TAO::Portable_Server::RequestProcessingStrategyServantLocator::strategy_cleanup ( void   )  [virtual]

Reimplemented from TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 29 of file RequestProcessingStrategyServantLocator.cpp.

References servant_locator_, and TAO::Portable_Server::RequestProcessingStrategy::strategy_cleanup().

00030     {
00031       {
00032         Non_Servant_Upcall non_servant_upcall (*this->poa_);
00033         ACE_UNUSED_ARG (non_servant_upcall);
00034 
00035         this->servant_locator_ = PortableServer::ServantLocator::_nil ();
00036       }
00037 
00038       RequestProcessingStrategy::strategy_cleanup ();
00039     }


Member Data Documentation

PortableServer::ServantLocator_var TAO::Portable_Server::RequestProcessingStrategyServantLocator::servant_locator_ [private]

Definition at line 69 of file RequestProcessingStrategyServantLocator.h.

Referenced by locate_servant(), post_invoke_servant_cleanup(), set_servant_manager(), and strategy_cleanup().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:41:49 2010 for TAO_PortableServer by  doxygen 1.4.7