00001
00002
00003 #include "tao/PortableServer/Active_Object_Map.h"
00004 #include "tao/PortableServer/Active_Object_Map_Entry.h"
00005
00006 #if !defined (__ACE_INLINE__)
00007 # include "tao/PortableServer/Active_Object_Map.inl"
00008 #endif
00009
00010 #include "tao/SystemException.h"
00011
00012 #include "ace/Auto_Ptr.h"
00013 #include "ace/CORBA_macros.h"
00014
00015 ACE_RCSID(PortableServer,
00016 Active_Object_Map,
00017 "$Id: Active_Object_Map.cpp 79258 2007-08-08 11:58:47Z johnnyw $")
00018
00019 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00020
00021
00022 size_t TAO_Active_Object_Map::system_id_size_ = 0;
00023
00024 void
00025 TAO_Active_Object_Map::set_system_id_size
00026 (const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters)
00027 {
00028 if (TAO_Active_Object_Map::system_id_size_ == 0)
00029 {
00030 if (creation_parameters.allow_reactivation_of_system_ids_)
00031 {
00032 switch (creation_parameters.object_lookup_strategy_for_system_id_policy_)
00033 {
00034 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
00035 case TAO_LINEAR:
00036 TAO_Active_Object_Map::system_id_size_ =
00037 sizeof (CORBA::ULong);
00038 break;
00039 #endif
00040
00041 case TAO_DYNAMIC_HASH:
00042 default:
00043 TAO_Active_Object_Map::system_id_size_ = sizeof (CORBA::ULong);
00044 break;
00045 }
00046
00047 size_t hint_size = 0;
00048
00049 if (creation_parameters.use_active_hint_in_ids_)
00050 hint_size = ACE_Active_Map_Manager_Key::size ();
00051
00052 TAO_Active_Object_Map::system_id_size_ += hint_size;
00053 }
00054 else
00055 {
00056 switch (creation_parameters.object_lookup_strategy_for_system_id_policy_)
00057 {
00058 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
00059 case TAO_LINEAR:
00060 TAO_Active_Object_Map::system_id_size_ =
00061 sizeof (CORBA::ULong);
00062 break;
00063
00064 case TAO_DYNAMIC_HASH:
00065 TAO_Active_Object_Map::system_id_size_ =
00066 sizeof (CORBA::ULong);
00067 break;
00068 #endif
00069
00070 case TAO_ACTIVE_DEMUX:
00071 default:
00072 TAO_Active_Object_Map::system_id_size_ =
00073 ACE_Active_Map_Manager_Key::size ();
00074 break;
00075 }
00076 }
00077 }
00078 }
00079
00080 TAO_Active_Object_Map::TAO_Active_Object_Map (int user_id_policy,
00081 int unique_id_policy,
00082 int persistent_id_policy,
00083 const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters)
00084 : user_id_map_ (0),
00085 servant_map_ (0),
00086 id_uniqueness_strategy_ (0),
00087 lifespan_strategy_ (0),
00088 id_assignment_strategy_ (0),
00089 id_hint_strategy_ (0),
00090 using_active_maps_ (false)
00091 {
00092 TAO_Active_Object_Map::set_system_id_size (creation_parameters);
00093
00094 TAO_Id_Uniqueness_Strategy *id_uniqueness_strategy = 0;
00095
00096 if (unique_id_policy)
00097 {
00098 ACE_NEW_THROW_EX (id_uniqueness_strategy,
00099 TAO_Unique_Id_Strategy,
00100 CORBA::NO_MEMORY ());
00101 }
00102 else
00103 {
00104 #if !defined (CORBA_E_MICRO)
00105 ACE_NEW_THROW_EX (id_uniqueness_strategy,
00106 TAO_Multiple_Id_Strategy,
00107 CORBA::NO_MEMORY ());
00108 #else
00109 ACE_ERROR ((LM_ERROR,
00110 "Multiple Id Strategy not supported with CORBA/e\n"));
00111 #endif
00112 }
00113
00114
00115 auto_ptr<TAO_Id_Uniqueness_Strategy> new_id_uniqueness_strategy (id_uniqueness_strategy);
00116
00117 TAO_Lifespan_Strategy *lifespan_strategy = 0;
00118
00119 if (persistent_id_policy)
00120 {
00121 #if !defined (CORBA_E_MICRO)
00122 ACE_NEW_THROW_EX (lifespan_strategy,
00123 TAO_Persistent_Strategy,
00124 CORBA::NO_MEMORY ());
00125 #else
00126 ACE_UNUSED_ARG (persistent_id_policy);
00127 ACE_ERROR ((LM_ERROR,
00128 "Persistent Id Strategy not supported with CORBA/e\n"));
00129 #endif
00130 }
00131 else
00132 {
00133 ACE_NEW_THROW_EX (lifespan_strategy,
00134 TAO_Transient_Strategy,
00135 CORBA::NO_MEMORY ());
00136 }
00137
00138
00139 auto_ptr<TAO_Lifespan_Strategy> new_lifespan_strategy (lifespan_strategy);
00140
00141 TAO_Id_Assignment_Strategy *id_assignment_strategy = 0;
00142
00143 if (user_id_policy)
00144 {
00145 #if !defined (CORBA_E_MICRO)
00146 ACE_NEW_THROW_EX (id_assignment_strategy,
00147 TAO_User_Id_Strategy,
00148 CORBA::NO_MEMORY ());
00149 #else
00150 ACE_ERROR ((LM_ERROR,
00151 "User Id Assignment not supported with CORBA/e\n"));
00152 #endif
00153 }
00154 else if (unique_id_policy)
00155 {
00156 ACE_NEW_THROW_EX (id_assignment_strategy,
00157 TAO_System_Id_With_Unique_Id_Strategy,
00158 CORBA::NO_MEMORY ());
00159 }
00160 else
00161 {
00162 #if !defined (CORBA_E_MICRO)
00163 ACE_NEW_THROW_EX (id_assignment_strategy,
00164 TAO_System_Id_With_Multiple_Id_Strategy,
00165 CORBA::NO_MEMORY ());
00166 #else
00167 ACE_ERROR ((LM_ERROR,
00168 "System Id Assignment with multiple not supported with CORBA/e\n"));
00169 #endif
00170 }
00171
00172
00173 auto_ptr<TAO_Id_Assignment_Strategy> new_id_assignment_strategy (id_assignment_strategy);
00174
00175 TAO_Id_Hint_Strategy *id_hint_strategy = 0;
00176 if ((user_id_policy
00177 || creation_parameters.allow_reactivation_of_system_ids_)
00178 && creation_parameters.use_active_hint_in_ids_)
00179 {
00180 this->using_active_maps_ = true;
00181
00182 ACE_NEW_THROW_EX (id_hint_strategy,
00183 TAO_Active_Hint_Strategy (creation_parameters.active_object_map_size_),
00184 CORBA::NO_MEMORY ());
00185 }
00186 else
00187 {
00188 ACE_NEW_THROW_EX (id_hint_strategy,
00189 TAO_No_Hint_Strategy,
00190 CORBA::NO_MEMORY ());
00191 }
00192
00193
00194 auto_ptr<TAO_Id_Hint_Strategy> new_id_hint_strategy (id_hint_strategy);
00195
00196 servant_map *sm = 0;
00197 if (unique_id_policy)
00198 {
00199 switch (creation_parameters.reverse_object_lookup_strategy_for_unique_id_policy_)
00200 {
00201 case TAO_LINEAR:
00202 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
00203 ACE_NEW_THROW_EX (sm,
00204 servant_linear_map (creation_parameters.active_object_map_size_),
00205 CORBA::NO_MEMORY ());
00206 break;
00207 #else
00208 ACE_ERROR ((LM_ERROR,
00209 "linear option for -ORBUniqueidPolicyReverseDemuxStrategy "
00210 "not supported with minimum POA maps. "
00211 "Ingoring option to use default... \n"));
00212
00213 #endif
00214
00215 case TAO_DYNAMIC_HASH:
00216 default:
00217 ACE_NEW_THROW_EX (sm,
00218 servant_hash_map (creation_parameters.active_object_map_size_),
00219 CORBA::NO_MEMORY ());
00220 break;
00221 }
00222 }
00223
00224
00225 auto_ptr<servant_map> new_servant_map (sm);
00226
00227 user_id_map *uim = 0;
00228 if (user_id_policy
00229 || creation_parameters.allow_reactivation_of_system_ids_)
00230 {
00231 switch (creation_parameters.object_lookup_strategy_for_user_id_policy_)
00232 {
00233 case TAO_LINEAR:
00234 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
00235 ACE_NEW_THROW_EX (uim,
00236 user_id_linear_map (creation_parameters.active_object_map_size_),
00237 CORBA::NO_MEMORY ());
00238 break;
00239 #else
00240 ACE_ERROR ((LM_ERROR,
00241 "linear option for -ORBUseridPolicyDemuxStrategy "
00242 "not supported with minimum POA maps. "
00243 "Ingoring option to use default... \n"));
00244
00245 #endif
00246
00247 case TAO_DYNAMIC_HASH:
00248 default:
00249 ACE_NEW_THROW_EX (uim,
00250 user_id_hash_map (creation_parameters.active_object_map_size_),
00251 CORBA::NO_MEMORY ());
00252 break;
00253 }
00254 }
00255 else
00256 {
00257 switch (creation_parameters.object_lookup_strategy_for_system_id_policy_)
00258 {
00259 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
00260 case TAO_LINEAR:
00261 ACE_NEW_THROW_EX (uim,
00262 user_id_linear_map (creation_parameters.active_object_map_size_),
00263 CORBA::NO_MEMORY ());
00264 break;
00265
00266 case TAO_DYNAMIC_HASH:
00267 ACE_NEW_THROW_EX (uim,
00268 user_id_hash_map (creation_parameters.active_object_map_size_),
00269 CORBA::NO_MEMORY ());
00270 break;
00271 #else
00272 case TAO_LINEAR:
00273 case TAO_DYNAMIC_HASH:
00274 ACE_ERROR ((LM_ERROR,
00275 "linear and dynamic options for -ORBSystemidPolicyDemuxStrategy "
00276 "are not supported with minimum POA maps. "
00277 "Ingoring option to use default... \n"));
00278
00279 #endif
00280
00281 case TAO_ACTIVE_DEMUX:
00282 default:
00283
00284 this->using_active_maps_ = true;
00285
00286 ACE_NEW_THROW_EX (uim,
00287 user_id_active_map (creation_parameters.active_object_map_size_),
00288 CORBA::NO_MEMORY ());
00289 break;
00290 }
00291 }
00292
00293
00294 auto_ptr<user_id_map> new_user_id_map (uim);
00295
00296 id_uniqueness_strategy->set_active_object_map (this);
00297 lifespan_strategy->set_active_object_map (this);
00298 id_assignment_strategy->set_active_object_map (this);
00299
00300
00301
00302 this->id_uniqueness_strategy_ = new_id_uniqueness_strategy.release ();
00303 this->lifespan_strategy_ = new_lifespan_strategy.release ();
00304 this->id_assignment_strategy_ = new_id_assignment_strategy.release ();
00305 this->id_hint_strategy_ = new_id_hint_strategy.release ();
00306 this->servant_map_ = new_servant_map.release ();
00307 this->user_id_map_ = new_user_id_map.release ();
00308 }
00309
00310 TAO_Active_Object_Map::~TAO_Active_Object_Map (void)
00311 {
00312 user_id_map::iterator iterator = this->user_id_map_->begin ();
00313 user_id_map::iterator end = this->user_id_map_->end ();
00314
00315 for (;
00316 iterator != end;
00317 ++iterator)
00318 {
00319 user_id_map::value_type map_entry = *iterator;
00320 delete map_entry.second ();
00321 }
00322
00323 delete this->id_uniqueness_strategy_;
00324 delete this->lifespan_strategy_;
00325 delete this->id_assignment_strategy_;
00326 delete this->id_hint_strategy_;
00327 delete this->servant_map_;
00328 delete this->user_id_map_;
00329 }
00330
00331 bool
00332 TAO_Active_Object_Map::is_user_id_in_map (const PortableServer::ObjectId &user_id,
00333 CORBA::Short priority,
00334 bool &priorities_match,
00335 bool &deactivated)
00336 {
00337 TAO_Active_Object_Map_Entry *entry = 0;
00338 bool result = false;
00339 int const find_result = this->user_id_map_->find (user_id, entry);
00340 if (find_result == 0)
00341 {
00342 if (entry->servant_ == 0)
00343 {
00344 if (entry->priority_ != priority)
00345 priorities_match = false;
00346 }
00347 else
00348 {
00349 result = true;
00350 if (entry->deactivated_)
00351 {
00352 deactivated = true;
00353 }
00354 }
00355 }
00356
00357 return result;
00358 }
00359
00360
00361
00362 TAO_Id_Uniqueness_Strategy::~TAO_Id_Uniqueness_Strategy (void)
00363 {
00364 }
00365
00366 void
00367 TAO_Id_Uniqueness_Strategy::set_active_object_map (TAO_Active_Object_Map *active_object_map)
00368 {
00369 this->active_object_map_ = active_object_map;
00370 }
00371
00372 int
00373 TAO_Unique_Id_Strategy::is_servant_in_map (PortableServer::Servant servant,
00374 bool &deactivated)
00375 {
00376 TAO_Active_Object_Map_Entry *entry = 0;
00377 int result = this->active_object_map_->servant_map_->find (servant,
00378 entry);
00379 if (result == 0)
00380 {
00381 result = 1;
00382 if (entry->deactivated_)
00383 {
00384 deactivated = true;
00385 }
00386 }
00387 else
00388 {
00389 result = 0;
00390 }
00391
00392 return result;
00393 }
00394
00395 int
00396 TAO_Unique_Id_Strategy::bind_using_user_id (PortableServer::Servant servant,
00397 const PortableServer::ObjectId &user_id,
00398 CORBA::Short priority,
00399 TAO_Active_Object_Map_Entry *&entry)
00400 {
00401 int result = this->active_object_map_->user_id_map_->find (user_id, entry);
00402 if (result == 0)
00403 {
00404 if (servant != 0)
00405 {
00406 entry->servant_ = servant;
00407
00408 result = this->active_object_map_->servant_map_->bind (entry->servant_,
00409 entry);
00410 }
00411 }
00412 else
00413 {
00414 ACE_NEW_RETURN (entry,
00415 TAO_Active_Object_Map_Entry,
00416 -1);
00417 entry->user_id_ = user_id;
00418 entry->servant_ = servant;
00419 entry->priority_ = priority;
00420
00421 result = this->active_object_map_->id_hint_strategy_->bind (*entry);
00422
00423 if (result == 0)
00424 {
00425 result = this->active_object_map_->user_id_map_->bind (entry->user_id_,
00426 entry);
00427 if (result == 0)
00428 {
00429 if (servant != 0)
00430 result = this->active_object_map_->servant_map_->bind (entry->servant_,
00431 entry);
00432 if (result != 0)
00433 {
00434 this->active_object_map_->user_id_map_->unbind (entry->user_id_);
00435 this->active_object_map_->id_hint_strategy_->unbind (*entry);
00436 delete entry;
00437 }
00438 }
00439 else
00440 {
00441 this->active_object_map_->id_hint_strategy_->unbind (*entry);
00442 delete entry;
00443 }
00444 }
00445 else
00446 delete entry;
00447 }
00448
00449 return result;
00450 }
00451
00452 int
00453 TAO_Unique_Id_Strategy::unbind_using_user_id (const PortableServer::ObjectId &user_id)
00454 {
00455 TAO_Active_Object_Map_Entry *entry = 0;
00456 int result = this->active_object_map_->user_id_map_->unbind (user_id,
00457 entry);
00458 if (result == 0)
00459 {
00460 if (entry->servant_ != 0)
00461 result = this->active_object_map_->servant_map_->unbind (entry->servant_);
00462
00463 if (result == 0)
00464 result =
00465 this->active_object_map_->id_hint_strategy_->unbind (*entry);
00466
00467 if (result == 0)
00468 delete entry;
00469 }
00470 return result;
00471 }
00472
00473 int
00474 TAO_Unique_Id_Strategy::find_user_id_using_servant (PortableServer::Servant servant,
00475 PortableServer::ObjectId_out user_id)
00476 {
00477 TAO_Active_Object_Map_Entry *entry = 0;
00478 int result = this->active_object_map_->servant_map_->find (servant, entry);
00479 if (result == 0)
00480 {
00481 if (entry->deactivated_)
00482 result = -1;
00483 else
00484 ACE_NEW_RETURN (user_id,
00485 PortableServer::ObjectId (entry->user_id_),
00486 -1);
00487 }
00488
00489 return result;
00490 }
00491
00492 int
00493 TAO_Unique_Id_Strategy::find_system_id_using_servant (PortableServer::Servant servant,
00494 PortableServer::ObjectId_out system_id,
00495 CORBA::Short &priority)
00496 {
00497 TAO_Active_Object_Map_Entry *entry = 0;
00498 int result = this->active_object_map_->servant_map_->find (servant,
00499 entry);
00500 if (result == 0)
00501 {
00502 if (entry->deactivated_)
00503 result = -1;
00504 else
00505 {
00506 result = this->active_object_map_->id_hint_strategy_->system_id (system_id,
00507 *entry);
00508 if (result == 0)
00509 priority = entry->priority_;
00510 }
00511 }
00512
00513 return result;
00514 }
00515
00516 CORBA::Boolean
00517 TAO_Unique_Id_Strategy::remaining_activations (PortableServer::Servant servant)
00518 {
00519 ACE_UNUSED_ARG (servant);
00520
00521
00522 return 0;
00523 }
00524
00525
00526
00527 #if !defined (CORBA_E_MICRO)
00528 int
00529 TAO_Multiple_Id_Strategy::is_servant_in_map (PortableServer::Servant, bool &)
00530 {
00531 return -1;
00532 }
00533
00534 int
00535 TAO_Multiple_Id_Strategy::bind_using_user_id (PortableServer::Servant servant,
00536 const PortableServer::ObjectId &user_id,
00537 CORBA::Short priority,
00538 TAO_Active_Object_Map_Entry *&entry)
00539 {
00540 int result = this->active_object_map_->user_id_map_->find (user_id, entry);
00541 if (result == 0)
00542 {
00543 if (servant != 0)
00544 entry->servant_ = servant;
00545 }
00546 else
00547 {
00548 ACE_NEW_RETURN (entry,
00549 TAO_Active_Object_Map_Entry,
00550 -1);
00551 entry->user_id_ = user_id;
00552 entry->servant_ = servant;
00553 entry->priority_ = priority;
00554
00555 result =
00556 this->active_object_map_->id_hint_strategy_->bind (*entry);
00557
00558 if (result == 0)
00559 {
00560 result = this->active_object_map_->user_id_map_->bind (entry->user_id_,
00561 entry);
00562 if (result != 0)
00563 {
00564 this->active_object_map_->id_hint_strategy_->unbind (*entry);
00565 delete entry;
00566 }
00567 }
00568 else
00569 delete entry;
00570 }
00571
00572 return result;
00573 }
00574
00575 int
00576 TAO_Multiple_Id_Strategy::unbind_using_user_id (const PortableServer::ObjectId &user_id)
00577 {
00578 TAO_Active_Object_Map_Entry *entry = 0;
00579 int result = this->active_object_map_->user_id_map_->unbind (user_id,
00580 entry);
00581 if (result == 0)
00582 {
00583 result = this->active_object_map_->id_hint_strategy_->unbind (*entry);
00584
00585 if (result == 0)
00586 delete entry;
00587 }
00588
00589 return result;
00590 }
00591
00592 int
00593 TAO_Multiple_Id_Strategy::find_user_id_using_servant (PortableServer::Servant,
00594 PortableServer::ObjectId_out)
00595 {
00596 return -1;
00597 }
00598
00599 int
00600 TAO_Multiple_Id_Strategy::find_system_id_using_servant (PortableServer::Servant,
00601 PortableServer::ObjectId_out,
00602 CORBA::Short &)
00603 {
00604 return -1;
00605 }
00606
00607 CORBA::Boolean
00608 TAO_Multiple_Id_Strategy::remaining_activations (PortableServer::Servant servant)
00609 {
00610 TAO_Active_Object_Map::user_id_map::iterator end
00611 = this->active_object_map_->user_id_map_->end ();
00612
00613 for (TAO_Active_Object_Map::user_id_map::iterator iter
00614 = this->active_object_map_->user_id_map_->begin ();
00615 iter != end;
00616 ++iter)
00617 {
00618 TAO_Active_Object_Map::user_id_map::value_type map_pair = *iter;
00619 TAO_Active_Object_Map_Entry *entry = map_pair.second ();
00620
00621 if (entry->servant_ == servant)
00622 return 1;
00623 }
00624
00625 return 0;
00626 }
00627 #endif
00628
00629 TAO_Lifespan_Strategy::~TAO_Lifespan_Strategy (void)
00630 {
00631 }
00632
00633 void
00634 TAO_Lifespan_Strategy::set_active_object_map (TAO_Active_Object_Map *active_object_map)
00635 {
00636 this->active_object_map_ = active_object_map;
00637 }
00638
00639 int
00640 TAO_Transient_Strategy::find_servant_using_system_id_and_user_id (const PortableServer::ObjectId &system_id,
00641 const PortableServer::ObjectId &user_id,
00642 PortableServer::Servant &servant,
00643 TAO_Active_Object_Map_Entry *&entry)
00644 {
00645 int result = this->active_object_map_->id_hint_strategy_->find (system_id,
00646 entry);
00647 if (result == 0)
00648 {
00649 if (entry->deactivated_)
00650 result = -1;
00651 else if (entry->servant_ == 0)
00652 result = -1;
00653 else
00654 servant = entry->servant_;
00655 }
00656 else
00657 {
00658 result = this->active_object_map_->user_id_map_->find (user_id,
00659 entry);
00660 if (result == 0)
00661 {
00662 if (entry->deactivated_)
00663 result = -1;
00664 else if (entry->servant_ == 0)
00665 result = -1;
00666 else
00667 servant = entry->servant_;
00668 }
00669 }
00670
00671 if (result == -1)
00672 entry = 0;
00673
00674 return result;
00675 }
00676
00677
00678
00679 #if !defined (CORBA_E_MICRO)
00680 int
00681 TAO_Persistent_Strategy::find_servant_using_system_id_and_user_id (const PortableServer::ObjectId &system_id,
00682 const PortableServer::ObjectId &user_id,
00683 PortableServer::Servant &servant,
00684 TAO_Active_Object_Map_Entry *&entry)
00685 {
00686 int result = this->active_object_map_->id_hint_strategy_->find (system_id,
00687 entry);
00688 if (result == 0 &&
00689 user_id == entry->user_id_)
00690 {
00691 if (entry->deactivated_)
00692 result = -1;
00693 else if (entry->servant_ == 0)
00694 result = -1;
00695 else
00696 servant = entry->servant_;
00697 }
00698 else
00699 {
00700 result = this->active_object_map_->user_id_map_->find (user_id, entry);
00701 if (result == 0)
00702 {
00703 if (entry->deactivated_)
00704 result = -1;
00705 else if (entry->servant_ == 0)
00706 result = -1;
00707 else
00708 servant = entry->servant_;
00709 }
00710 }
00711
00712 if (result == -1)
00713 entry = 0;
00714
00715 return result;
00716 }
00717 #endif
00718
00719 TAO_Id_Assignment_Strategy::~TAO_Id_Assignment_Strategy (void)
00720 {
00721 }
00722
00723 void
00724 TAO_Id_Assignment_Strategy::set_active_object_map (TAO_Active_Object_Map *active_object_map)
00725 {
00726 this->active_object_map_ = active_object_map;
00727 }
00728
00729 #if !defined (CORBA_E_MICRO)
00730 int
00731 TAO_User_Id_Strategy::bind_using_system_id (PortableServer::Servant,
00732 CORBA::Short,
00733 TAO_Active_Object_Map_Entry *&)
00734 {
00735 return -1;
00736 }
00737 #endif
00738
00739 int
00740 TAO_System_Id_With_Unique_Id_Strategy::bind_using_system_id (PortableServer::Servant servant,
00741 CORBA::Short priority,
00742 TAO_Active_Object_Map_Entry *&entry)
00743 {
00744 ACE_NEW_RETURN (entry,
00745 TAO_Active_Object_Map_Entry,
00746 -1);
00747
00748 int result = this->active_object_map_->user_id_map_->bind_create_key (entry,
00749 entry->user_id_);
00750 if (result == 0)
00751 {
00752 entry->servant_ = servant;
00753 entry->priority_ = priority;
00754
00755 result = this->active_object_map_->id_hint_strategy_->bind (*entry);
00756
00757 if (result == 0)
00758 {
00759 if (servant != 0)
00760 result = this->active_object_map_->servant_map_->bind (entry->servant_,
00761 entry);
00762
00763 if (result != 0)
00764 {
00765 this->active_object_map_->user_id_map_->unbind (entry->user_id_);
00766 this->active_object_map_->id_hint_strategy_->unbind (*entry);
00767 delete entry;
00768 }
00769 }
00770 else
00771 {
00772 this->active_object_map_->user_id_map_->unbind (entry->user_id_);
00773 delete entry;
00774 }
00775 }
00776 else
00777 delete entry;
00778
00779 return result;
00780 }
00781
00782 #if !defined (CORBA_E_MICRO)
00783 int
00784 TAO_System_Id_With_Multiple_Id_Strategy::bind_using_system_id (PortableServer::Servant servant,
00785 CORBA::Short priority,
00786 TAO_Active_Object_Map_Entry *&entry)
00787 {
00788 ACE_NEW_RETURN (entry,
00789 TAO_Active_Object_Map_Entry,
00790 -1);
00791 int result = this->active_object_map_->user_id_map_->bind_create_key (entry,
00792 entry->user_id_);
00793 if (result == 0)
00794 {
00795 entry->servant_ = servant;
00796 entry->priority_ = priority;
00797
00798 result = this->active_object_map_->id_hint_strategy_->bind (*entry);
00799
00800 if (result != 0)
00801 {
00802 this->active_object_map_->user_id_map_->unbind (entry->user_id_);
00803 delete entry;
00804 }
00805 }
00806 else
00807 delete entry;
00808
00809 return result;
00810 }
00811 #endif
00812
00813
00814
00815 TAO_Id_Hint_Strategy::~TAO_Id_Hint_Strategy (void)
00816 {
00817 }
00818
00819
00820
00821 TAO_Active_Hint_Strategy::TAO_Active_Hint_Strategy (CORBA::ULong map_size)
00822 : system_id_map_ (map_size)
00823 {
00824 }
00825
00826 TAO_Active_Hint_Strategy::~TAO_Active_Hint_Strategy (void)
00827 {
00828 }
00829
00830 int
00831 TAO_Active_Hint_Strategy::recover_key (const PortableServer::ObjectId &system_id,
00832 PortableServer::ObjectId &user_id)
00833 {
00834 return this->system_id_map_.recover_key (system_id,
00835 user_id);
00836 }
00837
00838 int
00839 TAO_Active_Hint_Strategy::bind (TAO_Active_Object_Map_Entry &entry)
00840 {
00841 entry.system_id_ = entry.user_id_;
00842
00843 return this->system_id_map_.bind_modify_key (&entry,
00844 entry.system_id_);
00845 }
00846
00847 int
00848 TAO_Active_Hint_Strategy::unbind (TAO_Active_Object_Map_Entry &entry)
00849 {
00850 return this->system_id_map_.unbind (entry.system_id_);
00851 }
00852
00853 int
00854 TAO_Active_Hint_Strategy::find (const PortableServer::ObjectId &system_id,
00855 TAO_Active_Object_Map_Entry *&entry)
00856 {
00857 return this->system_id_map_.find (system_id,
00858 entry);
00859 }
00860
00861 size_t
00862 TAO_Active_Hint_Strategy::hint_size (void)
00863 {
00864 return ACE_Active_Map_Manager_Key::size ();
00865 }
00866
00867 int
00868 TAO_Active_Hint_Strategy::system_id (PortableServer::ObjectId_out system_id,
00869 TAO_Active_Object_Map_Entry &entry)
00870 {
00871 ACE_NEW_RETURN (system_id,
00872 PortableServer::ObjectId (entry.system_id_),
00873 -1);
00874 return 0;
00875 }
00876
00877
00878
00879 TAO_No_Hint_Strategy::~TAO_No_Hint_Strategy (void)
00880 {
00881 }
00882
00883 int
00884 TAO_No_Hint_Strategy::recover_key (const PortableServer::ObjectId &system_id,
00885 PortableServer::ObjectId &user_id)
00886 {
00887
00888 user_id.replace (system_id.maximum (),
00889 system_id.length (),
00890 const_cast<CORBA::Octet *> (system_id.get_buffer ()),
00891 0);
00892
00893 return 0;
00894 }
00895
00896 int
00897 TAO_No_Hint_Strategy::bind (TAO_Active_Object_Map_Entry &)
00898 {
00899 return 0;
00900 }
00901
00902 int
00903 TAO_No_Hint_Strategy::unbind (TAO_Active_Object_Map_Entry &)
00904 {
00905 return 0;
00906 }
00907
00908 int
00909 TAO_No_Hint_Strategy::find (const PortableServer::ObjectId &,
00910 TAO_Active_Object_Map_Entry *&)
00911 {
00912 return -1;
00913 }
00914
00915 size_t
00916 TAO_No_Hint_Strategy::hint_size (void)
00917 {
00918 return 0;
00919 }
00920
00921 int
00922 TAO_No_Hint_Strategy::system_id (PortableServer::ObjectId_out system_id,
00923 TAO_Active_Object_Map_Entry &entry)
00924 {
00925 ACE_NEW_RETURN (system_id,
00926 PortableServer::ObjectId (entry.user_id_),
00927 -1);
00928 return 0;
00929 }
00930
00931 TAO_END_VERSIONED_NAMESPACE_DECL