TAO_Adapter_Registry Class Reference

#include <Adapter_Registry.h>

Collaboration diagram for TAO_Adapter_Registry:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_Adapter_Registry (TAO_ORB_Core *orb_core)
 ~TAO_Adapter_Registry (void)
 Close the.

void close (int wait_for_completion)
void check_close (int wait_for_completion)
void insert (TAO_Adapter *adapter)
 Insert a new adapter into the registry.

void dispatch (TAO::ObjectKey &key, TAO_ServerRequest &request, CORBA::Object_out forward_to)
CORBA::Object_ptr create_collocated_object (TAO_Stub *, const TAO_MProfile &)
 Create a collocated object using the given profile and stub.

CORBA::Long initialize_collocated_object (TAO_Stub *)
TAO_Adapterfind_adapter (const char *name) const
 Fetch the adapter named name.


Private Attributes

TAO_ORB_Coreorb_core_
 The ORB Core.

A simple array of adapters.
size_t adapters_capacity_
size_t adapters_count_
TAO_Adapter ** adapters_

Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Adapter_Registry::TAO_Adapter_Registry TAO_ORB_Core orb_core  ) 
 

Definition at line 19 of file Adapter_Registry.cpp.

References ACE_NEW.

00020   : orb_core_ (oc),
00021     adapters_capacity_ (16), // @@ Make it configurable
00022     adapters_count_ (0),
00023     adapters_ (0)
00024 {
00025   ACE_NEW (this->adapters_,
00026            TAO_Adapter*[this->adapters_capacity_]);
00027 }

TAO_Adapter_Registry::~TAO_Adapter_Registry void   ) 
 

Close the.

Definition at line 29 of file Adapter_Registry.cpp.

References adapters_, and adapters_count_.

00030 {
00031   for (size_t i = 0; i != this->adapters_count_; ++i)
00032     delete this->adapters_[i];
00033 
00034   delete[] this->adapters_;
00035 }


Member Function Documentation

void TAO_Adapter_Registry::check_close int  wait_for_completion  ) 
 

Verify if the close() call can be invoked in the current context for *all* adapters. Raise the right exception if not.

Definition at line 65 of file Adapter_Registry.cpp.

References ACE_ENV_ARG_PARAMETER, ACE_TRY_CHECK, adapters_, adapters_count_, and TAO_Adapter::check_close().

Referenced by TAO_ORB_Core::shutdown().

00067 {
00068   for (size_t i = 0; i != this->adapters_count_; ++i)
00069     {
00070       this->adapters_[i]->check_close (wait_for_completion
00071                                        ACE_ENV_ARG_PARAMETER);
00072       ACE_TRY_CHECK;
00073     }
00074 }

void TAO_Adapter_Registry::close int  wait_for_completion  ) 
 

Close each of of the Adapters and then cleanup the Registry. It is possible that an Adapter will reject a close() call if it is invoked in an innapropriate context (think shutting down the POA while performing an upcall).

Definition at line 38 of file Adapter_Registry.cpp.

References ACE_ANY_EXCEPTION, ACE_CATCHANY, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_PRINT_EXCEPTION, ACE_TRY, ACE_TRY_CHECK, adapters_, adapters_count_, TAO_Adapter::close(), and TAO_debug_level.

Referenced by TAO_ORB_Core::shutdown().

00040 {
00041   ACE_TRY
00042     {
00043       for (size_t i = 0; i != this->adapters_count_; ++i)
00044         {
00045           this->adapters_[i]->close (wait_for_completion
00046                                      ACE_ENV_ARG_PARAMETER);
00047           ACE_TRY_CHECK;
00048         }
00049     }
00050   ACE_CATCHANY
00051     {
00052       if (TAO_debug_level > 3)
00053         {
00054           ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
00055                                "Exception in TAO_Adapter_Registry::close ()");
00056         }
00057       return;
00058     }
00059   ACE_ENDTRY;
00060 
00061   return;
00062 }

CORBA::Object_ptr TAO_Adapter_Registry::create_collocated_object TAO_Stub ,
const TAO_MProfile
 

Create a collocated object using the given profile and stub.

Definition at line 141 of file Adapter_Registry.cpp.

References adapters_, adapters_count_, TAO_Stub::collocated_servant(), TAO_Adapter::create_collocated_object(), and CORBA::Object_ptr.

Referenced by TAO_ORB_Core::create_object().

00143 {
00144   for (size_t i = 0; i != this->adapters_count_; ++i)
00145     {
00146       CORBA::Object_ptr x =
00147         this->adapters_[i]->create_collocated_object (stub,
00148                                                       mprofile);
00149       if (x != 0)
00150         {
00151           if (!stub->collocated_servant ())
00152             {
00153               // This adapter created an object but it was not able to locate
00154               // a servant so we need to give the rest of the adapters a chance to
00155               // initialise the stub and find a servant or forward us or whatever.
00156               for (CORBA::Long go_on = 1; go_on && i != this->adapters_count_; ++i)
00157                 {
00158                   // initialize_collocated_object only returns 0 if it has completely
00159                   // initialised the object.
00160                   go_on = this->adapters_[i]->initialize_collocated_object (stub);
00161                 }
00162             }
00163           return x;
00164         }
00165     }
00166   return 0;
00167 }

