TAO::Portable_Server::RequestProcessingStrategyDefaultServant Class Reference

#include <RequestProcessingStrategyDefaultServant.h>

Inheritance diagram for TAO::Portable_Server::RequestProcessingStrategyDefaultServant:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RequestProcessingStrategyDefaultServant (void)
virtual void strategy_cleanup (void)
PortableServer::ServantManager_ptr get_servant_manager (void)
void set_servant_manager (PortableServer::ServantManager_ptr imgr)
PortableServer::Servant get_servant (void)
void set_servant (PortableServer::Servant servant)
virtual TAO_SERVANT_LOCATION locate_servant (const PortableServer::ObjectId &system_id, PortableServer::Servant &servant)
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 PortableServer::Servant system_id_to_servant (const PortableServer::ObjectId &system_id)
virtual PortableServer::Servant id_to_servant (const PortableServer::ObjectId &id)
virtual void cleanup_servant (PortableServer::Servant servant, const PortableServer::ObjectId &user_id)
virtual void etherealize_objects (CORBA::Boolean etherealize_objects)
virtual PortableServer::ObjectIdservant_to_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::RequestProcessingPolicyValue type () const

Private Attributes

PortableServer::ServantBase_var default_servant_

Detailed Description

Definition at line 38 of file RequestProcessingStrategyDefaultServant.h.


Constructor & Destructor Documentation

TAO::Portable_Server::RequestProcessingStrategyDefaultServant::RequestProcessingStrategyDefaultServant ( void   ) 

Definition at line 26 of file RequestProcessingStrategyDefaultServant.cpp.

00027       : default_servant_ (0)
00028     {
00029     }


Member Function Documentation

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

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 181 of file RequestProcessingStrategyDefaultServant.cpp.

References TAO_ServantBase::_remove_ref().

00184     {
00185       if (servant)
00186         {
00187           // ATTENTION: Trick locking here, see class header for details
00188           Non_Servant_Upcall non_servant_upcall (*this->poa_);
00189           ACE_UNUSED_ARG (non_servant_upcall);
00190 
00191           servant->_remove_ref ();
00192         }
00193 
00194       // This operation causes the association of the Object Id specified
00195       // by the oid parameter and its servant to be removed from the
00196       // Active Object Map.
00197       if (this->poa_->unbind_using_user_id (user_id) != 0)
00198         {
00199           throw ::CORBA::OBJ_ADAPTER ();
00200         }
00201     }

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

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 204 of file RequestProcessingStrategyDefaultServant.cpp.

00206     {
00207     }

