00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef TAO_ACTIVE_OBJECT_MAP_H
00015 #define TAO_ACTIVE_OBJECT_MAP_H
00016
00017 #include "ace/pre.h"
00018
00019 #include "tao/PortableServer/Key_Adapters.h"
00020
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif
00024
00025 #include "tao/PortableServer/Servant_Base.h"
00026 #include "tao/Server_Strategy_Factory.h"
00027 #include "ace/Map_T.h"
00028 #include "ace/Auto_Ptr.h"
00029
00030 #if defined (TAO_HAS_MONITOR_POINTS) && (TAO_HAS_MONITOR_POINTS == 1)
00031 #include "ace/Monitor_Size.h"
00032 #endif
00033
00034 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00035
00036
00037 class TAO_Id_Uniqueness_Strategy;
00038 class TAO_Lifespan_Strategy;
00039 class TAO_Id_Assignment_Strategy;
00040 class TAO_Id_Hint_Strategy;
00041 struct TAO_Active_Object_Map_Entry;
00042
00043
00044
00045
00046
00047
00048
00049
00050 class TAO_Active_Object_Map
00051 {
00052 public:
00053
00054
00055 TAO_Active_Object_Map (
00056 int user_id_policy,
00057 int unique_id_policy,
00058 int persistent_id_policy,
00059 const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters);
00060
00061
00062 ~TAO_Active_Object_Map (void);
00063
00064
00065 int
00066 is_servant_in_map (PortableServer::Servant servant,
00067 bool &deactivated);
00068
00069
00070
00071 bool
00072 is_user_id_in_map (const PortableServer::ObjectId &user_id,
00073 CORBA::Short priority,
00074 bool &priorities_match,
00075 bool &deactivated);
00076
00077
00078 int
00079 bind_using_system_id_returning_system_id (
00080 PortableServer::Servant servant,
00081 CORBA::Short priority,
00082 PortableServer::ObjectId_out system_id);
00083
00084
00085 int
00086 bind_using_system_id_returning_user_id (
00087 PortableServer::Servant servant,
00088 CORBA::Short priority,
00089 PortableServer::ObjectId_out user_id);
00090
00091
00092
00093 int
00094 bind_using_user_id (PortableServer::Servant servant,
00095 const PortableServer::ObjectId &user_id,
00096 CORBA::Short priority);
00097
00098
00099
00100 int
00101 find_system_id_using_user_id (const PortableServer::ObjectId &user_id,
00102 CORBA::Short priority,
00103 PortableServer::ObjectId_out system_id);
00104
00105
00106 int
00107 rebind_using_user_id_and_system_id (
00108 PortableServer::Servant servant,
00109 const PortableServer::ObjectId &user_id,
00110 const PortableServer::ObjectId &system_id,
00111 TAO_Active_Object_Map_Entry *&entry);
00112
00113
00114
00115 int
00116 unbind_using_user_id (const PortableServer::ObjectId &user_id);
00117
00118
00119
00120 int
00121 find_user_id_using_servant (PortableServer::Servant servant,
00122 PortableServer::ObjectId_out user_id);
00123
00124
00125
00126 int
00127 find_system_id_using_servant (PortableServer::Servant servant,
00128 PortableServer::ObjectId_out system_id,
00129 CORBA::Short &priority);
00130
00131
00132
00133 int
00134 find_servant_using_user_id (const PortableServer::ObjectId &user_id,
00135 PortableServer::Servant &servant);
00136
00137
00138
00139 int
00140 find_servant_using_system_id_and_user_id (
00141 const PortableServer::ObjectId &system_id,
00142 const PortableServer::ObjectId &user_id,
00143 PortableServer::Servant &servant,
00144 TAO_Active_Object_Map_Entry *&entry);
00145
00146
00147
00148 int
00149 find_servant_and_system_id_using_user_id (
00150 const PortableServer::ObjectId &user_id,
00151 PortableServer::Servant &servant,
00152 PortableServer::ObjectId_out system_id,
00153 CORBA::Short &priority);
00154
00155
00156
00157
00158
00159
00160
00161 int
00162 find_entry_using_user_id (const PortableServer::ObjectId &user_id,
00163 TAO_Active_Object_Map_Entry *&entry);
00164
00165
00166
00167 int
00168 find_user_id_using_system_id (const PortableServer::ObjectId &system_id,
00169 PortableServer::ObjectId_out user_id);
00170
00171
00172
00173 int
00174 find_user_id_using_system_id (const PortableServer::ObjectId &system_id,
00175 PortableServer::ObjectId &user_id);
00176
00177
00178
00179 CORBA::Boolean
00180 remaining_activations (PortableServer::Servant servant);
00181
00182
00183 size_t
00184 current_size (void);
00185
00186
00187 static size_t
00188 system_id_size (void);
00189
00190
00191 static void
00192 set_system_id_size (
00193 const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters);
00194
00195
00196 typedef ACE_Map<
00197 PortableServer::ObjectId,
00198 TAO_Active_Object_Map_Entry *> user_id_map;
00199
00200
00201 typedef ACE_Hash_Map_Manager_Ex_Adapter<
00202 PortableServer::ObjectId,
00203 TAO_Active_Object_Map_Entry *,
00204 TAO_ObjectId_Hash,
00205 ACE_Equal_To<PortableServer::ObjectId>,
00206 TAO_Incremental_Key_Generator> user_id_hash_map;
00207
00208
00209 typedef ACE_Map_Manager_Adapter<
00210 PortableServer::ObjectId,
00211 TAO_Active_Object_Map_Entry *,
00212 TAO_Incremental_Key_Generator> user_id_linear_map;
00213
00214
00215 typedef ACE_Active_Map_Manager_Adapter<
00216 PortableServer::ObjectId,
00217 TAO_Active_Object_Map_Entry *,
00218 TAO_Ignore_Original_Key_Adapter> user_id_active_map;
00219
00220
00221 typedef ACE_Map<
00222 PortableServer::Servant,
00223 TAO_Active_Object_Map_Entry *> servant_map;
00224
00225
00226 typedef ACE_Hash_Map_Manager_Ex_Adapter<
00227 PortableServer::Servant,
00228 TAO_Active_Object_Map_Entry *,
00229 TAO_Servant_Hash,
00230 ACE_Equal_To<PortableServer::Servant>,
00231 ACE_Noop_Key_Generator<PortableServer::Servant> > servant_hash_map;
00232
00233 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
00234
00235 typedef ACE_Map_Manager_Adapter<
00236 PortableServer::Servant,
00237 TAO_Active_Object_Map_Entry *,
00238 ACE_Noop_Key_Generator<PortableServer::Servant> > servant_linear_map;
00239 #endif
00240
00241
00242 auto_ptr<user_id_map> user_id_map_;
00243
00244
00245 auto_ptr<servant_map> servant_map_;
00246
00247
00248 auto_ptr<TAO_Id_Uniqueness_Strategy> id_uniqueness_strategy_;
00249
00250
00251 auto_ptr<TAO_Lifespan_Strategy> lifespan_strategy_;
00252
00253
00254 auto_ptr<TAO_Id_Assignment_Strategy> id_assignment_strategy_;
00255
00256
00257 auto_ptr<TAO_Id_Hint_Strategy> id_hint_strategy_;
00258
00259
00260
00261 bool using_active_maps_;
00262
00263
00264 static size_t system_id_size_;
00265
00266 #if defined (TAO_HAS_MONITOR_POINTS) && (TAO_HAS_MONITOR_POINTS == 1)
00267 ACE::Monitor_Control::Size_Monitor *monitor_;
00268 #endif
00269 };
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279 class TAO_Id_Uniqueness_Strategy
00280 {
00281 public:
00282
00283 virtual ~TAO_Id_Uniqueness_Strategy (void);
00284
00285
00286 virtual int
00287 is_servant_in_map (PortableServer::Servant servant,
00288 bool &deactivated) = 0;
00289
00290
00291
00292 virtual int
00293 unbind_using_user_id (const PortableServer::ObjectId &user_id) = 0;
00294
00295
00296
00297 virtual int
00298 find_user_id_using_servant (PortableServer::Servant servant,
00299 PortableServer::ObjectId_out user_id) = 0;
00300
00301
00302
00303 virtual int
00304 find_system_id_using_servant (PortableServer::Servant servant,
00305 PortableServer::ObjectId_out system_id,
00306 CORBA::Short &priority) = 0;
00307
00308
00309
00310 virtual int
00311 bind_using_user_id (PortableServer::Servant servant,
00312 const PortableServer::ObjectId &user_id,
00313 CORBA::Short priority,
00314 TAO_Active_Object_Map_Entry *&entry) = 0;
00315
00316
00317
00318 virtual CORBA::Boolean
00319 remaining_activations (PortableServer::Servant servant) = 0;
00320
00321
00322 void
00323 set_active_object_map (TAO_Active_Object_Map *active_object_map);
00324
00325 protected:
00326
00327
00328 TAO_Active_Object_Map *active_object_map_;
00329 };
00330
00331
00332
00333
00334
00335
00336
00337
00338 class TAO_Unique_Id_Strategy : public TAO_Id_Uniqueness_Strategy
00339 {
00340 public:
00341
00342
00343 virtual int
00344 is_servant_in_map (PortableServer::Servant servant,
00345 bool &deactivated);
00346
00347
00348
00349 virtual int
00350 unbind_using_user_id (const PortableServer::ObjectId &user_id);
00351
00352
00353
00354 virtual int
00355 find_user_id_using_servant (PortableServer::Servant servant,
00356 PortableServer::ObjectId_out user_id);
00357
00358
00359
00360 virtual int
00361 find_system_id_using_servant (PortableServer::Servant servant,
00362 PortableServer::ObjectId_out system_id,
00363 CORBA::Short &priority);
00364
00365
00366
00367 virtual int
00368 bind_using_user_id (PortableServer::Servant servant,
00369 const PortableServer::ObjectId &user_id,
00370 CORBA::Short priority,
00371 TAO_Active_Object_Map_Entry *&entry);
00372
00373
00374
00375 virtual CORBA::Boolean
00376 remaining_activations (PortableServer::Servant servant);
00377 };
00378
00379 #if !defined (CORBA_E_MICRO)
00380
00381
00382
00383
00384
00385
00386
00387 class TAO_Multiple_Id_Strategy : public TAO_Id_Uniqueness_Strategy
00388 {
00389 public:
00390
00391
00392 virtual int
00393 is_servant_in_map (PortableServer::Servant servant,
00394 bool &deactivated);
00395
00396
00397
00398 virtual int
00399 unbind_using_user_id (const PortableServer::ObjectId &user_id);
00400
00401
00402
00403 virtual int
00404 find_user_id_using_servant (PortableServer::Servant servant,
00405 PortableServer::ObjectId_out user_id);
00406
00407
00408
00409 virtual int
00410 find_system_id_using_servant (PortableServer::Servant servant,
00411 PortableServer::ObjectId_out system_id,
00412 CORBA::Short &priority);
00413
00414
00415
00416 virtual int
00417 bind_using_user_id (PortableServer::Servant servant,
00418 const PortableServer::ObjectId &user_id,
00419 CORBA::Short priority,
00420 TAO_Active_Object_Map_Entry *&entry);
00421
00422
00423
00424 virtual CORBA::Boolean
00425 remaining_activations (PortableServer::Servant servant);
00426 };
00427 #endif
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437 class TAO_Lifespan_Strategy
00438 {
00439 public:
00440
00441
00442 virtual ~TAO_Lifespan_Strategy (void);
00443
00444
00445 virtual int
00446 find_servant_using_system_id_and_user_id (
00447 const PortableServer::ObjectId &system_id,
00448 const PortableServer::ObjectId &user_id,
00449 PortableServer::Servant &servant,
00450 TAO_Active_Object_Map_Entry *&entry) = 0;
00451
00452
00453 void
00454 set_active_object_map (TAO_Active_Object_Map *active_object_map);
00455
00456 protected:
00457
00458
00459 TAO_Active_Object_Map *active_object_map_;
00460 };
00461
00462
00463
00464
00465
00466
00467
00468
00469 class TAO_Transient_Strategy : public TAO_Lifespan_Strategy
00470 {
00471 public:
00472
00473 virtual int
00474 find_servant_using_system_id_and_user_id (
00475 const PortableServer::ObjectId &system_id,
00476 const PortableServer::ObjectId &user_id,
00477 PortableServer::Servant &servant,
00478 TAO_Active_Object_Map_Entry *&entry);
00479 };
00480
00481 #if !defined (CORBA_E_MICRO)
00482
00483
00484
00485
00486
00487
00488
00489 class TAO_Persistent_Strategy : public TAO_Lifespan_Strategy
00490 {
00491 public:
00492
00493 virtual int
00494 find_servant_using_system_id_and_user_id (
00495 const PortableServer::ObjectId &system_id,
00496 const PortableServer::ObjectId &user_id,
00497 PortableServer::Servant &servant,
00498 TAO_Active_Object_Map_Entry *&entry);
00499 };
00500 #endif
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510 class TAO_Id_Assignment_Strategy
00511 {
00512 public:
00513
00514 virtual ~TAO_Id_Assignment_Strategy (void);
00515
00516
00517 virtual int
00518 bind_using_system_id (PortableServer::Servant servant,
00519 CORBA::Short priority,
00520 TAO_Active_Object_Map_Entry *&entry) = 0;
00521
00522
00523 void
00524 set_active_object_map (TAO_Active_Object_Map *active_object_map);
00525
00526 protected:
00527
00528
00529 TAO_Active_Object_Map *active_object_map_;
00530 };
00531
00532 #if !defined (CORBA_E_MICRO)
00533
00534
00535
00536
00537
00538
00539
00540 class TAO_User_Id_Strategy : public TAO_Id_Assignment_Strategy
00541 {
00542 public:
00543
00544 virtual int
00545 bind_using_system_id (PortableServer::Servant servant,
00546 CORBA::Short priority,
00547 TAO_Active_Object_Map_Entry *&entry);
00548 };
00549 #endif
00550
00551
00552
00553
00554
00555
00556
00557
00558 class TAO_System_Id_With_Unique_Id_Strategy
00559 : public TAO_Id_Assignment_Strategy
00560 {
00561 public:
00562
00563 virtual int
00564 bind_using_system_id (PortableServer::Servant servant,
00565 CORBA::Short priority,
00566 TAO_Active_Object_Map_Entry *&entry);
00567 };
00568
00569 #if !defined (CORBA_E_MICRO)
00570
00571
00572
00573
00574
00575
00576
00577 class TAO_System_Id_With_Multiple_Id_Strategy
00578 : public TAO_Id_Assignment_Strategy
00579 {
00580 public:
00581
00582 virtual int
00583 bind_using_system_id (PortableServer::Servant servant,
00584 CORBA::Short priority,
00585 TAO_Active_Object_Map_Entry *&entry);
00586 };
00587 #endif
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597 class TAO_Id_Hint_Strategy
00598 {
00599 public:
00600
00601 virtual ~TAO_Id_Hint_Strategy (void);
00602
00603
00604 virtual int
00605 recover_key (const PortableServer::ObjectId &system_id,
00606 PortableServer::ObjectId &user_id) = 0;
00607
00608
00609 virtual int
00610 bind (TAO_Active_Object_Map_Entry &entry) = 0;
00611
00612
00613 virtual int
00614 unbind (TAO_Active_Object_Map_Entry &entry) = 0;
00615
00616
00617 virtual int
00618 find (const PortableServer::ObjectId &system_id,
00619 TAO_Active_Object_Map_Entry *&entry) = 0;
00620
00621
00622 virtual size_t
00623 hint_size (void) = 0;
00624
00625
00626 virtual int
00627 system_id (PortableServer::ObjectId_out system_id,
00628 TAO_Active_Object_Map_Entry &entry) = 0;
00629 };
00630
00631
00632
00633
00634
00635
00636
00637
00638 class TAO_Active_Hint_Strategy : public TAO_Id_Hint_Strategy
00639 {
00640 public:
00641 TAO_Active_Hint_Strategy (CORBA::ULong map_size);
00642
00643
00644 virtual ~TAO_Active_Hint_Strategy (void);
00645
00646 virtual int
00647 recover_key (const PortableServer::ObjectId &system_id,
00648 PortableServer::ObjectId &user_id);
00649
00650 virtual int
00651 bind (TAO_Active_Object_Map_Entry &entry);
00652
00653 virtual int
00654 unbind (TAO_Active_Object_Map_Entry &entry);
00655
00656 virtual int
00657 find (const PortableServer::ObjectId &system_id,
00658 TAO_Active_Object_Map_Entry *&entry);
00659
00660 virtual size_t
00661 hint_size (void);
00662
00663 virtual int
00664 system_id (PortableServer::ObjectId_out system_id,
00665 TAO_Active_Object_Map_Entry &entry);
00666
00667 typedef ACE_Active_Map_Manager_Adapter<
00668 PortableServer::ObjectId,
00669 TAO_Active_Object_Map_Entry *,
00670 TAO_Preserve_Original_Key_Adapter> system_id_map;
00671
00672 system_id_map system_id_map_;
00673 };
00674
00675
00676
00677
00678
00679
00680
00681
00682 class TAO_No_Hint_Strategy : public TAO_Id_Hint_Strategy
00683 {
00684 public:
00685
00686 virtual ~TAO_No_Hint_Strategy (void);
00687
00688 virtual int
00689 recover_key (const PortableServer::ObjectId &system_id,
00690 PortableServer::ObjectId &user_id);
00691
00692 virtual int
00693 bind (TAO_Active_Object_Map_Entry &entry);
00694
00695 virtual int
00696 unbind (TAO_Active_Object_Map_Entry &entry);
00697
00698 virtual int
00699 find (const PortableServer::ObjectId &system_id,
00700 TAO_Active_Object_Map_Entry *&entry);
00701
00702 virtual size_t
00703 hint_size (void);
00704
00705 virtual int
00706 system_id (PortableServer::ObjectId_out system_id,
00707 TAO_Active_Object_Map_Entry &entry);
00708 };
00709
00710 TAO_END_VERSIONED_NAMESPACE_DECL
00711
00712 #if defined (__ACE_INLINE__)
00713 # include "tao/PortableServer/Active_Object_Map.inl"
00714 #endif
00715
00716 #include "ace/post.h"
00717
00718 #endif