void TAO_Adapter_Registry::dispatch TAO::ObjectKey key,
TAO_ServerRequest request,
CORBA::Object_out  forward_to
 

Dispatch the request to all the adapters. It tries the adapters ordered by priority, stopping when the adapter returns a status different from DS_MISMATCHED_KEY

Definition at line 115 of file Adapter_Registry.cpp.

References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_THROW, adapters_, adapters_count_, TAO_Adapter::dispatch(), CORBA::is_nil(), and CORBA::Object_out.

Referenced by TAO_Request_Dispatcher::dispatch(), TAO_GIOP_Message_Lite::process_locate_request(), and TAO_GIOP_Message_Lite::process_request().

00119 {
00120   for (size_t i = 0; i != this->adapters_count_; ++i)
00121     {
00122       int const r = this->adapters_[i]->dispatch (key,
00123                                                   request,
00124                                                   forward_to
00125                                                   ACE_ENV_ARG_PARAMETER);
00126       ACE_CHECK;
00127 
00128       if (r != TAO_Adapter::DS_MISMATCHED_KEY)
00129         {
00130           return;
00131         }
00132     }
00133 
00134   if (CORBA::is_nil (forward_to))
00135     {
00136       ACE_THROW (CORBA::OBJECT_NOT_EXIST ());
00137     }
00138 }

TAO_Adapter * TAO_Adapter_Registry::find_adapter const char *  name  )  const
 

Fetch the adapter named name.

Definition at line 187 of file Adapter_Registry.cpp.

References adapters_, adapters_count_, and ACE_OS::strcmp().

Referenced by TAO_ORB_Core::poa_adapter().

00188 {
00189   for (TAO_Adapter **i = this->adapters_;
00190        i != this->adapters_ + this->adapters_count_;
00191        ++i)
00192     if (ACE_OS::strcmp ((*i)->name (), name) == 0)
00193       return *i;
00194 
00195   return 0;
00196 
00197 }

CORBA::Long TAO_Adapter_Registry::initialize_collocated_object TAO_Stub  ) 
 

Initialize a collocated object using the given stub and object pointer for lazily evaluated object references.

Definition at line 170 of file Adapter_Registry.cpp.

References adapters_, adapters_count_, and TAO_Adapter::initialize_collocated_object().

Referenced by TAO_ORB_Core::initialize_object_i().

00171 {
00172   for (size_t i = 0; i != this->adapters_count_; ++i)
00173     {
00174       int const retval =
00175         this->adapters_[i]->initialize_collocated_object (stub);
00176       if (retval == 0)
00177         {
00178           // initialize_collocated_object only returns 0 if it has completely
00179           // initialised the object. We can return early.
00180           return retval;
00181         }
00182     }
00183   return 0;
00184 }

void TAO_Adapter_Registry::insert TAO_Adapter adapter  ) 
 

Insert a new adapter into the registry.

Definition at line 77 of file Adapter_Registry.cpp.

References ACE_CHECK, ACE_NEW_THROW_EX, adapters_, adapters_capacity_, adapters_count_, and TAO_Adapter::priority().

Referenced by TAO_ORB_Core::resolve_ior_table_i(), and TAO_ORB_Core::root_poa().

00079 {
00080   if (this->adapters_capacity_ == this->adapters_count_)
00081     {
00082       this->adapters_capacity_ *= 2;
00083       TAO_Adapter **tmp = 0;
00084       ACE_NEW_THROW_EX (tmp,
00085                         TAO_Adapter*[this->adapters_capacity_],
00086                         CORBA::NO_MEMORY ());
00087       ACE_CHECK;
00088 
00089       for (size_t i = 0; i != this->adapters_count_; ++i)
00090         tmp[i] = this->adapters_[i];
00091       delete[] this->adapters_;
00092       this->adapters_ = tmp;
00093     }
00094 
00095   int const priority = adapter->priority ();
00096   for (size_t i = 0; i != this->adapters_count_; ++i)
00097     {
00098       if (this->adapters_[i]->priority () >= priority)
00099         {
00100           for (size_t j = this->adapters_count_ + 1;
00101                j > i;
00102                --j)
00103             {
00104               this->adapters_[j] = this->adapters_[j - 1];
00105             }
00106           this->adapters_[i] = adapter;
00107           ++this->adapters_count_;
00108           return;
00109         }
00110     }
00111   this->adapters_[this->adapters_count_++] = adapter;
00112 }


Member Data Documentation

TAO_Adapter** TAO_Adapter_Registry::adapters_ [private]
 

Definition at line 111 of file Adapter_Registry.h.

Referenced by check_close(), close(), create_collocated_object(), dispatch(), find_adapter(), initialize_collocated_object(), insert(), and ~TAO_Adapter_Registry().

size_t TAO_Adapter_Registry::adapters_capacity_ [private]
 

Definition at line 109 of file Adapter_Registry.h.

Referenced by insert().

size_t TAO_Adapter_Registry::adapters_count_ [private]
 

Definition at line 110 of file Adapter_Registry.h.

Referenced by check_close(), close(), create_collocated_object(), dispatch(), find_adapter(), initialize_collocated_object(), insert(), and ~TAO_Adapter_Registry().

TAO_ORB_Core* TAO_Adapter_Registry::orb_core_ [private]
 

The ORB Core.

Definition at line 103 of file Adapter_Registry.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 12:12:12 2006 for TAO by doxygen 1.3.6