PortableServer::Servant TAO::Portable_Server::RequestProcessingStrategyDefaultServant::get_servant ( void   )  [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 51 of file RequestProcessingStrategyDefaultServant.cpp.

References default_servant_, and PortableServer::Servant_var< T >::in().

00052     {
00053       // This operation returns the default servant associated with the
00054       // POA.
00055       return this->default_servant_.in ();
00056     }

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

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 38 of file RequestProcessingStrategyDefaultServant.cpp.

00039     {
00040       throw PortableServer::POA::WrongPolicy ();
00041     }

PortableServer::Servant TAO::Portable_Server::RequestProcessingStrategyDefaultServant::id_to_servant ( const PortableServer::ObjectId id  )  [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 162 of file RequestProcessingStrategyDefaultServant.cpp.

References default_servant_, and PortableServer::Servant_var< T >::in().

00164     {
00165       PortableServer::Servant servant = this->default_servant_.in ();
00166 
00167       if (servant == 0)
00168         {
00169           /*
00170            * If using default servant request processing strategy but
00171            * no default servant is available, we will raise the
00172            * ObjectNotActive system exception.
00173            */
00174           throw PortableServer::POA::ObjectNotActive ();
00175         }
00176 
00177       return servant;
00178     }

PortableServer::Servant TAO::Portable_Server::RequestProcessingStrategyDefaultServant::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 110 of file RequestProcessingStrategyDefaultServant.cpp.

References CORBA::COMPLETED_NO, default_servant_, TAO_Root_POA::find_servant(), PortableServer::Servant_var< T >::in(), CORBA::OMGVMCID, and TAO::Portable_Server::RequestProcessingStrategy::poa_.

00116     {
00117       PortableServer::Servant servant = 0;
00118 
00119       servant = this->poa_->find_servant (system_id,
00120                                           servant_upcall,
00121                                           poa_current_impl);
00122 
00123       if (servant == 0)
00124         {
00125           // If the POA has the USE_DEFAULT_SERVANT policy, a default servant
00126           // has been associated with the POA so the POA will invoke the
00127           // appropriate method on that servant. If no servant has been
00128           // associated with the POA, the POA raises the OBJ_ADAPTER system
00129           // exception.
00130           PortableServer::Servant default_servant = this->default_servant_.in ();
00131           if (default_servant == 0)
00132             {
00133               throw ::CORBA::OBJ_ADAPTER (
00134                 CORBA::OMGVMCID | 3,
00135                 CORBA::COMPLETED_NO);
00136             }
00137           else
00138             {
00139               // Success
00140               servant = default_servant;
00141             }
00142         }
00143 
00144         return servant;
00145     }

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

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 89 of file RequestProcessingStrategyDefaultServant.cpp.

References TAO::Portable_Server::RequestProcessingStrategy::poa_, TAO_Root_POA::servant_present(), TAO_DEFAULT_SERVANT, and TAO_SERVANT_NOT_FOUND.

00093     {
00094       TAO_SERVANT_LOCATION location = TAO_SERVANT_NOT_FOUND;
00095 
00096       location = this->poa_->servant_present (system_id, servant);
00097 
00098       if (location == TAO_SERVANT_NOT_FOUND)
00099         {
00100           if (this->default_servant_.in () != 0)
00101             {
00102               location = TAO_DEFAULT_SERVANT;
00103             }
00104         }
00105 
00106       return location;
00107     }

void TAO::Portable_Server::RequestProcessingStrategyDefaultServant::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 236 of file RequestProcessingStrategyDefaultServant.cpp.

00239     {
00240     }

PortableServer::ObjectId * TAO::Portable_Server::RequestProcessingStrategyDefaultServant::servant_to_id ( PortableServer::Servant  servant  )  [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 210 of file RequestProcessingStrategyDefaultServant.cpp.

References default_servant_, TAO::Portable_Server::POA_Current_Impl::get_object_id(), PortableServer::Servant_var< T >::in(), TAO_TSS_Resources::instance(), TAO::Portable_Server::RequestProcessingStrategy::poa_, TAO_TSS_Resources::poa_current_impl_, TAO::Portable_Server::POA_Current_Impl::servant(), and TAO_Root_POA::servant_to_user_id().

00212     {
00213       PortableServer::Servant default_servant = this->default_servant_.in ();
00214 
00215       if (default_servant != 0 &&
00216           default_servant == servant)
00217         {
00218           // If they are the same servant, then check if we are in an
00219           // upcall.
00220           TAO::Portable_Server::POA_Current_Impl *poa_current_impl =
00221             static_cast <TAO::Portable_Server::POA_Current_Impl *>
00222                         (TAO_TSS_Resources::instance ()->poa_current_impl_);
00223           // If we are in an upcall on the default servant, return the
00224           // ObjectId associated with the current invocation.
00225           if (poa_current_impl != 0 &&
00226               servant == poa_current_impl->servant ())
00227             {
00228               return poa_current_impl->get_object_id ();
00229             }
00230         }
00231 
00232       return this->poa_->servant_to_user_id (servant);
00233     }

void TAO::Portable_Server::RequestProcessingStrategyDefaultServant::set_servant ( PortableServer::Servant  servant  )  [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 59 of file RequestProcessingStrategyDefaultServant.cpp.

References TAO_ServantBase::_add_ref(), and default_servant_.

00061     {
00062       // This operation registers the specified servant with the POA as
00063       // the default servant. This servant will be used for all requests
00064       // for which no servant is found in the Active Object Map.
00065       this->default_servant_ = servant;
00066 
00067       // The implementation of set_servant will invoke _add_ref at least
00068       // once on the Servant argument before returning. When the POA no
00069       // longer needs the Servant, it will invoke _remove_ref on it the
00070       // same number of times.
00071       if (servant != 0)
00072         {
00073           // A recursive thread lock without using a recursive thread
00074           // lock.  Non_Servant_Upcall has a magic constructor and
00075           // destructor.  We unlock the Object_Adapter lock for the
00076           // duration of the servant activator upcalls; reacquiring once
00077           // the upcalls complete.  Even though we are releasing the lock,
00078           // other threads will not be able to make progress since
00079           // <Object_Adapter::non_servant_upcall_in_progress_> has been
00080           // set.
00081           Non_Servant_Upcall non_servant_upcall (*this->poa_);
00082           ACE_UNUSED_ARG (non_servant_upcall);
00083 
00084           servant->_add_ref ();
00085         }
00086     }

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

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 44 of file RequestProcessingStrategyDefaultServant.cpp.

00046     {
00047       throw PortableServer::POA::WrongPolicy ();
00048     }

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

Reimplemented from TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 32 of file RequestProcessingStrategyDefaultServant.cpp.

References default_servant_.

00033     {
00034       this->default_servant_ = 0;
00035     }

PortableServer::Servant TAO::Portable_Server::RequestProcessingStrategyDefaultServant::system_id_to_servant ( const PortableServer::ObjectId system_id  )  [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 148 of file RequestProcessingStrategyDefaultServant.cpp.

References default_servant_, TAO_Root_POA::find_servant(), PortableServer::Servant_var< T >::in(), and TAO::Portable_Server::RequestProcessingStrategy::poa_.

00150     {
00151       PortableServer::Servant servant = this->default_servant_.in ();
00152 
00153       if (servant == 0)
00154         {
00155           servant = this->poa_->find_servant (system_id);
00156         }
00157 
00158       return servant;
00159     }

PortableServer::RequestProcessingPolicyValue TAO::Portable_Server::RequestProcessingStrategyDefaultServant::type (  )  const [virtual]

Implements TAO::Portable_Server::RequestProcessingStrategy.

Definition at line 243 of file RequestProcessingStrategyDefaultServant.cpp.

00244     {
00245       return ::PortableServer::USE_DEFAULT_SERVANT;
00246     }


Member Data Documentation

PortableServer::ServantBase_var TAO::Portable_Server::RequestProcessingStrategyDefaultServant::default_servant_ [private]

Definition at line 87 of file RequestProcessingStrategyDefaultServant.h.

Referenced by get_servant(), id_to_servant(), locate_servant(), servant_to_id(), set_servant(), strategy_cleanup(), and system_id_to_servant().


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