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 20 of file Adapter_Registry.cpp.

References ACE_NEW.

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

TAO_Adapter_Registry::~TAO_Adapter_Registry void   ) 
 

Close the.

Definition at line 30 of file Adapter_Registry.cpp.

References adapters_, and adapters_count_.

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


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 62 of file Adapter_Registry.cpp.

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

Referenced by TAO_ORB_Core::shutdown().

00063 {
00064   for (size_t i = 0; i != this->adapters_count_; ++i)
00065     {
00066       this->adapters_[i]->check_close (wait_for_completion);
00067     }
00068 }

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 39 of file Adapter_Registry.cpp.

References adapters_, adapters_count_, TAO_Adapter::close(), and TAO_debug_level.

Referenced by TAO_ORB_Core::shutdown().

00040 {
00041   try
00042     {
00043       for (size_t i = 0; i != this->adapters_count_; ++i)
00044         {
00045           this->adapters_[i]->close (wait_for_completion);
00046         }
00047     }
00048   catch (const::CORBA::Exception &ex)
00049     {
00050       if (TAO_debug_level > 3)
00051         {
00052           ex._tao_print_exception (
00053             "Exception in TAO_Adapter_Registry::close ()");
00054         }
00055       return;
00056     }
00057 
00058   return;
00059 }

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 128 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().

00130 {
00131   for (size_t i = 0; i != this->adapters_count_; ++i)
00132     {
00133       CORBA::Object_ptr x =
00134         this->adapters_[i]->create_collocated_object (stub, mprofile);
00135       if (x != 0)
00136         {
00137           if (!stub->collocated_servant ())
00138             {
00139               // This adapter created an object but it was not able to locate
00140               // a servant so we need to give the rest of the adapters a chance to
00141               // initialise the stub and find a servant or forward us or whatever.
00142               for (CORBA::Long go_on = 1; go_on && i != this->adapters_count_;
00143                    ++i)
00144                 {
00145                   // initialize_collocated_object only returns 0 if it has completely
00146                   // initialised the object.
00147                   go_on = this->adapters_[i]->initialize_collocated_object (
00148                     stub);
00149                 }
00150             }
00151           return x;
00152         }
00153     }
00154   return 0;
00155 }

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 107 of file Adapter_Registry.cpp.

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

Referenced by TAO_Request_Dispatcher::dispatch().

00110 {
00111   for (size_t i = 0; i != this->adapters_count_; ++i)
00112     {
00113       int const r = this->adapters_[i]->dispatch (key, request, forward_to);
00114 
00115       if (r != TAO_Adapter::DS_MISMATCHED_KEY)
00116         {
00117           return;
00118         }
00119     }
00120 
00121   if (CORBA::is_nil (forward_to))
00122     {
00123       throw ::CORBA::OBJECT_NOT_EXIST ();
00124     }
00125 }

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

Fetch the adapter named name.

Definition at line 175 of file Adapter_Registry.cpp.

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

Referenced by TAO_ORB_Core::poa_adapter().

00176 {
00177   for (TAO_Adapter **i = this->adapters_;
00178        i != this->adapters_ + this->adapters_count_;
00179        ++i)
00180     if (ACE_OS::strcmp ((*i)->name (), name) == 0)
00181       return *i;
00182 
00183   return 0;
00184 
00185 }

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 158 of file Adapter_Registry.cpp.

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

Referenced by TAO_ORB_Core::initialize_object_i().

00159 {
00160   for (size_t i = 0; i != this->adapters_count_; ++i)
00161     {
00162       int const retval =
00163         this->adapters_[i]->initialize_collocated_object (stub);
00164       if (retval == 0)
00165         {
00166           // initialize_collocated_object only returns 0 if it has completely
00167           // initialised the object. We can return early.
00168           return retval;
00169         }
00170     }
00171   return 0;
00172 }

void TAO_Adapter_Registry::insert TAO_Adapter adapter  ) 
 

Insert a new adapter into the registry.

Definition at line 71 of file Adapter_Registry.cpp.

References 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().

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


Member Data Documentation

TAO_Adapter** TAO_Adapter_Registry::adapters_ [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().

size_t TAO_Adapter_Registry::adapters_capacity_ [private]
 

Definition at line 108 of file Adapter_Registry.h.

Referenced by insert().

size_t TAO_Adapter_Registry::adapters_count_ [private]
 

Definition at line 109 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 102 of file Adapter_Registry.h.


The documentation for this class was generated from the following files:
Generated on Sun Jan 27 13:13:58 2008 for TAO by doxygen 1.3.6