00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef TAO_OBJECT_ADAPTER_H
00014 #define TAO_OBJECT_ADAPTER_H
00015
00016 #include "ace/pre.h"
00017
00018 #include "tao/PortableServer/portableserver_export.h"
00019
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif
00023
00024 #include "tao/PortableServer/Key_Adapters.h"
00025 #include "tao/PortableServer/poa_macros.h"
00026 #include "tao/PortableServer/Servant_Location.h"
00027 #include "tao/PortableServer/Default_Policy_Validator.h"
00028 #include "tao/PortableServer/POA_Policy_Set.h"
00029
00030 #include "tao/Adapter.h"
00031 #include "tao/Adapter_Factory.h"
00032 #include "tao/Server_Strategy_Factory.h"
00033 #include "tao/LocalObject.h"
00034
00035 #include "ace/Reverse_Lock_T.h"
00036 #include "ace/Condition_Thread_Mutex.h"
00037 #include "ace/Map_T.h"
00038
00039 #include "tao/PortableServer/Servant_Location.h"
00040
00041 #if defined(_MSC_VER)
00042 #pragma warning(push)
00043 #pragma warning(disable:4250)
00044 #endif
00045
00046 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00047
00048 class TAO_Root_POA;
00049 class TAO_POA_Manager;
00050 class TAO_TSS_Resources;
00051 class TAO_Transport;
00052 class TAO_Servant_Dispatcher;
00053 class TAO_POAManager_Factory;
00054
00055 namespace TAO
00056 {
00057 namespace Portable_Server
00058 {
00059 class Non_Servant_Upcall;
00060 class Servant_Upcall;
00061 class POA_Current_Impl;
00062 class Temporary_Creation_Time;
00063 }
00064 }
00065
00066
00067
00068
00069
00070
00071
00072
00073 class TAO_PortableServer_Export TAO_Object_Adapter
00074 : public TAO_Adapter
00075 {
00076 public:
00077
00078 friend class TAO_Root_POA;
00079
00080 typedef PortableServer::ObjectId poa_name;
00081 typedef PortableServer::ObjectId_var poa_name_var;
00082 typedef PortableServer::ObjectId_out poa_name_out;
00083
00084
00085 TAO_Object_Adapter (const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters,
00086 TAO_ORB_Core &orb_core);
00087
00088
00089 ~TAO_Object_Adapter (void);
00090
00091 int dispatch_servant (const TAO::ObjectKey &key,
00092 TAO_ServerRequest &req,
00093 CORBA::Object_out forward_to
00094 ACE_ENV_ARG_DECL);
00095
00096 int locate_servant (const TAO::ObjectKey &key
00097 ACE_ENV_ARG_DECL);
00098
00099 TAO_SERVANT_LOCATION find_servant (const TAO::ObjectKey &key,
00100 PortableServer::Servant &servant
00101 ACE_ENV_ARG_DECL);
00102
00103 int find_poa (const poa_name &system_name,
00104 CORBA::Boolean activate_it,
00105 CORBA::Boolean root,
00106 const TAO::Portable_Server::Temporary_Creation_Time &poa_creation_time,
00107 TAO_Root_POA *&poa
00108 ACE_ENV_ARG_DECL);
00109
00110 int bind_poa (const poa_name &folded_name,
00111 TAO_Root_POA *poa,
00112 poa_name_out system_name);
00113
00114 int unbind_poa (TAO_Root_POA *poa,
00115 const poa_name &folded_name,
00116 const poa_name &system_name);
00117
00118 int activate_poa (const poa_name &folded_name,
00119 TAO_Root_POA *&poa
00120 ACE_ENV_ARG_DECL);
00121
00122 ACE_Lock &lock (void);
00123
00124 TAO_SYNCH_MUTEX &thread_lock (void);
00125
00126 ACE_Reverse_Lock<ACE_Lock> &reverse_lock (void);
00127
00128
00129 TAO_Root_POA *root_poa (void) const;
00130
00131
00132 TAO_ORB_Core &orb_core (void) const;
00133
00134
00135 void wait_for_non_servant_upcalls_to_complete (CORBA::Environment &ACE_TRY_ENV);
00136
00137
00138 void wait_for_non_servant_upcalls_to_complete (void);
00139
00140 static CORBA::ULong transient_poa_name_size (void);
00141
00142
00143 TAO_Policy_Validator &validator (void);
00144
00145 int enable_locking() const;
00146
00147
00148 TAO_POA_Policy_Set &default_poa_policies (void);
00149
00150
00151
00152
00153 void servant_dispatcher (TAO_Servant_Dispatcher *dispatcher);
00154
00155
00156 void init_default_policies (TAO_POA_Policy_Set &policies
00157 ACE_ENV_ARG_DECL);
00158
00159
00160
00161 virtual void open (ACE_ENV_SINGLE_ARG_DECL);
00162 virtual void close (int wait_for_completion
00163 ACE_ENV_ARG_DECL);
00164 virtual void check_close (int wait_for_completion
00165 ACE_ENV_ARG_DECL);
00166 virtual int priority (void) const;
00167 virtual int dispatch (TAO::ObjectKey &key,
00168 TAO_ServerRequest &request,
00169 CORBA::Object_out forward_to
00170 ACE_ENV_ARG_DECL);
00171 virtual const char *name (void) const;
00172 virtual CORBA::Object_ptr root (void);
00173 virtual CORBA::Object_ptr create_collocated_object (TAO_Stub *,
00174 const TAO_MProfile &);
00175
00176 virtual CORBA::Long initialize_collocated_object (TAO_Stub *);
00177
00178 protected:
00179
00180 int locate_servant_i (const TAO::ObjectKey &key
00181 ACE_ENV_ARG_DECL);
00182
00183 TAO_SERVANT_LOCATION find_servant_i (const TAO::ObjectKey &key,
00184 PortableServer::Servant &servant
00185 ACE_ENV_ARG_DECL);
00186
00187 void dispatch_servant_i (const TAO::ObjectKey &key,
00188 TAO_ServerRequest &req,
00189 void *context
00190 ACE_ENV_ARG_DECL);
00191
00192 void locate_poa (const TAO::ObjectKey &key,
00193 PortableServer::ObjectId &id,
00194 TAO_Root_POA *&poa
00195 ACE_ENV_ARG_DECL);
00196
00197 int find_transient_poa (const poa_name &system_name,
00198 CORBA::Boolean root,
00199 const TAO::Portable_Server::Temporary_Creation_Time &poa_creation_time,
00200 TAO_Root_POA *&poa
00201 ACE_ENV_ARG_DECL);
00202
00203 int find_persistent_poa (const poa_name &system_name,
00204 TAO_Root_POA *&poa
00205 ACE_ENV_ARG_DECL);
00206
00207 int bind_transient_poa (TAO_Root_POA *poa,
00208 poa_name_out system_name);
00209
00210 int bind_persistent_poa (const poa_name &folded_name,
00211 TAO_Root_POA *poa,
00212 poa_name_out system_name);
00213
00214 int unbind_transient_poa (const poa_name &system_name);
00215
00216 int unbind_persistent_poa (const poa_name &folded_name,
00217 const poa_name &system_name);
00218
00219 static ACE_Lock *create_lock (int enable_locking,
00220 TAO_SYNCH_MUTEX &thread_lock);
00221
00222 virtual void do_dispatch (TAO_ServerRequest& req,
00223 TAO::Portable_Server::Servant_Upcall& upcall
00224 ACE_ENV_ARG_DECL);
00225
00226 public:
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236 class TAO_PortableServer_Export Hint_Strategy
00237 {
00238 public:
00239
00240 virtual ~Hint_Strategy (void);
00241
00242 virtual int find_persistent_poa (const poa_name &system_name,
00243 TAO_Root_POA *&poa
00244 ACE_ENV_ARG_DECL) = 0;
00245
00246 virtual int bind_persistent_poa (const poa_name &folded_name,
00247 TAO_Root_POA *poa,
00248 poa_name_out system_name) = 0;
00249
00250 virtual int unbind_persistent_poa (const poa_name &folded_name,
00251 const poa_name &system_name) = 0;
00252
00253 void object_adapter (TAO_Object_Adapter *oa);
00254
00255 protected:
00256
00257 TAO_Object_Adapter *object_adapter_;
00258 };
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 class TAO_PortableServer_Export Active_Hint_Strategy : public Hint_Strategy
00270 {
00271 public:
00272
00273 Active_Hint_Strategy (CORBA::ULong map_size);
00274
00275 virtual ~Active_Hint_Strategy (void);
00276
00277 virtual int find_persistent_poa (const poa_name &system_name,
00278 TAO_Root_POA *&poa
00279 ACE_ENV_ARG_DECL);
00280
00281 virtual int bind_persistent_poa (const poa_name &folded_name,
00282 TAO_Root_POA *poa,
00283 poa_name_out system_name);
00284
00285 virtual int unbind_persistent_poa (const poa_name &folded_name,
00286 const poa_name &system_name);
00287
00288 protected:
00289
00290 typedef ACE_Active_Map_Manager_Adapter<
00291 poa_name,
00292 TAO_Root_POA *,
00293 TAO_Preserve_Original_Key_Adapter> persistent_poa_system_map;
00294
00295 persistent_poa_system_map persistent_poa_system_map_;
00296 };
00297
00298 friend class Active_Hint_Strategy;
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309 class TAO_PortableServer_Export No_Hint_Strategy : public Hint_Strategy
00310 {
00311 public:
00312
00313 virtual ~No_Hint_Strategy (void);
00314
00315 virtual int find_persistent_poa (const poa_name &system_name,
00316 TAO_Root_POA *&poa
00317 ACE_ENV_ARG_DECL);
00318
00319 virtual int bind_persistent_poa (const poa_name &folded_name,
00320 TAO_Root_POA *poa,
00321 poa_name_out system_name);
00322
00323 virtual int unbind_persistent_poa (const poa_name &folded_name,
00324 const poa_name &system_name);
00325
00326 };
00327
00328 friend class No_Hint_Strategy;
00329
00330 protected:
00331
00332 Hint_Strategy *hint_strategy_;
00333
00334
00335 typedef ACE_Map<
00336 poa_name,
00337 TAO_Root_POA *> transient_poa_map;
00338
00339 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
00340
00341 typedef ACE_Hash_Map_Manager_Ex_Adapter<
00342 poa_name,
00343 TAO_Root_POA *,
00344 TAO_ObjectId_Hash,
00345 ACE_Equal_To<poa_name>,
00346 TAO_Incremental_Key_Generator> transient_poa_hash_map;
00347 #endif
00348
00349 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
00350
00351 typedef ACE_Map_Manager_Adapter<
00352 poa_name,
00353 TAO_Root_POA *,
00354 TAO_Incremental_Key_Generator> transient_poa_linear_map;
00355 #endif
00356
00357
00358 typedef ACE_Active_Map_Manager_Adapter<
00359 poa_name,
00360 TAO_Root_POA *,
00361 TAO_Ignore_Original_Key_Adapter> transient_poa_active_map;
00362
00363
00364 typedef ACE_Map<
00365 poa_name,
00366 TAO_Root_POA *> persistent_poa_name_map;
00367
00368
00369 typedef ACE_Hash_Map_Manager_Ex_Adapter<
00370 poa_name,
00371 TAO_Root_POA *,
00372 TAO_ObjectId_Hash,
00373 ACE_Equal_To<PortableServer::ObjectId>,
00374 ACE_Noop_Key_Generator<poa_name> > persistent_poa_name_hash_map;
00375
00376 #if (TAO_HAS_MINIMUM_POA_MAPS == 0)
00377
00378 typedef ACE_Map_Manager_Adapter<
00379 poa_name,
00380 TAO_Root_POA *,
00381 ACE_Noop_Key_Generator<poa_name> > persistent_poa_name_linear_map;
00382 #endif
00383
00384
00385 TAO_Servant_Dispatcher *servant_dispatcher_;
00386
00387
00388 persistent_poa_name_map *persistent_poa_name_map_;
00389
00390
00391 transient_poa_map *transient_poa_map_;
00392
00393 protected:
00394
00395 static CORBA::ULong transient_poa_name_size_;
00396
00397 static void set_transient_poa_name_size (const TAO_Server_Strategy_Factory::Active_Object_Map_Creation_Parameters &creation_parameters);
00398
00399 TAO_ORB_Core &orb_core_;
00400
00401 int enable_locking_;
00402
00403 TAO_SYNCH_MUTEX thread_lock_;
00404
00405 ACE_Lock *lock_;
00406
00407 ACE_Reverse_Lock<ACE_Lock> reverse_lock_;
00408
00409 public:
00410
00411
00412
00413
00414
00415
00416 class poa_name_iterator
00417 {
00418 public:
00419
00420
00421 poa_name_iterator (int begin,
00422 CORBA::ULong size,
00423 const CORBA::Octet *folded_buffer);
00424
00425
00426 bool operator== (const poa_name_iterator &rhs) const;
00427 bool operator!= (const poa_name_iterator &rhs) const;
00428
00429
00430 ACE_CString operator* () const;
00431
00432
00433 poa_name_iterator &operator++ (void);
00434
00435 protected:
00436
00437 CORBA::ULong size_;
00438 CORBA::ULong position_;
00439 const CORBA::Octet *folded_buffer_;
00440 CORBA::ULong last_separator_;
00441 };
00442
00443
00444
00445
00446
00447
00448 class iteratable_poa_name
00449 {
00450 public:
00451
00452 typedef poa_name_iterator iterator;
00453
00454 iteratable_poa_name (const poa_name &folded_name);
00455
00456 iterator begin (void) const;
00457 iterator end (void) const;
00458
00459 protected:
00460
00461 const poa_name &folded_name_;
00462 };
00463
00464 friend class TAO::Portable_Server::Non_Servant_Upcall;
00465
00466 friend class TAO::Portable_Server::Servant_Upcall;
00467
00468 public:
00469
00470
00471
00472 TAO::Portable_Server::Non_Servant_Upcall *non_servant_upcall_in_progress (void) const;
00473
00474 private:
00475
00476
00477 TAO_ServantBase *get_collocated_servant (const TAO_MProfile &mp);
00478
00479 private:
00480
00481
00482 TAO_SYNCH_CONDITION non_servant_upcall_condition_;
00483
00484
00485
00486 TAO::Portable_Server::Non_Servant_Upcall *non_servant_upcall_in_progress_;
00487
00488
00489 unsigned int non_servant_upcall_nesting_level_;
00490
00491
00492 ACE_thread_t non_servant_upcall_thread_;
00493
00494
00495 TAO_Root_POA *root_;
00496
00497
00498 TAO_POAManager_Factory *poa_manager_factory_;
00499
00500
00501
00502 TAO_POA_Default_Policy_Validator default_validator_;
00503
00504
00505
00506 TAO_POA_Policy_Set default_poa_policies_;
00507 };
00508
00509 TAO_END_VERSIONED_NAMESPACE_DECL
00510
00511 #if defined(_MSC_VER)
00512 #pragma warning(pop)
00513 #endif
00514
00515 #if defined (__ACE_INLINE__)
00516 # include "tao/PortableServer/Object_Adapter.i"
00517 #endif
00518
00519 #include "ace/post.h"
00520
00521 #endif