#include <Adapter_Registry.h>
Collaboration diagram for TAO_Adapter_Registry:
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_Adapter * | find_adapter (const char *name) const |
Fetch the adapter named name. | |
Private Attributes | |
TAO_ORB_Core * | orb_core_ |
The ORB Core. | |
A simple array of adapters. | |
size_t | adapters_capacity_ |
size_t | adapters_count_ |
TAO_Adapter ** | adapters_ |
Definition at line 50 of file Adapter_Registry.h.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_Adapter_Registry::TAO_Adapter_Registry | ( | TAO_ORB_Core * | orb_core | ) |
Definition at line 21 of file Adapter_Registry.cpp.
References ACE_NEW.
00022 : orb_core_ (oc), 00023 adapters_capacity_ (16), // @@ Make it configurable 00024 adapters_count_ (0), 00025 adapters_ (0) 00026 { 00027 ACE_NEW (this->adapters_, 00028 TAO_Adapter*[this->adapters_capacity_]); 00029 }
TAO_Adapter_Registry::~TAO_Adapter_Registry | ( | void | ) |
Close the.
Definition at line 31 of file Adapter_Registry.cpp.
References adapters_count_.
00032 { 00033 for (size_t i = 0; i != this->adapters_count_; ++i) 00034 delete this->adapters_[i]; 00035 00036 delete[] this->adapters_; 00037 }
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 63 of file Adapter_Registry.cpp.
References adapters_count_.
Referenced by TAO_ORB_Core::shutdown().
00064 { 00065 for (size_t i = 0; i != this->adapters_count_; ++i) 00066 { 00067 this->adapters_[i]->check_close (wait_for_completion); 00068 } 00069 }
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 40 of file Adapter_Registry.cpp.
References adapters_count_, and TAO_debug_level.
Referenced by TAO_ORB_Core::shutdown().
00041 { 00042 try 00043 { 00044 for (size_t i = 0; i != this->adapters_count_; ++i) 00045 { 00046 this->adapters_[i]->close (wait_for_completion); 00047 } 00048 } 00049 catch (const::CORBA::Exception &ex) 00050 { 00051 if (TAO_debug_level > 3) 00052 { 00053 ex._tao_print_exception ( 00054 "Exception in TAO_Adapter_Registry::close ()"); 00055 } 00056 return; 00057 } 00058 00059 return; 00060 }
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 129 of file Adapter_Registry.cpp.
References adapters_count_.
00131 { 00132 for (size_t i = 0; i != this->adapters_count_; ++i) 00133 { 00134 CORBA::Object_ptr x = 00135 this->adapters_[i]->create_collocated_object (stub, mprofile); 00136 if (x != 0) 00137 { 00138 if (!stub->collocated_servant ()) 00139 { 00140 // This adapter created an object but it was not able to locate 00141 // a servant so we need to give the rest of the adapters a chance to 00142 // initialise the stub and find a servant or forward us or whatever. 00143 for (CORBA::Long go_on = 1; go_on && i != this->adapters_count_; 00144 ++i) 00145 { 00146 // initialize_collocated_object only returns 0 if it has completely 00147 // initialised the object. 00148 go_on = this->adapters_[i]->initialize_collocated_object ( 00149 stub); 00150 } 00151 } 00152 return x; 00153 } 00154 } 00155 return 0; 00156 }
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 108 of file Adapter_Registry.cpp.
References adapters_count_, TAO_Adapter::DS_MISMATCHED_KEY, and TAO_ServerRequest::is_forwarded().
Referenced by TAO_Request_Dispatcher::dispatch().
00111 { 00112 for (size_t i = 0; i != this->adapters_count_; ++i) 00113 { 00114 int const r = this->adapters_[i]->dispatch (key, request, forward_to); 00115 00116 if (r != TAO_Adapter::DS_MISMATCHED_KEY) 00117 { 00118 return; 00119 } 00120 } 00121 00122 if (!request.is_forwarded ()) 00123 { 00124 throw ::CORBA::OBJECT_NOT_EXIST (); 00125 } 00126 }
TAO_Adapter * TAO_Adapter_Registry::find_adapter | ( | const char * | name | ) | const |
Fetch the adapter named name.
Definition at line 176 of file Adapter_Registry.cpp.
References ACE_OS::strcmp().
Referenced by TAO_ORB_Core::poa_adapter().
00177 { 00178 for (TAO_Adapter **i = this->adapters_; 00179 i != this->adapters_ + this->adapters_count_; 00180 ++i) 00181 if (ACE_OS::strcmp ((*i)->name (), name) == 0) 00182 return *i; 00183 00184 return 0; 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 159 of file Adapter_Registry.cpp.
References adapters_count_.
Referenced by TAO_ORB_Core::initialize_object_i().
00160 { 00161 for (size_t i = 0; i != this->adapters_count_; ++i) 00162 { 00163 int const retval = 00164 this->adapters_[i]->initialize_collocated_object (stub); 00165 if (retval == 0) 00166 { 00167 // initialize_collocated_object only returns 0 if it has completely 00168 // initialised the object. We can return early. 00169 return retval; 00170 } 00171 } 00172 return 0; 00173 }
void TAO_Adapter_Registry::insert | ( | TAO_Adapter * | adapter | ) |
Insert a new adapter into the registry.
Definition at line 72 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().
00073 { 00074 if (this->adapters_capacity_ == this->adapters_count_) 00075 { 00076 this->adapters_capacity_ *= 2; 00077 TAO_Adapter **tmp = 0; 00078 ACE_NEW_THROW_EX (tmp, 00079 TAO_Adapter*[this->adapters_capacity_], 00080 CORBA::NO_MEMORY ()); 00081 00082 for (size_t i = 0; i != this->adapters_count_; ++i) 00083 tmp[i] = this->adapters_[i]; 00084 delete[] this->adapters_; 00085 this->adapters_ = tmp; 00086 } 00087 00088 int const priority = adapter->priority (); 00089 for (size_t i = 0; i != this->adapters_count_; ++i) 00090 { 00091 if (this->adapters_[i]->priority () >= priority) 00092 { 00093 for (size_t j = this->adapters_count_ + 1; 00094 j > i; 00095 --j) 00096 { 00097 this->adapters_[j] = this->adapters_[j - 1]; 00098 } 00099 this->adapters_[i] = adapter; 00100 ++this->adapters_count_; 00101 return; 00102 } 00103 } 00104 this->adapters_[this->adapters_count_++] = adapter; 00105 }
TAO_Adapter** TAO_Adapter_Registry::adapters_ [private] |
size_t TAO_Adapter_Registry::adapters_capacity_ [private] |
size_t TAO_Adapter_Registry::adapters_count_ [private] |
Definition at line 104 of file Adapter_Registry.h.
Referenced by check_close(), close(), create_collocated_object(), dispatch(), initialize_collocated_object(), insert(), and ~TAO_Adapter_Registry().
TAO_ORB_Core* TAO_Adapter_Registry::orb_core_ [private] |