diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-01-23 04:01:29 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-01-23 04:01:29 +0000 |
commit | f297a53ea794ab08514be4d8896f748b6281b48e (patch) | |
tree | 2b239305f6a6014e82aea2c09c451e428007f756 | |
parent | 4d115dfab0435c66776898c9fe6ca1f4758b3f03 (diff) | |
download | ATCD-f297a53ea794ab08514be4d8896f748b6281b48e.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/ChangeLog-98c | 168 | ||||
-rw-r--r-- | TAO/docs/releasenotes/orbcore.html | 2 | ||||
-rw-r--r-- | TAO/tao/orbobj.cpp | 10 | ||||
-rw-r--r-- | TAO/tao/poa.cpp | 885 | ||||
-rw-r--r-- | TAO/tao/poa.h | 220 | ||||
-rw-r--r-- | TAO/tao/poaC.h | 2 | ||||
-rw-r--r-- | TAO/tao/poaS.cpp | 64 | ||||
-rw-r--r-- | TAO/tao/poaS.h | 32 | ||||
-rw-r--r-- | TAO/tao/servant_base.cpp | 108 | ||||
-rw-r--r-- | TAO/tao/servant_base.h | 111 | ||||
-rw-r--r-- | TAO/tests/POA/Explicit_Activation_POA_Ids/server.cpp | 7 |
11 files changed, 1146 insertions, 463 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c index 2ed7ae826b6..567dc0457b9 100644 --- a/TAO/ChangeLog-98c +++ b/TAO/ChangeLog-98c @@ -1,63 +1,4 @@ -Thu Jan 22 16:56:32 1998 Carlos O'Ryan <coryan@cs.wustl.edu> - - * TAO_IDL/be_include/be_interface.h: - * TAO_IDL/be/be_interface.cpp: - * TAO_IDL/be/be_visitor_interface.cpp: - Fixed some relative name problems for the server header file. - - * TAO_IDL/be/be_visitor_sequence.cpp: - * TAO_IDL/be/be_visitor_root.cpp: - * TAO_IDL/be/be_visitor_args.cpp: - Get rid of some "unused arg" warnings. - -Thu Jan 22 15:26:55 1998 Chris Cleeland <cleeland@cs.wustl.edu> - - * tao/object.i: CORBA::Object --> CORBA_Object for internal stuff. - - * tao/object.i (CORBA_Object): Re-ordered member initialization to - match declaration order. - -Thu Jan 22 14:40:01 1998 Carlos O'Ryan <coryan@cs.wustl.edu> - - * tao/corbacom.h: - Fixed multiple definitions of ORB_var and ORB_out due to a - simplistic merge. - - * TAO_IDL/be/be_interface.cpp: - Generate _find() to locate operations; using just find() is not - complaint. - -Thu Jan 22 10:40:13 1998 Carlos O'Ryan <coryan@cs.wustl.edu> - - * Merged changes from main_to_poa_merge_10 up to - main_to_poa_merge_11 - -Wed Jan 21 00:31:40 1998 Irfan Pyarali <irfan@cs.wustl.edu> - - * tao/servant_base.cpp (_default_POA): Changed to use - TAO_ORB_Core_instance()->root_poa() instead of - TAO_ORB_Core_instance()->orb()->resolve_initial_references("RootPOA"). - - * tao/poaC: Added string_to_ObjectId and ObjectId_to_string - methods to PortableServer. - - * tao/poa.cpp (TAO_Adapter_Activator::unknown_adapter): Changed - the implementation of this object so that it does not depend on - being friends with the POA and the POAManager. Initially, this - was done to avoid recursive locks. However, since user may want - to write their own implementations, recursive locks were deemed - necessary. - - * tao/default_server.cpp (create_poa_lock): Changed implementation - to produce ACE_Recursive_Thread_Mutex instead of - ACE_Thread_Mutex. - - * tests/POA/RootPOA/RootPOA.cpp (main) and - tests/POA/NewPOA/NewPOA.cpp (main): Added code to destroy the - rootPOA. I am not sure this is the responsibility of the user - to destroy the rootPOA since they never really created it. The - responsibility probably lies with the ORB, but since the spec - seems neutral about this, it is ok for now. +Thu Jan 22 21:22:41 1998 Irfan Pyarali <irfan@cs.wustl.edu> * tao/poa: @@ -101,10 +42,117 @@ Wed Jan 21 00:31:40 1998 Irfan Pyarali <irfan@cs.wustl.edu> - Added code to create_POA_i and find_POA_i_optimized to check when topmost_poa_name == this->name_. + + - Added the concept of creation time to a POA. This way when a + transient POA gets a object key from a previous incarnation, + the OBJECT_NOT_EXISTS exception can be thrown. + + - Added a locator cookie field to TAO_POA_Current to keep track + of the cookie produced by the servant locator. + + - Made all methods virtual. + + - Renamed active_object_table to active_object_map. + + - Added pre_invoke and post_invoke methods to setup the + necessary state before doing the upcall to the servant. + + - Changed locate_servant to return 0 for success and -1 for + failure instead of trying to return a servant. This change is + necessary since there may not be a servant available but there + may be default servants or servant managers that could fill in + for the servant. Currently the locate_servant method takes an + optimistic approach to return TRUE when the servant was not + found but a default servant or servant manager was registered + with the POA, hoping the default servant or servant manager + will be able to fill in when the real request arrives. + + - Add a validity checks for POA policies. + + - Added support for servant managers (both servant locators and + servant activators), default servants and DSI. + * tao/poaC.h: Added DynamicImplementation class to the + PortableServer. + + * tao/poaS: Changed dispatch to _dispatch. + + * tao/servant_base: + + - Added TAO_DynamicImplementation class + (a.k.a. PortableServer::DynamicImplementation). Users will + inherit from this to implement DSI. + + - Added prefix _ to all methods names in the ServantBase class + to avoid potential crashes with user specified method names. + + - Made TAO_POA a friend of ServantBase. + + * tao/connect.cpp (handle_locate): Changed to use latest version + of TAO_POA::locate_servant. + + * tao/servant_base.cpp (_default_POA): Changed to use + TAO_ORB_Core_instance()->root_poa() instead of + TAO_ORB_Core_instance()->orb()->resolve_initial_references("RootPOA"). + + * tao/poaC: Added string_to_ObjectId and ObjectId_to_string + methods to PortableServer. + + * tao/poa.cpp (TAO_Adapter_Activator::unknown_adapter): Changed + the implementation of this object so that it does not depend on + being friends with the POA and the POAManager. Initially, this + was done to avoid recursive locks. However, since user may want + to write their own implementations, recursive locks were deemed + necessary. + + * tao/default_server.cpp (create_poa_lock): Changed implementation + to produce ACE_Recursive_Thread_Mutex instead of + ACE_Thread_Mutex. + + * tests/POA/RootPOA/RootPOA.cpp (main) and + tests/POA/NewPOA/NewPOA.cpp (main): Added code to destroy the + rootPOA. I am not sure this is the responsibility of the user + to destroy the rootPOA since they never really created it. The + responsibility probably lies with the ORB, but since the spec + seems neutral about this, it is ok for now. + * tao/object.i (CORBA_Object::Release): We must delete the object when the parent_ refcount goes to zero. +Thu Jan 22 16:56:32 1998 Carlos O'Ryan <coryan@cs.wustl.edu> + + * TAO_IDL/be_include/be_interface.h: + * TAO_IDL/be/be_interface.cpp: + * TAO_IDL/be/be_visitor_interface.cpp: + Fixed some relative name problems for the server header file. + + * TAO_IDL/be/be_visitor_sequence.cpp: + * TAO_IDL/be/be_visitor_root.cpp: + * TAO_IDL/be/be_visitor_args.cpp: + Get rid of some "unused arg" warnings. + +Thu Jan 22 15:26:55 1998 Chris Cleeland <cleeland@cs.wustl.edu> + + * tao/object.i: CORBA::Object --> CORBA_Object for internal stuff. + + * tao/object.i (CORBA_Object): Re-ordered member initialization to + match declaration order. + +Thu Jan 22 14:40:01 1998 Carlos O'Ryan <coryan@cs.wustl.edu> + + * tao/corbacom.h: + Fixed multiple definitions of ORB_var and ORB_out due to a + simplistic merge. + + * TAO_IDL/be/be_interface.cpp: + Generate _find() to locate operations; using just find() is not + complaint. + +Thu Jan 22 10:40:13 1998 Carlos O'Ryan <coryan@cs.wustl.edu> + + * Merged changes from main_to_poa_merge_10 up to + main_to_poa_merge_11 + Wed Jan 21 17:35:20 1998 Carlos O'Ryan <coryan@cs.wustl.edu> * TAO_IDL/be/be_visitor_interface.cpp: diff --git a/TAO/docs/releasenotes/orbcore.html b/TAO/docs/releasenotes/orbcore.html index 310ffa474c0..0ceb92f25e0 100644 --- a/TAO/docs/releasenotes/orbcore.html +++ b/TAO/docs/releasenotes/orbcore.html @@ -397,6 +397,8 @@ of this type are rather static in nature, this is currently not a big deal. However, it should be fixed soon. </LI> + <LI>CORBA_Exception::Release is not working correctly as the + memory is never really freed. </LI> </ol> </li> diff --git a/TAO/tao/orbobj.cpp b/TAO/tao/orbobj.cpp index 8d27d67c002..5d757e04620 100644 --- a/TAO/tao/orbobj.cpp +++ b/TAO/tao/orbobj.cpp @@ -305,7 +305,7 @@ CORBA_ORB::resolve_poa (void) // multiple threads using a global resource policy. if (poa == 0) { - TAO_POA_Manager *manager = new TAO_POA_Manager; + TAO_POA_Manager *manager = new TAO_Strategy_POA_Manager; TAO_POA_Policies root_poa_policies; root_poa_policies.implicit_activation (PortableServer::IMPLICIT_ACTIVATION); @@ -532,13 +532,15 @@ CORBA_ORB::key_to_object (const TAO::ObjectKey &key, // Return the CORBA::Object_ptr interface to this objref. CORBA::Object_ptr new_obj; - + if (data->QueryInterface (IID_CORBA_Object, - (void **) &new_obj) != TAO_NOERROR) + (void **) &new_obj) != TAO_NOERROR) env.exception (new CORBA::INTERNAL (CORBA::COMPLETED_NO)); - + data->Release (); return new_obj; + + // return new CORBA::Object (data); } diff --git a/TAO/tao/poa.cpp b/TAO/tao/poa.cpp index 23e9fabcbaa..e5bac93f28a 100644 --- a/TAO/tao/poa.cpp +++ b/TAO/tao/poa.cpp @@ -1,9 +1,9 @@ // @(#) $Id$ // CORBA -#include "tao/corba.h" +#include "tao/corba.h" -// POA +// POA #include "tao/poa.h" // Exception macros @@ -12,6 +12,9 @@ // auto_ptr class #include "ace/Auto_Ptr.h" +// This is the maximum space require to convert the ulong into a string +const int TAO_POA::max_space_required_for_ulong = 24; + TAO_Thread_Policy::TAO_Thread_Policy (PortableServer::ThreadPolicyValue value) : value_ (value) { @@ -29,7 +32,7 @@ TAO_Thread_Policy::value (CORBA::Environment &env) return this->value_; } -PortableServer::Policy_ptr +PortableServer::Policy_ptr TAO_Thread_Policy::copy (CORBA::Environment &env) { auto_ptr<TAO_Thread_Policy> new_policy (new TAO_Thread_Policy (*this)); @@ -45,10 +48,12 @@ TAO_Thread_Policy::copy (CORBA::Environment &env) return result._retn (); } } - -void + +void TAO_Thread_Policy::destroy (CORBA::Environment &env) { + ACE_UNUSED_ARG (env); + // Commit suicide: must have been dynamically allocated delete this; } @@ -90,6 +95,8 @@ TAO_Lifespan_Policy::copy (CORBA::Environment &env) void TAO_Lifespan_Policy::destroy (CORBA::Environment &env) { + ACE_UNUSED_ARG (env); + // Commit suicide: must have been dynamically allocated delete this; } @@ -131,6 +138,8 @@ TAO_Id_Uniqueness_Policy::copy (CORBA::Environment &env) void TAO_Id_Uniqueness_Policy::destroy (CORBA::Environment &env) { + ACE_UNUSED_ARG (env); + // Commit suicide: must have been dynamically allocated delete this; } @@ -148,7 +157,7 @@ TAO_Id_Assignment_Policy::TAO_Id_Assignment_Policy (const TAO_Id_Assignment_Poli PortableServer::IdAssignmentPolicyValue TAO_Id_Assignment_Policy::value (CORBA::Environment &env) { - ACE_UNUSED_ARG (env); + ACE_UNUSED_ARG (env); return this->value_; } @@ -172,6 +181,8 @@ TAO_Id_Assignment_Policy::copy (CORBA::Environment &env) void TAO_Id_Assignment_Policy::destroy (CORBA::Environment &env) { + ACE_UNUSED_ARG (env); + // Commit suicide: must have been dynamically allocated delete this; } @@ -213,6 +224,8 @@ TAO_Implicit_Activation_Policy::copy (CORBA::Environment &env) void TAO_Implicit_Activation_Policy::destroy (CORBA::Environment &env) { + ACE_UNUSED_ARG (env); + // Commit suicide: must have been dynamically allocated delete this; } @@ -230,7 +243,7 @@ TAO_Servant_Retention_Policy::TAO_Servant_Retention_Policy (const TAO_Servant_Re PortableServer::ServantRetentionPolicyValue TAO_Servant_Retention_Policy::value (CORBA::Environment &env) { - ACE_UNUSED_ARG (env); + ACE_UNUSED_ARG (env); return this->value_; } @@ -254,6 +267,8 @@ TAO_Servant_Retention_Policy::copy (CORBA::Environment &env) void TAO_Servant_Retention_Policy::destroy (CORBA::Environment &env) { + ACE_UNUSED_ARG (env); + // Commit suicide: must have been dynamically allocated delete this; } @@ -295,6 +310,8 @@ TAO_Request_Processing_Policy::copy (CORBA::Environment &env) void TAO_Request_Processing_Policy::destroy (CORBA::Environment &env) { + ACE_UNUSED_ARG (env); + // Commit suicide: must have been dynamically allocated delete this; } @@ -311,7 +328,7 @@ TAO_POA_Policies::TAO_POA_Policies (void) } void -TAO_POA_Policies::parse_policies (const PortableServer::PolicyList& policies, +TAO_POA_Policies::parse_policies (const PortableServer::PolicyList &policies, CORBA::Environment &env) { for (CORBA::ULong i = 0; @@ -320,6 +337,42 @@ TAO_POA_Policies::parse_policies (const PortableServer::PolicyList& policies, { this->parse_policy (policies[i], env); } + + if (this->validity_check () == -1) + { + CORBA::Exception *exception = new PortableServer::POA::InvalidPolicy; + env.exception (exception); + return; + } +} + +int +TAO_POA_Policies::validity_check (void) +{ + // The NON_RETAIN policy requires either the USE_DEFAULT_SERVANT or + // USE_SERVANT_MANAGER policies. + if (this->servant_retention_ == PortableServer::NON_RETAIN) + if (this->request_processing_ != PortableServer::USE_SERVANT_MANAGER && + this->request_processing_ != PortableServer::USE_DEFAULT_SERVANT) + return -1; + + // USE_ACTIVE_OBJECT_MAP_ONLY requires the RETAIN policy. + if (this->request_processing_ == PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY) + if (this->servant_retention_ != PortableServer::RETAIN) + return -1; + + // USE_DEFAULT_SERVANT requires the MULTIPLE_ID policy. + if (this->request_processing_ == PortableServer::USE_DEFAULT_SERVANT) + if (this->id_uniqueness_ != PortableServer::MULTIPLE_ID) + return -1; + + // IMPLICIT_ACTIVATION requires the SYSTEM_ID and RETAIN policies. + if (this->implicit_activation_ == PortableServer::IMPLICIT_ACTIVATION) + if (this->servant_retention_ != PortableServer::RETAIN || + this->id_assignment_ != PortableServer::SYSTEM_ID) + return -1; + + return 0; } void @@ -328,7 +381,7 @@ TAO_POA_Policies::parse_policy (const PortableServer::Policy_ptr policy, { PortableServer::ThreadPolicy_var thread = PortableServer::ThreadPolicy::_narrow (policy, env); - if (!CORBA::is_nil (thread)) + if (!CORBA::is_nil (thread.in ())) { this->thread_ = thread->value (env); return; @@ -336,11 +389,11 @@ TAO_POA_Policies::parse_policy (const PortableServer::Policy_ptr policy, else { env.clear (); - } + } PortableServer::LifespanPolicy_var lifespan = PortableServer::LifespanPolicy::_narrow (policy, env); - if (!CORBA::is_nil (lifespan)) + if (!CORBA::is_nil (lifespan.in ())) { this->lifespan_ = lifespan->value (env); return; @@ -348,11 +401,11 @@ TAO_POA_Policies::parse_policy (const PortableServer::Policy_ptr policy, else { env.clear (); - } + } PortableServer::IdUniquenessPolicy_var id_uniqueness = PortableServer::IdUniquenessPolicy::_narrow (policy, env); - if (!CORBA::is_nil (id_uniqueness)) + if (!CORBA::is_nil (id_uniqueness.in ())) { this->id_uniqueness_ = id_uniqueness->value (env); return; @@ -360,11 +413,11 @@ TAO_POA_Policies::parse_policy (const PortableServer::Policy_ptr policy, else { env.clear (); - } + } PortableServer::IdAssignmentPolicy_var id_assignment = PortableServer::IdAssignmentPolicy::_narrow (policy, env); - if (!CORBA::is_nil (id_assignment)) + if (!CORBA::is_nil (id_assignment.in ())) { this->id_assignment_ = id_assignment->value (env); return; @@ -372,11 +425,11 @@ TAO_POA_Policies::parse_policy (const PortableServer::Policy_ptr policy, else { env.clear (); - } + } PortableServer::ImplicitActivationPolicy_var implicit_activation = PortableServer::ImplicitActivationPolicy::_narrow (policy, env); - if (!CORBA::is_nil (implicit_activation)) + if (!CORBA::is_nil (implicit_activation.in ())) { this->implicit_activation_ = implicit_activation->value (env); return; @@ -384,11 +437,11 @@ TAO_POA_Policies::parse_policy (const PortableServer::Policy_ptr policy, else { env.clear (); - } + } PortableServer::ServantRetentionPolicy_var servant_retention = PortableServer::ServantRetentionPolicy::_narrow (policy, env); - if (!CORBA::is_nil (servant_retention)) + if (!CORBA::is_nil (servant_retention.in ())) { this->servant_retention_ = servant_retention->value (env); return; @@ -396,11 +449,11 @@ TAO_POA_Policies::parse_policy (const PortableServer::Policy_ptr policy, else { env.clear (); - } + } PortableServer::RequestProcessingPolicy_var request_processing = PortableServer::RequestProcessingPolicy::_narrow (policy, env); - if (!CORBA::is_nil (request_processing)) + if (!CORBA::is_nil (request_processing.in ())) { this->request_processing_ = request_processing->value (env); return; @@ -408,7 +461,7 @@ TAO_POA_Policies::parse_policy (const PortableServer::Policy_ptr policy, else { env.clear (); - } + } CORBA::Exception *exception = new PortableServer::POA::InvalidPolicy; env.exception (exception); @@ -508,8 +561,8 @@ TAO_POA::TAO_POA (const TAO_POA::String &adapter_name, poa_manager_ (poa_manager), policies_ (policies), parent_ (parent), - active_object_table_ (new TAO_Object_Table), - delete_active_object_table_ (1), + active_object_map_ (new TAO_Object_Table), + delete_active_object_map_ (1), adapter_activator_ (), servant_activator_ (), servant_locator_ (), @@ -517,10 +570,11 @@ TAO_POA::TAO_POA (const TAO_POA::String &adapter_name, children_ (), lock_ (), closing_down_ (0), - counter_ (0) + counter_ (0), + creation_time_ (ACE_OS::gettimeofday ()) { this->set_complete_name (); - + // Register self with manager this->poa_manager_.register_poa (this, env); } @@ -529,14 +583,14 @@ TAO_POA::TAO_POA (const TAO_POA::String &adapter_name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, TAO_POA *parent, - TAO_Object_Table &active_object_table, + TAO_Object_Table &active_object_map, CORBA::Environment &env) : name_ (adapter_name), poa_manager_ (poa_manager), policies_ (policies), parent_ (parent), - active_object_table_ (&active_object_table), - delete_active_object_table_ (0), + active_object_map_ (&active_object_map), + delete_active_object_map_ (0), adapter_activator_ (), servant_activator_ (), servant_locator_ (), @@ -544,7 +598,8 @@ TAO_POA::TAO_POA (const TAO_POA::String &adapter_name, children_ (), lock_ (), closing_down_ (0), - counter_ (0) + counter_ (0), + creation_time_ (ACE_OS::gettimeofday ()) { this->set_complete_name (); @@ -571,24 +626,24 @@ TAO_POA::clone (const TAO_POA::String &adapter_name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, TAO_POA *parent, - TAO_Object_Table &active_object_table, + TAO_Object_Table &active_object_map, CORBA::Environment &env) { return new TAO_POA (adapter_name, poa_manager, policies, parent, - active_object_table, + active_object_map, env); } TAO_POA::~TAO_POA (void) { - if (this->delete_active_object_table_) - delete active_object_table_; + if (this->delete_active_object_map_) + delete active_object_map_; - // Remove POA from the POAManager - // + // Remove POA from the POAManager + // // Note: Errors are ignored here since there is nothing we can do // about them // @@ -605,7 +660,7 @@ TAO_POA::lock (void) PortableServer::POA_ptr TAO_POA::create_POA (const char *adapter_name, PortableServer::POAManager_ptr poa_manager, - const PortableServer::PolicyList& policies, + const PortableServer::PolicyList &policies, CORBA::Environment &env) { // If any of the policy objects specified are not valid for the ORB @@ -626,7 +681,7 @@ TAO_POA::create_POA (const char *adapter_name, TAO_POA_Manager *poa_manager_impl = 0; if (CORBA::is_nil (poa_manager)) { - poa_manager_impl = this->poa_manager_.clone (); + poa_manager_impl = this->poa_manager_.clone (); } else { @@ -637,10 +692,12 @@ TAO_POA::create_POA (const char *adapter_name, env.exception (exception); return PortableServer::POA::_nil (); } - - poa_manager_impl = ACE_dynamic_cast (TAO_POA_Manager *, servant); + + void *ptr = servant->_downcast (servant->_interface_repository_id ()); + POA_PortableServer::POAManager *mgr = (POA_PortableServer::POAManager *) ptr; + poa_manager_impl = ACE_dynamic_cast (TAO_POA_Manager *, mgr); } - + TAO_POA *result = this->create_POA (adapter_name, *poa_manager_impl, tao_policies, @@ -689,7 +746,7 @@ TAO_POA::create_POA_i (const TAO_POA::String &adapter_name, env.exception (exception); return 0; } - + // // Child was not found // @@ -704,7 +761,7 @@ TAO_POA::create_POA_i (const TAO_POA::String &adapter_name, policies, this, env)); - + if (env.exception () != 0) return 0; @@ -737,7 +794,7 @@ TAO_POA::create_POA_i (const TAO_POA::String &adapter_name, // Find the topmost name TAO_POA::String topmost_poa_name; TAO_POA::String tail_poa_name; - this->parse_poa_name (adapter_name, + this->parse_poa_name (adapter_name, topmost_poa_name, tail_poa_name, env); @@ -752,8 +809,8 @@ TAO_POA::create_POA_i (const TAO_POA::String &adapter_name, poa_manager, policies, env); - } - + } + // // We are not the topmost POA // @@ -772,7 +829,7 @@ TAO_POA::create_POA_i (const TAO_POA::String &adapter_name, if (env.exception () != 0) return 0; } - + // At this point, the intermediate child POA was either found or // created return child_poa->create_POA (tail_poa_name, @@ -788,7 +845,7 @@ TAO_POA::find_POA (const char *adapter_name, CORBA::Environment &env) { TAO_POA::String name (adapter_name); - + TAO_POA *result = this->find_POA (name, activate_it, env); @@ -825,7 +882,7 @@ TAO_POA::find_POA_i (const TAO_POA::String &adapter_name, // Check if we are the POA the user is looking for if (adapter_name == this->name_) return this; - + return this->find_POA_i_optimized (adapter_name, activate_it, env); @@ -843,8 +900,8 @@ TAO_POA::find_POA_i_optimized (const TAO_POA::String &adapter_name, // specified name (relative to the target POA), that child POA // is returned. TAO_POA *child_poa = 0; - int result = this->children_.find (adapter_name, child_poa); - + int result = this->children_.find (adapter_name, child_poa); + // Child was found if (result != -1) return child_poa; @@ -852,19 +909,19 @@ TAO_POA::find_POA_i_optimized (const TAO_POA::String &adapter_name, // // Child was not found // - + // If a child POA with the specified name does not exist and the // value of the activate_it parameter is TRUE, the target POA's // AdapterActivator, if one exists, is invoked, and, if it // successfully activates the child POA, that child POA is // returned. - if (activate_it && !CORBA::is_nil (this->adapter_activator_)) + if (activate_it && !CORBA::is_nil (this->adapter_activator_.in ())) { PortableServer::POA_var self = this->_this (env); // Check for exceptions if (env.exception () != 0) return 0; - + CORBA::Boolean success = this->adapter_activator_->unknown_adapter (self.in (), adapter_name.c_str (), @@ -872,19 +929,19 @@ TAO_POA::find_POA_i_optimized (const TAO_POA::String &adapter_name, // Check for exceptions if (env.exception () != 0) return 0; - + // On success if (success) { // Search the children table again - result = this->children_.find (adapter_name, child_poa); - + result = this->children_.find (adapter_name, child_poa); + // Child was found if (result != -1) return child_poa; } } - + // Otherwise, the AdapterNonExistent exception is raised. CORBA::Exception *exception = new PortableServer::POA::AdapterNonExistent; env.exception (exception); @@ -897,7 +954,7 @@ TAO_POA::find_POA_i_optimized (const TAO_POA::String &adapter_name, // Find the topmost name TAO_POA::String topmost_poa_name; TAO_POA::String tail_poa_name; - this->parse_poa_name (adapter_name, + this->parse_poa_name (adapter_name, topmost_poa_name, tail_poa_name, env); @@ -911,15 +968,15 @@ TAO_POA::find_POA_i_optimized (const TAO_POA::String &adapter_name, return this->find_POA_i (tail_poa_name, activate_it, env); - } - + } + // // We are not the topmost POA // // Try to find the topmost child TAO_POA *child_poa; - int result = this->children_.find (topmost_poa_name, child_poa); + int result = this->children_.find (topmost_poa_name, child_poa); // Child was not found if (result != 0) @@ -1006,10 +1063,10 @@ TAO_POA::destroy_i (CORBA::Boolean etherealize_objects, { if (this->policies ().servant_retention () == PortableServer::RETAIN && this->policies ().request_processing () == PortableServer::USE_SERVANT_MANAGER && - !CORBA::is_nil (this->servant_activator_)) + !CORBA::is_nil (this->servant_activator_.in ())) { - for (TAO_Object_Table::iterator iterator = this->active_object_table ().begin (); - iterator != this->active_object_table ().end () && env.exception () == 0; + for (TAO_Object_Table::iterator iterator = this->active_object_map ().begin (); + iterator != this->active_object_map ().end () && env.exception () == 0; iterator++) { PortableServer::POA_var self = this->_this (env); @@ -1033,7 +1090,7 @@ TAO_POA::destroy_i (CORBA::Boolean etherealize_objects, // destroying the POAs. ACE_UNUSED_ARG (wait_for_completion); - + // Commit suicide delete this; } @@ -1043,12 +1100,12 @@ TAO_POA::delete_child (const TAO_POA::String &child, CORBA::Environment &env) { // If we are not closing down, we must remove this child from our - // collection. + // collection. if (!this->closing_down_) - { + { // Lock access to the POA for the duration of this transaction TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env); - + this->delete_child_i (child, env); } @@ -1077,9 +1134,9 @@ TAO_POA::policies (void) } TAO_Object_Table & -TAO_POA::active_object_table (void) +TAO_POA::active_object_map (void) { - return *this->active_object_table_; + return *this->active_object_map_; } PortableServer::ServantManager_ptr @@ -1087,7 +1144,7 @@ TAO_POA::get_servant_manager (CORBA::Environment &env) { // Lock access to the POA for the duration of this transaction TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), PortableServer::ServantManager::_nil (), env); - + return this->get_servant_manager_i (env); } @@ -1107,9 +1164,9 @@ TAO_POA::get_servant_manager_i (CORBA::Environment &env) // POA. If no servant manager has been associated with the POA, it // returns a null reference. if (this->policies ().servant_retention () == PortableServer::RETAIN) - return PortableServer::ServantManager::_duplicate (this->servant_activator_); + return PortableServer::ServantManager::_duplicate (this->servant_activator_.in ()); else - return PortableServer::ServantManager::_duplicate (this->servant_locator_); + return PortableServer::ServantManager::_duplicate (this->servant_locator_.in ()); } void @@ -1118,7 +1175,7 @@ TAO_POA::set_servant_manager (PortableServer::ServantManager_ptr imgr, { // Lock access to the POA for the duration of this transaction TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env); - + this->set_servant_manager_i (imgr, env); } @@ -1141,7 +1198,7 @@ TAO_POA::set_servant_manager_i (PortableServer::ServantManager_ptr imgr, if (this->policies ().servant_retention () == PortableServer::RETAIN) { this->servant_activator_ = PortableServer::ServantActivator::_narrow (imgr, env); - if (CORBA::is_nil (this->servant_activator_)) + if (CORBA::is_nil (this->servant_activator_.in ())) { CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; env.exception (exception); @@ -1151,7 +1208,7 @@ TAO_POA::set_servant_manager_i (PortableServer::ServantManager_ptr imgr, else { this->servant_locator_ = PortableServer::ServantLocator::_narrow (imgr, env); - if (CORBA::is_nil (this->servant_locator_)) + if (CORBA::is_nil (this->servant_locator_.in ())) { CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; env.exception (exception); @@ -1165,7 +1222,7 @@ TAO_POA::get_servant (CORBA::Environment &env) { // Lock access to the POA for the duration of this transaction TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); - + return this->get_servant_i (env); } @@ -1180,7 +1237,7 @@ TAO_POA::get_servant_i (CORBA::Environment &env) env.exception (exception); return 0; } - + // This operation returns the default servant associated with the // POA. if (this->default_servant_ != 0) @@ -1203,7 +1260,7 @@ TAO_POA::set_servant (PortableServer::Servant servant, { // Lock access to the POA for the duration of this transaction TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env); - + this->set_servant_i (servant, env); } @@ -1256,7 +1313,7 @@ TAO_POA::activate_object_i (PortableServer::Servant servant, // already in the Active Object Map, the ServantAlreadyActive // exception is raised. if (this->policies ().id_uniqueness () == PortableServer::UNIQUE_ID && - this->active_object_table ().find (servant) != -1) + this->active_object_map ().find (servant) != -1) { CORBA::Exception *exception = new PortableServer::POA::ServantAlreadyActive; env.exception (exception); @@ -1268,7 +1325,7 @@ TAO_POA::activate_object_i (PortableServer::Servant servant, // Object Map. The Object Id is returned. PortableServer::ObjectId_var new_id = this->create_object_id (); - if (this->active_object_table ().bind (new_id.in (), servant) == -1) + if (this->active_object_map ().bind (new_id.in (), servant) == -1) { CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); env.exception (exception); @@ -1280,7 +1337,7 @@ TAO_POA::activate_object_i (PortableServer::Servant servant, } void -TAO_POA::activate_object_with_id (const PortableServer::ObjectId& id, +TAO_POA::activate_object_with_id (const PortableServer::ObjectId &id, PortableServer::Servant servant, CORBA::Environment &env) { @@ -1293,7 +1350,7 @@ TAO_POA::activate_object_with_id (const PortableServer::ObjectId& id, } void -TAO_POA::activate_object_with_id_i (const PortableServer::ObjectId& id, +TAO_POA::activate_object_with_id_i (const PortableServer::ObjectId &id, PortableServer::Servant servant, CORBA::Environment &env) { @@ -1326,7 +1383,7 @@ TAO_POA::activate_object_with_id_i (const PortableServer::ObjectId& id, // If the CORBA object denoted by the Object Id value is already // active in this POA (there is a servant bound to it in the Active // Object Map), the ObjectAlreadyActive exception is raised. - if (this->active_object_table ().find (id) != -1) + if (this->active_object_map ().find (id) != -1) { CORBA::Exception *exception = new PortableServer::POA::ObjectAlreadyActive; env.exception (exception); @@ -1337,7 +1394,7 @@ TAO_POA::activate_object_with_id_i (const PortableServer::ObjectId& id, // the Active Object Map, the ServantAlreadyActive exception is // raised. if (this->policies ().id_uniqueness () == PortableServer::UNIQUE_ID && - this->active_object_table ().find (servant) != -1) + this->active_object_map ().find (servant) != -1) { CORBA::Exception *exception = new PortableServer::POA::ServantAlreadyActive; env.exception (exception); @@ -1347,7 +1404,7 @@ TAO_POA::activate_object_with_id_i (const PortableServer::ObjectId& id, // Otherwise, the activate_object_with_id operation enters an // association between the specified Object Id and the specified // servant in the Active Object Map. - if (this->active_object_table ().bind (id, servant) == -1) + if (this->active_object_map ().bind (id, servant) == -1) { CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); env.exception (exception); @@ -1358,7 +1415,7 @@ TAO_POA::activate_object_with_id_i (const PortableServer::ObjectId& id, } void -TAO_POA::deactivate_object (const PortableServer::ObjectId& oid, +TAO_POA::deactivate_object (const PortableServer::ObjectId &oid, CORBA::Environment &env) { // Lock access to the POA for the duration of this transaction @@ -1369,7 +1426,7 @@ TAO_POA::deactivate_object (const PortableServer::ObjectId& oid, } void -TAO_POA::deactivate_object_i (const PortableServer::ObjectId& oid, +TAO_POA::deactivate_object_i (const PortableServer::ObjectId &oid, CORBA::Environment &env) { // This operation requires the RETAIN policy; if not present, the @@ -1385,7 +1442,7 @@ TAO_POA::deactivate_object_i (const PortableServer::ObjectId& oid, // by the oid parameter and its servant to be removed from the // Active Object Map. PortableServer::Servant servant = 0; - int result = this->active_object_table ().unbind (oid, servant); + int result = this->active_object_map ().unbind (oid, servant); // If there is no active object associated with the specified Object // Id, the operation raises an ObjectNotActive exception. @@ -1412,7 +1469,7 @@ TAO_POA::deactivate_object_i (const PortableServer::ObjectId& oid, if (env.exception () != 0) return; - if (!CORBA::is_nil (this->servant_activator_)) + if (!CORBA::is_nil (this->servant_activator_.in ())) this->servant_activator_->etherealize (oid, self.in (), servant, @@ -1504,7 +1561,7 @@ TAO_POA::servant_to_id (PortableServer::Servant servant, // Lock access to the POA for the duration of this transaction TAO_POA_WRITE_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); - return this->servant_to_id_i (servant, + return this->servant_to_id_i (servant, env); } @@ -1523,14 +1580,14 @@ TAO_POA::servant_to_id_i (PortableServer::Servant servant, env.exception (exception); return 0; } - + // This operation has three possible behaviors. // If the POA has the UNIQUE_ID policy and the specified servant is // active, the Object Id associated with that servant is returned. PortableServer::ObjectId_var id; if (this->policies ().id_uniqueness () == PortableServer::UNIQUE_ID && - this->active_object_table ().find (servant, id.out ()) != -1) + this->active_object_map ().find (servant, id.out ()) != -1) { return id._retn (); } @@ -1543,11 +1600,11 @@ TAO_POA::servant_to_id_i (PortableServer::Servant servant, if (this->policies ().implicit_activation () == PortableServer::IMPLICIT_ACTIVATION) { if (this->policies ().id_uniqueness () == PortableServer::MULTIPLE_ID || - this->active_object_table ().find (servant) != 0) + this->active_object_map ().find (servant) != 0) { PortableServer::ObjectId_var new_id = this->create_object_id (); - if (this->active_object_table ().bind (new_id.in (), servant) == -1) + if (this->active_object_map ().bind (new_id.in (), servant) == -1) { CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); env.exception (exception); @@ -1613,11 +1670,17 @@ TAO_POA::reference_to_servant (CORBA::Object_ptr reference, PortableServer::ObjectId_var id; TAO_POA::String poa_name; CORBA::Boolean persistent = CORBA::B_FALSE; - - int result = this->parse_key (key.in (), poa_name, id.out (), persistent); - if (result != 0 || - poa_name != this->complete_name () || - persistent != this->persistent ()) + ACE_Time_Value poa_creation_time; + + int result = this->parse_key (key.in (), + poa_name, + id.out (), + persistent, + poa_creation_time); + if (result != 0 || + poa_name != this->complete_name () || + persistent != this->persistent () || + !this->persistent () && poa_creation_time != this->creation_time_) { CORBA::Exception *exception = new PortableServer::POA::WrongAdapter; env.exception (exception); @@ -1634,7 +1697,7 @@ TAO_POA::reference_to_servant (CORBA::Object_ptr reference, { // Lock access to the POA for the duration of this transaction TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); - + if (this->default_servant_ != 0) { return this->default_servant_; @@ -1669,11 +1732,17 @@ TAO_POA::reference_to_id (CORBA::Object_ptr reference, PortableServer::ObjectId_var id; TAO_POA::String poa_name; CORBA::Boolean persistent = CORBA::B_FALSE; - - int result = this->parse_key (key.in (), poa_name, id.out (), persistent); - if (result != 0 || - poa_name != this->complete_name () || - persistent != this->persistent ()) + ACE_Time_Value poa_creation_time; + + int result = this->parse_key (key.in (), + poa_name, + id.out (), + persistent, + poa_creation_time); + if (result != 0 || + poa_name != this->complete_name () || + persistent != this->persistent () || + !this->persistent () && poa_creation_time != this->creation_time_) { CORBA::Exception *exception = new PortableServer::POA::WrongAdapter; env.exception (exception); @@ -1691,8 +1760,8 @@ TAO_POA::id_to_servant (const PortableServer::ObjectId &oid, { // Lock access to the POA for the duration of this transaction TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), 0, env); - - return this->id_to_servant_i (oid, + + return this->id_to_servant_i (oid, env); } @@ -1713,7 +1782,7 @@ TAO_POA::id_to_servant_i (const PortableServer::ObjectId &oid, // specified Object Id value. If the Object Id value is not active // in the POA, an ObjectNotActive exception is raised. PortableServer::Servant servant = 0; - if (this->active_object_table ().find (oid, servant) != -1) + if (this->active_object_map ().find (oid, servant) != -1) { return servant; } @@ -1758,107 +1827,448 @@ TAO_POA::the_POAManager (CORBA::Environment &env) PortableServer::AdapterActivator_ptr TAO_POA::the_activator (CORBA::Environment &env) { + ACE_UNUSED_ARG (env); + return PortableServer::AdapterActivator::_duplicate (this->adapter_activator_); } void -TAO_POA::the_activator (PortableServer::AdapterActivator_ptr adapter_activator, +TAO_POA::the_activator (PortableServer::AdapterActivator_ptr adapter_activator, CORBA::Environment &env) { + ACE_UNUSED_ARG (env); + this->adapter_activator_ = PortableServer::AdapterActivator::_duplicate (adapter_activator); } -void -TAO_POA::dispatch_servant (const TAO::ObjectKey &key, - CORBA::ServerRequest &req, - void *context, - CORBA::Environment &env) +TAO_POA * +TAO_POA::locate_poa_i (const TAO::ObjectKey &key, + PortableServer::ObjectId_out id, + CORBA::Environment &env) { - // Lock access to the POAManager for the duration of this transaction - TAO_POA_READ_GUARD (ACE_Lock, monitor, this->lock (), env); + TAO_POA::String poa_name; + CORBA::Boolean persistent = CORBA::B_FALSE; + ACE_Time_Value poa_creation_time; - PortableServer::Servant servant = this->locate_servant_i (key, env); - - if (env.exception () != 0 || servant == 0) - return; + int result = this->parse_key (key, + poa_name, + id, + persistent, + poa_creation_time); + if (result != 0) + { + CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); + env.exception (exception); + return 0; + } + + TAO_POA *poa = this->find_POA_i (poa_name, + persistent, + env); + if (env.exception () != 0) + return 0; + + // Make sure it is not an "old" objectId + if (!poa->persistent () && + poa->creation_time () != poa_creation_time) + { + CORBA::Exception *exception = new CORBA::OBJECT_NOT_EXIST (CORBA::COMPLETED_NO); + env.exception (exception); + return 0; + } - servant->dispatch (req, context, env); + return poa; } -PortableServer::Servant +int TAO_POA::locate_servant (const TAO::ObjectKey &key, CORBA::Environment &env) { // Lock access to the POAManager for the duration of this transaction - TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), ERROR, env); + TAO_POA_READ_GUARD_RETURN (ACE_Lock, monitor, this->lock (), -1, env); return this->locate_servant_i (key, env); } -PortableServer::Servant +int TAO_POA::locate_servant_i (const TAO::ObjectKey &key, CORBA::Environment &env) { PortableServer::ObjectId_var id; - TAO_POA::String poa_name; - CORBA::Boolean persistent = CORBA::B_FALSE; - int result = this->parse_key (key, poa_name, id.out (), persistent); - if (result != 0) + TAO_POA *poa = this->locate_poa_i (key, + id.out (), + env); + if (env.exception () != 0) + return -1; + + // If the POA has the RETAIN policy, the POA looks in the Active + // Object Map to find if there is a servant associated with the + // Object Id value from the request. If such a servant exists, + // return 0. + if (poa->policies ().servant_retention () == PortableServer::RETAIN) { - CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); - env.exception (exception); - return 0; + PortableServer::Servant servant = poa->id_to_servant_i (id.in (), env); + + if (env.exception () != 0) + return -1; + + // Success + if (servant != 0) + return 0; } - TAO_POA *poa = this->find_POA_i (poa_name, - persistent, - env); + // If the POA has the NON_RETAIN policy or has the RETAIN policy but + // didn't find a servant in the Active Object Map, the POA takes the + // following actions: + // If the USE_ACTIVE_OBJECT_MAP_ONLY policy is in effect, the POA raises + // the OBJECT_NOT_EXIST system exception. + if (poa->policies ().request_processing () == PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY) + return -1; + + // If the POA has the USE_DEFAULT_SERVANT policy, a default servant + // has been associated with the POA, return 0. If no servant has + // been associated with the POA, return -1. + if (poa->policies ().request_processing () == PortableServer::USE_DEFAULT_SERVANT) + { + if (poa->default_servant_ == 0) + return -1; + else + // Success + return 0; + } + + // If the POA has the USE_SERVANT_MANAGER policy, a servant manager + // has been associated with the POA, return 0. If no servant manager + // has been associated with the POA, return -1. + if (poa->policies ().request_processing () == PortableServer::USE_SERVANT_MANAGER) + { + if (CORBA::is_nil (poa->servant_activator_.in ()) && + CORBA::is_nil (poa->servant_locator_.in ())) + return -1; + else + // Success + return 0; + } + + // Failure + return -1; +} + +PortableServer::Servant +TAO_POA::locate_poa_and_servant_i (const TAO::ObjectKey &key, + const char *operation, + PortableServer::ObjectId_out id, + TAO_POA *&poa_impl, + CORBA::Environment &env) +{ + poa_impl = this->locate_poa_i (key, + id, + env); if (env.exception () != 0) return 0; - PortableServer::Servant servant = poa->id_to_servant_i (id.in (), env); - + PortableServer::POA_var poa = poa_impl->_this (env); if (env.exception () != 0) return 0; - return servant; + // If the POA has the RETAIN policy, the POA looks in the Active + // Object Map to find if there is a servant associated with the + // Object Id value from the request. If such a servant exists, the + // POA invokes the appropriate method on the servant. + if (poa_impl->policies ().servant_retention () == PortableServer::RETAIN) + { + PortableServer::Servant servant = poa_impl->id_to_servant_i (*id.ptr (), env); + + if (env.exception () != 0) + return 0; + + // Success + if (servant != 0) + return servant; + } + + // If the POA has the NON_RETAIN policy or has the RETAIN policy but + // didn't find a servant in the Active Object Map, the POA takes the + // following actions: + + // If the USE_ACTIVE_OBJECT_MAP_ONLY policy is in effect, the POA raises + // the OBJECT_NOT_EXIST system exception. + if (poa_impl->policies ().request_processing () == PortableServer::USE_ACTIVE_OBJECT_MAP_ONLY) + { + CORBA::Exception *exception = new CORBA::OBJECT_NOT_EXIST (CORBA::COMPLETED_NO); + env.exception (exception); + return 0; + } + + // If the POA has the USE_DEFAULT_SERVANT policy, a default servant + // has been associated with the POA so the POA will invoke the + // appropriate method on that servant. If no servant has been + // associated with the POA, the POA raises the OBJ_ADAPTER system + // exception. + if (poa_impl->policies ().request_processing () == PortableServer::USE_DEFAULT_SERVANT) + { + if (poa_impl->default_servant_ == 0) + { + CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); + env.exception (exception); + return 0; + } + else + { + // Success + return poa_impl->default_servant_; + } + } + + // If the POA has the USE_SERVANT_MANAGER policy, a servant manager + // has been associated with the POA so the POA will invoke incarnate + // or preinvoke on it to find a servant that may handle the + // request. (The choice of method depends on the NON_RETAIN or + // RETAIN policy of the POA.) If no servant manager has been + // associated with the POA, the POA raises the OBJ_ADAPTER system + // exception. + // + // If a servant manager is located and invoked, but the servant + // manager is not directly capable of incarnating the object, it + // (the servant manager) may deal with the circumstance in a variety + // of ways, all of which are the application's responsibility. Any + // system exception raised by the servant manager will be returned + // to the client in the reply. In addition to standard CORBA + // exceptions, a servant manager is capable of raising a + // ForwardRequest exception. This exception includes an object + // reference. + // + if (poa_impl->policies ().request_processing () == PortableServer::USE_SERVANT_MANAGER) + { + if (CORBA::is_nil (poa_impl->servant_activator_.in ()) && + CORBA::is_nil (poa_impl->servant_locator_.in ())) + { + CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); + env.exception (exception); + return 0; + } + + if (poa_impl->policies ().servant_retention () == PortableServer::RETAIN) + { + // @@ + // Invocations of incarnate on the servant manager are serialized. + // Invocations of etherealize on the servant manager are serialized. + // Invocations of incarnate and etherealize on the servant manager are mutually exclusive. + PortableServer::Servant servant = poa_impl->servant_activator_->incarnate (*id.ptr (), + poa.in (), + env); + if (env.exception () != 0 || servant == 0) + return 0; + + // If the incarnate operation returns a servant that is + // already active for a different Object Id and if the POA + // also has the UNIQUE_ID policy, the incarnate has violated + // the POA policy and is considered to be in error. The POA + // will raise an OBJ_ADAPTER system exception for the + // request. + if (poa_impl->policies ().id_uniqueness () == PortableServer::UNIQUE_ID && + poa_impl->active_object_map ().find (servant) != -1) + { + CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); + env.exception (exception); + return 0; + } + + // The POA enters the returned Servant value into the Active + // Object Map so that subsequent requests with the same + // ObjectId value will be delivered directly to that servant + // without invoking the servant manager. + if (poa_impl->active_object_map ().bind (*id.ptr (), servant) == -1) + { + CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); + env.exception (exception); + return 0; + } + + // Success + return servant; + } + else + // + // Don't retain servant + // + { + // No serialization of invocations of preinvoke or + // postinvoke may be assumed; there may be multiple + // concurrent invocations of preinvoke for the same + // ObjectId. + // + // The same thread will be used to preinvoke the object, + // process the request, and postinvoke the object. + // + PortableServer::ServantLocator::Cookie cookie; + PortableServer::Servant servant = poa_impl->servant_locator_->preinvoke (*id.ptr (), + poa.in (), + operation, + cookie, + env); + if (env.exception () != 0 || servant == 0) + return 0; + + // Remember the cookie + TAO_ORB_Core *orb_core = TAO_ORB_Core_instance (); + TAO_POA_Current *poa_current = orb_core->poa_current (); + poa_current->locator_cookie (cookie); + + // Success + return servant; + } + } + + // Failure + CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); + env.exception (exception); + return 0; +} + +void +TAO_POA::dispatch_servant (const TAO::ObjectKey &key, + CORBA::ServerRequest &req, + void *context, + CORBA::Environment &env) +{ + // Lock access to the POAManager for the duration of this transaction + TAO_POA_READ_GUARD (ACE_Lock, monitor, this->lock (), env); + + this->dispatch_servant_i (key, req, context, env); +} + +void +TAO_POA::dispatch_servant_i (const TAO::ObjectKey &key, + CORBA::ServerRequest &req, + void *context, + CORBA::Environment &env) +{ + PortableServer::ObjectId_var id; + TAO_POA *poa = 0; + // const char *operation = req.operation (); + const char *operation = req.op_name (); + + PortableServer::Servant servant = this->locate_poa_and_servant_i (key, + operation, + id.out (), + poa, + env); + if (env.exception () != 0 || servant == 0) + return; + + // Setup for upcall + poa->pre_invoke (key, + id.in (), + env); + + servant->_dispatch (req, + context, + env); + + // Cleanup from upcall + poa->post_invoke (servant, + operation, + env); +} + +void +TAO_POA::pre_invoke (const TAO::ObjectKey &key, + const PortableServer::ObjectId &id, + CORBA::Environment &env) +{ + ACE_UNUSED_ARG (env); + + TAO_ORB_Core *orb_core = TAO_ORB_Core_instance (); + TAO_POA_Current *poa_current = orb_core->poa_current (); + + poa_current->POA_impl (this); + poa_current->object_key (key); + poa_current->object_id (id); + poa_current->in_upcall (1); +} + +void +TAO_POA::post_invoke (PortableServer::Servant servant, + const char *operation, + CORBA::Environment &env) +{ + TAO_ORB_Core *orb_core = TAO_ORB_Core_instance (); + TAO_POA_Current *poa_current = orb_core->poa_current (); + + PortableServer::ServantLocator::Cookie cookie = poa_current->locator_cookie (); + + PortableServer::POA_var poa = poa_current->get_POA (env); + + if (cookie != 0) + this->servant_locator_->postinvoke (poa_current->object_id (), + poa.in (), + operation, + cookie, + servant, + env); + // Reset current + poa_current->clear (); +} + +const ACE_Time_Value & +TAO_POA::creation_time (void) +{ + return this->creation_time_; } int -TAO_POA::parse_key (const TAO::ObjectKey &key, +TAO_POA::parse_key (const TAO::ObjectKey &key, TAO_POA::String &poa_name, PortableServer::ObjectId_out id, - CORBA::Boolean &persistent) + CORBA::Boolean &persistent, + ACE_Time_Value &poa_creation_time) { // Grab the id buffer TAO_POA::String object_key (TAO_POA::ObjectKey_to_const_string (key)); - - // Try to find the first separator - int first_token_position = object_key.find (TAO_POA::name_separator ()); + // Try to find the first separator + int first_token_position = object_key.find (TAO_POA::name_separator (), + 0); // If not found, the name is not correct if (first_token_position == TAO_POA::String::npos) - { - return -1; - } + return -1; + else + first_token_position += 0; // Try to find the second separator - int second_token_position = object_key.rfind (TAO_POA::name_separator ()); + int second_token_position = object_key.find (TAO_POA::name_separator (), + first_token_position + 1); + // If not found, the name is not correct + if (second_token_position == TAO_POA::String::npos) + return -1; + else + second_token_position += first_token_position + 1; + + // Try to find the third separator + int third_token_position = object_key.find (TAO_POA::name_separator (), + second_token_position + 1); + // If not found, the name is not correct + if (third_token_position == TAO_POA::String::npos) + return -1; + else + third_token_position += second_token_position + 1; + + // Try to find the last separator + int last_token_position = object_key.rfind (TAO_POA::name_separator ()); // If not found or the token are not distinct, the name is not correct - if (second_token_position == TAO_POA::String::npos || - first_token_position == second_token_position) - { - return -1; - } + if (last_token_position == TAO_POA::String::npos || + third_token_position == last_token_position) + return -1; // Take the substring from 0 to first_token_position for the // object_key_type. int starting_at = 0; int now_many = first_token_position - starting_at; - TAO_POA::String object_key_type = object_key.substr (starting_at, + TAO_POA::String object_key_type = object_key.substr (starting_at, now_many); if (object_key_type == this->persistent_key_type ()) persistent = 1; @@ -1869,22 +2279,38 @@ TAO_POA::parse_key (const TAO::ObjectKey &key, return -1; // Take the substring from (first_token_position + separator_length) - // to second_token_position for the POA name + // to second_token_position for the seconds starting_at = first_token_position + TAO_POA::name_separator_length (); now_many = second_token_position - starting_at; + TAO_POA::String seconds = object_key.substr (starting_at, + now_many); + + // Take the substring from (second_token_position + separator_length) + // to third_token_position for the micro_seconds + starting_at = second_token_position + TAO_POA::name_separator_length (); + now_many = third_token_position - starting_at; + TAO_POA::String micro_seconds = object_key.substr (starting_at, + now_many); + + // Take the substring from (third_token_position + separator_length) + // to last_token_position for the POA name + starting_at = third_token_position + TAO_POA::name_separator_length (); + now_many = last_token_position - starting_at; poa_name = object_key.substr (starting_at, now_many); - // Take the substring from (second_token_position + + // Take the substring from (last_token_position + // separator_length) to length for the objectId - - starting_at = second_token_position + TAO_POA::name_separator_length (); + starting_at = last_token_position + TAO_POA::name_separator_length (); now_many = object_key.length () - starting_at; - TAO_POA::String objectId = object_key.substr (starting_at, + TAO_POA::String objectId = object_key.substr (starting_at, now_many); - + id = TAO_POA::string_to_ObjectId (objectId.c_str ()); + poa_creation_time.sec (::atol (seconds.c_str ())); + poa_creation_time.usec (::atol (micro_seconds.c_str ())); + // Success return 0; } @@ -1901,7 +2327,7 @@ TAO_POA::object_key_type (void) if (this->persistent ()) return TAO_POA::persistent_key_type (); else - return TAO_POA::transient_key_type (); + return TAO_POA::transient_key_type (); } const TAO_POA::String & @@ -1925,12 +2351,8 @@ TAO_POA::create_object_id (void) // 1. Locks are held when this method is called // 2. Size of octet == size of string element - // This is the maximum space require to convert the counter into a - // string - const int max_space_required_for_counter = 24; - - // Buffer for counter - char counter[max_space_required_for_counter]; + // Buffer for counter + char counter[TAO_POA::max_space_required_for_ulong]; // Convert counter into string ACE_OS::sprintf (counter, @@ -1939,9 +2361,9 @@ TAO_POA::create_object_id (void) // Calculate the required buffer size. // Note: 1 is for the null terminator - TAO_POA::String id = - this->name_ + - TAO_POA::id_separator () + + TAO_POA::String id = + this->name_ + + TAO_POA::id_separator () + counter; // Increment counter @@ -1954,11 +2376,30 @@ TAO_POA::create_object_id (void) TAO::ObjectKey * TAO_POA::create_object_key (const PortableServer::ObjectId &id) { + // Buffer for seconds + char seconds[TAO_POA::max_space_required_for_ulong]; + // Buffer for micro seconds + char micro_seconds[TAO_POA::max_space_required_for_ulong]; + + // Convert seconds into string + ACE_OS::sprintf (seconds, + "%d", + this->creation_time_.sec ()); + + // Convert micro seconds into string + ACE_OS::sprintf (micro_seconds, + "%d", + this->creation_time_.usec ()); + // Calculate the required buffer size. // Note: 1 is for the null terminator int buffer_size = this->object_key_type ().length () + TAO_POA::name_separator_length () + + ACE_OS::strlen (seconds) + + TAO_POA::name_separator_length () + + ACE_OS::strlen (micro_seconds) + + TAO_POA::name_separator_length () + this->complete_name_.length () + TAO_POA::name_separator_length () + id.length () + @@ -1972,9 +2413,13 @@ TAO_POA::create_object_key (const PortableServer::ObjectId &id) // Make an object key ACE_OS::sprintf ((CORBA::String) buffer, - "%s%c%s%c%s", + "%s%c%s%c%s%c%s%c%s", this->object_key_type ().c_str (), TAO_POA::name_separator (), + seconds, + TAO_POA::name_separator (), + micro_seconds, + TAO_POA::name_separator (), this->complete_name_.c_str (), TAO_POA::name_separator (), id_buffer); @@ -1988,7 +2433,7 @@ TAO_POA::create_object_key (const PortableServer::ObjectId &id) } int -TAO_POA::is_poa_generated_id (const PortableServer::ObjectId& id) +TAO_POA::is_poa_generated_id (const PortableServer::ObjectId &id) { // Grab the buffer const char *id_buffer = TAO_POA::ObjectId_to_const_string (id); @@ -2003,7 +2448,7 @@ TAO_POA::is_poa_generated_id (const PortableServer::ObjectId& id) } int -TAO_POA::is_poa_generated_key (const TAO::ObjectKey& key) +TAO_POA::is_poa_generated_key (const TAO::ObjectKey &key) { // Grab the buffer const char *id_buffer = TAO_POA::ObjectKey_to_const_string (key); @@ -2041,7 +2486,7 @@ TAO_POA::parse_poa_name (const TAO_POA::String &adapter_name, { // Try to find the name separator int token_position = adapter_name.find (TAO_POA::name_separator ()); - + // If not found, the name was a leaf, throw exception if (token_position == TAO_POA::String::npos) { @@ -2054,14 +2499,14 @@ TAO_POA::parse_poa_name (const TAO_POA::String &adapter_name, // If found, take the substring from 0 to token_position int starting_at = 0; int now_many = token_position - starting_at; - topmost_poa_name = adapter_name.substr (starting_at, + topmost_poa_name = adapter_name.substr (starting_at, now_many); // Take the substring from (token_position + separator_length) // to length starting_at = token_position + TAO_POA::name_separator_length (); now_many = adapter_name.length () - starting_at; - tail_poa_name = adapter_name.substr (starting_at, + tail_poa_name = adapter_name.substr (starting_at, now_many); } } @@ -2069,6 +2514,8 @@ TAO_POA::parse_poa_name (const TAO_POA::String &adapter_name, CORBA::String TAO_POA::the_name (CORBA::Environment &env) { + ACE_UNUSED_ARG (env); + return CORBA::string_dup (this->name_.c_str ()); } @@ -2097,7 +2544,7 @@ TAO_POA::ObjectId_to_string (const PortableServer::ObjectId &id) // Grab the id buffer CORBA::String id_buffer = (CORBA::String) &id[0]; - + // Create space and copy the contents return CORBA::string_dup (id_buffer); } @@ -2127,7 +2574,7 @@ TAO_POA::string_to_ObjectId (const char *id) // Create the buffer for the Id CORBA::Octet *buffer = PortableServer::ObjectId::allocbuf (id_length); - + // Copy contents ACE_OS::strcpy ((CORBA::String) buffer, id); @@ -2146,7 +2593,7 @@ TAO_POA::wstring_to_ObjectId (const wchar_t *id) // Create the buffer for the Id CORBA::Octet *buffer = PortableServer::ObjectId::allocbuf (id_length * sizeof CORBA::WChar); - + // Copy contents ACE_OS::strcpy ((CORBA::WString) buffer, id); @@ -2246,7 +2693,7 @@ TAO_POA::create_id_uniqueness_policy (PortableServer::IdUniquenessPolicyValue va PortableServer::IdUniquenessPolicy_var result = new_policy->_this (env); if (env.exception () != 0) return PortableServer::IdUniquenessPolicy::_nil (); - else + else { // Make sure that the auto_ptr does not delete the // implementation @@ -2263,7 +2710,7 @@ TAO_POA::create_id_assignment_policy (PortableServer::IdAssignmentPolicyValue va PortableServer::IdAssignmentPolicy_var result = new_policy->_this (env); if (env.exception () != 0) return PortableServer::IdAssignmentPolicy::_nil (); - else + else { // Make sure that the auto_ptr does not delete the // implementation @@ -2280,7 +2727,7 @@ TAO_POA::create_implicit_activation_policy (PortableServer::ImplicitActivationPo PortableServer::ImplicitActivationPolicy_var result = new_policy->_this (env); if (env.exception () != 0) return PortableServer::ImplicitActivationPolicy::_nil (); - else + else { // Make sure that the auto_ptr does not delete the // implementation @@ -2297,7 +2744,7 @@ TAO_POA::create_servant_retention_policy (PortableServer::ServantRetentionPolicy PortableServer::ServantRetentionPolicy_var result = new_policy->_this (env); if (env.exception () != 0) return PortableServer::ServantRetentionPolicy::_nil (); - else + else { // Make sure that the auto_ptr does not delete the // implementation @@ -2314,7 +2761,7 @@ TAO_POA::create_request_processing_policy (PortableServer::RequestProcessingPoli PortableServer::RequestProcessingPolicy_var result = new_policy->_this (env); if (env.exception () != 0) return PortableServer::RequestProcessingPolicy::_nil (); - else + else { // Make sure that the auto_ptr does not delete the // implementation @@ -2327,7 +2774,7 @@ CORBA::Boolean TAO_Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent, const char *name, CORBA::Environment &env) -{ +{ // Default policies PortableServer::PolicyList default_policies; @@ -2344,18 +2791,18 @@ TAO_Adapter_Activator::unknown_adapter (PortableServer::POA_ptr parent, PortableServer::AdapterActivator_var activator = this->_this (env); if (env.exception () != 0) { - child->destroy (CORBA::B_FALSE, - CORBA::B_FALSE, + child->destroy (CORBA::B_FALSE, + CORBA::B_FALSE, env); return CORBA::B_FALSE; } - child->the_activator (activator, env); + child->the_activator (activator.in (), env); if (env.exception () != 0) { - child->destroy (CORBA::B_FALSE, - CORBA::B_FALSE, + child->destroy (CORBA::B_FALSE, + CORBA::B_FALSE, env); return CORBA::B_FALSE; } @@ -2542,17 +2989,17 @@ TAO_POA_Manager::state (CORBA::Environment &env) } void -TAO_POA_Manager::remove_poa (TAO_POA *poa, +TAO_POA_Manager::remove_poa (TAO_POA *poa, CORBA::Environment &env) { // If we are not closing down, we must remove this poa from our - // collection. + // collection. if (!this->closing_down_) - { + { // Lock access to the POAManager for the duration of this transaction TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env); - this->remove_poa_i (poa, + this->remove_poa_i (poa, env); } @@ -2562,7 +3009,7 @@ TAO_POA_Manager::remove_poa (TAO_POA *poa, } void -TAO_POA_Manager::remove_poa_i (TAO_POA *poa, +TAO_POA_Manager::remove_poa_i (TAO_POA *poa, CORBA::Environment &env) { int result = this->poa_collection_.remove (poa); @@ -2576,22 +3023,22 @@ TAO_POA_Manager::remove_poa_i (TAO_POA *poa, } void -TAO_POA_Manager::register_poa (TAO_POA *poa, +TAO_POA_Manager::register_poa (TAO_POA *poa, CORBA::Environment &env) { // Lock access to the POAManager for the duration of this transaction TAO_POA_WRITE_GUARD (ACE_Lock, monitor, this->lock (), env); - this->register_poa_i (poa, + this->register_poa_i (poa, env); } void -TAO_POA_Manager::register_poa_i (TAO_POA *poa, +TAO_POA_Manager::register_poa_i (TAO_POA *poa, CORBA::Environment &env) { int result = this->poa_collection_.insert (poa); - + if (result != 0) { CORBA::Exception *exception = new CORBA::OBJ_ADAPTER (CORBA::COMPLETED_NO); @@ -2631,19 +3078,19 @@ TAO_Strategy_POA::TAO_Strategy_POA (const TAO_POA::String &adapter_name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, TAO_POA *parent, - TAO_Object_Table &active_object_table, + TAO_Object_Table &active_object_map, CORBA::Environment &env) : TAO_POA (adapter_name, poa_manager, policies, parent, - active_object_table, + active_object_map, env), lock_ (0) { this->lock_ = TAO_ORB_Core_instance ()->server_factory ()->create_poa_lock (); } - + TAO_Strategy_POA::~TAO_Strategy_POA (void) { delete this->lock_; @@ -2668,14 +3115,14 @@ TAO_Strategy_POA::clone (const TAO_POA::String &adapter_name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, TAO_POA *parent, - TAO_Object_Table &active_object_table, + TAO_Object_Table &active_object_map, CORBA::Environment &env) { return new SELF (adapter_name, poa_manager, policies, parent, - active_object_table, + active_object_map, env); } @@ -2689,7 +3136,7 @@ TAO_Strategy_POA_Manager::TAO_Strategy_POA_Manager (void) : TAO_POA_Manager (), lock_ (0) { - this->lock_ = TAO_ORB_Core_instance ()->server_factory ()->create_poa_mgr_lock (); + this->lock_ = TAO_ORB_Core_instance ()->server_factory ()->create_poa_mgr_lock (); } TAO_Strategy_POA_Manager::~TAO_Strategy_POA_Manager (void) @@ -2700,7 +3147,7 @@ TAO_Strategy_POA_Manager::~TAO_Strategy_POA_Manager (void) TAO_POA_Manager * TAO_Strategy_POA_Manager::clone (void) { - return new SELF; + return new SELF; } ACE_Lock & @@ -2713,7 +3160,8 @@ TAO_POA_Current::TAO_POA_Current (void) : poa_impl_ (0), object_id_ (0), in_upcall_ (0), - object_key_ (0) + object_key_ (0), + cookie_ (0) { } @@ -2730,7 +3178,7 @@ TAO_POA_Current::get_POA (CORBA::Environment &env) env.exception (exception); return PortableServer::POA::_nil (); } - + PortableServer::POA_var result = this->poa_impl_->_this (env); if (env.exception () != 0) return PortableServer::POA::_nil (); @@ -2759,15 +3207,16 @@ TAO_POA_Current::clear (void) this->object_id_ = 0; this->in_upcall_ = 0; this->object_key_ = 0; + this->cookie_ = 0; } int TAO_POA_Current::context_is_valid (void) { - return - this->poa_impl_ != 0 && - this->object_id_ != 0 && - this->in_upcall_ != 0 && + return + this->poa_impl_ != 0 && + this->object_id_ != 0 && + this->in_upcall_ != 0 && this->object_key_ != 0; } @@ -2818,3 +3267,15 @@ TAO_POA_Current::in_upcall (void) const { return this->in_upcall_; } + +PortableServer::ServantLocator::Cookie +TAO_POA_Current::locator_cookie (void) const +{ + return this->cookie_; +} + +void +TAO_POA_Current::locator_cookie (PortableServer::ServantLocator::Cookie cookie) +{ + this->cookie_ = cookie; +} diff --git a/TAO/tao/poa.h b/TAO/tao/poa.h index 5860281bf93..f5b08c94d19 100644 --- a/TAO/tao/poa.h +++ b/TAO/tao/poa.h @@ -19,31 +19,31 @@ #if !defined (POA_H) #define POA_H -// CORBA +// CORBA #include "tao/corba.h" // Stubs -#include "tao/poaC.h" +#include "tao/poaC.h" -// Servant +// Servant #include "tao/servant_base.h" // Skeletons -#include "tao/poaS.h" +#include "tao/poaS.h" -// String +// String #include "ace/SString.h" //#include "string" -// Map +// Map //#include "map" #include "ace/Map_Manager.h" -// Vector +// Vector //#include "vector" #include "ace/Containers.h" -// Locking +// Locking #include "ace/Synch.h" // Active Object Table @@ -62,7 +62,7 @@ public: virtual PortableServer::ThreadPolicyValue value (CORBA::Environment &env); virtual PortableServer::Policy_ptr copy (CORBA::Environment &env); - + virtual void destroy (CORBA::Environment &env); protected: @@ -79,7 +79,7 @@ public: virtual PortableServer::LifespanPolicyValue value (CORBA::Environment &env); virtual PortableServer::Policy_ptr copy (CORBA::Environment &env); - + virtual void destroy (CORBA::Environment &env); protected: @@ -96,7 +96,7 @@ public: virtual PortableServer::IdUniquenessPolicyValue value (CORBA::Environment &env); virtual PortableServer::Policy_ptr copy (CORBA::Environment &env); - + virtual void destroy (CORBA::Environment &env); protected: @@ -113,7 +113,7 @@ public: virtual PortableServer::IdAssignmentPolicyValue value (CORBA::Environment &env); virtual PortableServer::Policy_ptr copy (CORBA::Environment &env); - + virtual void destroy (CORBA::Environment &env); protected: @@ -130,7 +130,7 @@ public: virtual PortableServer::ImplicitActivationPolicyValue value (CORBA::Environment &env); virtual PortableServer::Policy_ptr copy (CORBA::Environment &env); - + virtual void destroy (CORBA::Environment &env); protected: @@ -147,7 +147,7 @@ public: virtual PortableServer::ServantRetentionPolicyValue value (CORBA::Environment &env); virtual PortableServer::Policy_ptr copy (CORBA::Environment &env); - + virtual void destroy (CORBA::Environment &env); protected: @@ -164,7 +164,7 @@ public: virtual PortableServer::RequestProcessingPolicyValue value (CORBA::Environment &env); virtual PortableServer::Policy_ptr copy (CORBA::Environment &env); - + virtual void destroy (CORBA::Environment &env); protected: @@ -177,34 +177,36 @@ public: TAO_POA_Policies (void); - PortableServer::ThreadPolicyValue thread (void) const; - void thread (PortableServer::ThreadPolicyValue value); + virtual PortableServer::ThreadPolicyValue thread (void) const; + virtual void thread (PortableServer::ThreadPolicyValue value); - PortableServer::LifespanPolicyValue lifespan (void) const; - void lifespan (PortableServer::LifespanPolicyValue value); + virtual PortableServer::LifespanPolicyValue lifespan (void) const; + virtual void lifespan (PortableServer::LifespanPolicyValue value); - PortableServer::IdUniquenessPolicyValue id_uniqueness (void) const; - void id_uniqueness (PortableServer::IdUniquenessPolicyValue value); + virtual PortableServer::IdUniquenessPolicyValue id_uniqueness (void) const; + virtual void id_uniqueness (PortableServer::IdUniquenessPolicyValue value); - PortableServer::IdAssignmentPolicyValue id_assignment (void) const; - void id_assignment (PortableServer::IdAssignmentPolicyValue value); + virtual PortableServer::IdAssignmentPolicyValue id_assignment (void) const; + virtual void id_assignment (PortableServer::IdAssignmentPolicyValue value); - PortableServer::ImplicitActivationPolicyValue implicit_activation (void) const; - void implicit_activation (PortableServer::ImplicitActivationPolicyValue value); + virtual PortableServer::ImplicitActivationPolicyValue implicit_activation (void) const; + virtual void implicit_activation (PortableServer::ImplicitActivationPolicyValue value); - PortableServer::ServantRetentionPolicyValue servant_retention (void) const; - void servant_retention (PortableServer::ServantRetentionPolicyValue value); + virtual PortableServer::ServantRetentionPolicyValue servant_retention (void) const; + virtual void servant_retention (PortableServer::ServantRetentionPolicyValue value); - PortableServer::RequestProcessingPolicyValue request_processing (void) const; - void request_processing (PortableServer::RequestProcessingPolicyValue value); + virtual PortableServer::RequestProcessingPolicyValue request_processing (void) const; + virtual void request_processing (PortableServer::RequestProcessingPolicyValue value); - void parse_policies (const PortableServer::PolicyList& policies, - CORBA::Environment &env); + virtual void parse_policies (const PortableServer::PolicyList &policies, + CORBA::Environment &env); protected: - void parse_policy (const PortableServer::Policy_ptr policy, - CORBA::Environment &env); + virtual void parse_policy (const PortableServer::Policy_ptr policy, + CORBA::Environment &env); + + virtual int validity_check (void); PortableServer::ThreadPolicyValue thread_; @@ -230,7 +232,7 @@ public: virtual PortableServer::POA_ptr create_POA (const char *adapter_name, PortableServer::POAManager_ptr poa_manager, - const PortableServer::PolicyList& policies, + const PortableServer::PolicyList &policies, CORBA::Environment &env); virtual PortableServer::POA_ptr find_POA (const char *adapter_name, @@ -335,7 +337,7 @@ public: TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, TAO_POA *parent, - TAO_Object_Table &active_object_table, + TAO_Object_Table &active_object_map, CORBA::Environment &env); virtual TAO_POA *clone (const String &adapter_name, @@ -348,7 +350,7 @@ public: TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, TAO_POA *parent, - TAO_Object_Table &active_object_table, + TAO_Object_Table &active_object_map, CORBA::Environment &env); virtual ~TAO_POA (void); @@ -358,8 +360,8 @@ public: void *context, CORBA::Environment &env); - virtual PortableServer::Servant locate_servant (const TAO::ObjectKey &key, - CORBA::Environment &env); + virtual int locate_servant (const TAO::ObjectKey &key, + CORBA::Environment &env); static char name_separator (void); @@ -371,9 +373,6 @@ public: protected: - virtual PortableServer::Servant locate_servant_i (const TAO::ObjectKey &key, - CORBA::Environment &env); - virtual TAO_POA *create_POA (const String &adapter_name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, @@ -387,7 +386,7 @@ protected: virtual TAO_POA *find_POA (const String &adapter_name, CORBA::Boolean activate_it, CORBA::Environment &env); - + virtual TAO_POA *find_POA_i (const String &adapter_name, CORBA::Boolean activate_it, CORBA::Environment &env); @@ -395,7 +394,7 @@ protected: virtual TAO_POA *find_POA_i_optimized (const String &adapter_name, CORBA::Boolean activate_it, CORBA::Environment &env); - + virtual void destroy_i (CORBA::Boolean etherealize_objects, CORBA::Boolean wait_for_completion, CORBA::Environment &env); @@ -419,10 +418,10 @@ protected: virtual void deactivate_object_i (const PortableServer::ObjectId &oid, CORBA::Environment &env); - + virtual CORBA::Object_ptr create_reference_i (const char *intf, CORBA::Environment &env); - + virtual PortableServer::ObjectId *servant_to_id_i (PortableServer::Servant servant, CORBA::Environment &env); @@ -433,7 +432,7 @@ protected: virtual TAO_POA_Policies &policies (void); - virtual TAO_Object_Table &active_object_table (void); + virtual TAO_Object_Table &active_object_map (void); virtual void delete_child (const String &child, CORBA::Environment &env); @@ -447,26 +446,55 @@ protected: virtual int leaf_poa_name (const String &adapter_name, CORBA::Environment &env); - + virtual void parse_poa_name (const TAO_POA::String &adapter_name, TAO_POA::String &topmost_poa_name, TAO_POA::String &tail_poa_name, CORBA::Environment &env); virtual PortableServer::ObjectId *create_object_id (void); - + virtual TAO::ObjectKey *create_object_key (const PortableServer::ObjectId &id); - virtual int is_poa_generated_id (const PortableServer::ObjectId& id); + virtual int is_poa_generated_id (const PortableServer::ObjectId &id); - virtual int is_poa_generated_key (const TAO::ObjectKey& key); + virtual int is_poa_generated_key (const TAO::ObjectKey &key); - virtual int parse_key (const TAO::ObjectKey &key, + virtual int parse_key (const TAO::ObjectKey &key, String &poa_name, PortableServer::ObjectId_out id, - CORBA::Boolean &persistent); + CORBA::Boolean &persistent, + ACE_Time_Value &poa_creation_time); + + virtual int locate_servant_i (const TAO::ObjectKey &key, + CORBA::Environment &env); + + virtual PortableServer::Servant locate_poa_and_servant_i (const TAO::ObjectKey &key, + const char *operation, + PortableServer::ObjectId_out id, + TAO_POA *&poa_impl, + CORBA::Environment &env); + + virtual TAO_POA *locate_poa_i (const TAO::ObjectKey &key, + PortableServer::ObjectId_out id, + CORBA::Environment &env); - virtual CORBA::Boolean persistent (void); + virtual void dispatch_servant_i (const TAO::ObjectKey &key, + CORBA::ServerRequest &req, + void *context, + CORBA::Environment &env); + + virtual void pre_invoke (const TAO::ObjectKey &key, + const PortableServer::ObjectId &id, + CORBA::Environment &env); + + virtual void post_invoke (PortableServer::Servant servant, + const char *operation, + CORBA::Environment &env); + + virtual CORBA::Boolean persistent (void); + + virtual const ACE_Time_Value &creation_time (void); virtual const String &object_key_type (void); @@ -477,7 +505,7 @@ protected: static const char *ObjectId_to_const_string (const PortableServer::ObjectId &id); static const wchar_t *ObjectId_to_const_wstring (const PortableServer::ObjectId &id); - + static const char *ObjectKey_to_const_string (const TAO::ObjectKey &key); String name_; @@ -490,9 +518,9 @@ protected: TAO_POA *parent_; - TAO_Object_Table *active_object_table_; + TAO_Object_Table *active_object_map_; - int delete_active_object_table_; + int delete_active_object_map_; PortableServer::AdapterActivator_var adapter_activator_; @@ -511,6 +539,10 @@ protected: int closing_down_; CORBA::ULong counter_; + + ACE_Time_Value creation_time_; + + static const int max_space_required_for_ulong; }; class TAO_Export TAO_POA_Manager : public POA_PortableServer::POAManager @@ -551,16 +583,16 @@ protected: virtual ACE_Lock &lock (void); - virtual void remove_poa (TAO_POA *poa, + virtual void remove_poa (TAO_POA *poa, CORBA::Environment &env); - virtual void remove_poa_i (TAO_POA *poa, + virtual void remove_poa_i (TAO_POA *poa, CORBA::Environment &env); - virtual void register_poa (TAO_POA *poa, + virtual void register_poa (TAO_POA *poa, CORBA::Environment &env); - virtual void register_poa_i (TAO_POA *poa, + virtual void register_poa_i (TAO_POA *poa, CORBA::Environment &env); Processing_State state_; @@ -570,8 +602,8 @@ protected: ACE_Lock_Adapter<ACE_Null_Mutex> lock_; typedef ACE_Unbounded_Set<TAO_POA *> POA_COLLECTION; - - POA_COLLECTION poa_collection_; + + POA_COLLECTION poa_collection_; }; class TAO_Export TAO_Adapter_Activator : public POA_PortableServer::AdapterActivator @@ -592,25 +624,25 @@ public: const TAO_POA_Policies &policies, TAO_POA *parent, CORBA::Environment &env); - + TAO_Strategy_POA (const String &adapter_name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, TAO_POA *parent, - TAO_Object_Table &active_object_table, + TAO_Object_Table &active_object_map, CORBA::Environment &env); - + virtual TAO_POA *clone (const String &adapter_name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, TAO_POA *parent, CORBA::Environment &env); - + virtual TAO_POA *clone (const String &adapter_name, TAO_POA_Manager &poa_manager, const TAO_POA_Policies &policies, TAO_POA *parent, - TAO_Object_Table &active_object_table, + TAO_Object_Table &active_object_map, CORBA::Environment &env); virtual ~TAO_Strategy_POA (void); @@ -666,74 +698,80 @@ class TAO_Export TAO_POA_Current : public POA_PortableServer::Current public: // = Specification-mandated methods - - PortableServer::POA_ptr get_POA (CORBA::Environment &env); - // Return pointer to the invoking POA. This has _out - // semantics. (Irfan is this correct?) Raises the - // <CORBA::NoContext> exception. + virtual PortableServer::POA_ptr get_POA (CORBA::Environment &env); + // Return pointer to the invoking POA. Raises the + // <CORBA::NoContext> exception. - PortableServer::ObjectId *get_object_id (CORBA::Environment &env); + virtual PortableServer::ObjectId *get_object_id (CORBA::Environment &env); // Return pointer to the object id through which this was invoked. // This may be necessary in cases where a <Servant> is serving under - // the guise of multiple object ids. This has _out semantics - // (Irfan, is this correct?) Raises the <CORBA::NoContext> - // exception. + // the guise of multiple object ids. This has _out semantics Raises + // the <CORBA::NoContext> exception. // = TAO Extensions - void clear (void); + virtual void clear (void); // Clear any prior settings made. This will make things which can // throw the <CORBA::NoContext> exception raise it if invoked // without a corresponding <set_*> operation. - int context_is_valid (void); + virtual int context_is_valid (void); // Returns non-zero if the context is valid, i.e., if it would be // impossible for a <CORBA::NoContext> exception to be raised. - - void POA_impl (TAO_POA *impl); + + virtual void POA_impl (TAO_POA *impl); // Set the POA implementation. - TAO_POA *POA_impl (void) const; + virtual TAO_POA *POA_impl (void) const; // Get the POA imeplemantation - void object_id (const PortableServer::ObjectId &id); + virtual void object_id (const PortableServer::ObjectId &id); // Set the object ID. - const PortableServer::ObjectId &object_id (void) const; + virtual const PortableServer::ObjectId &object_id (void) const; // Get the object ID. - void object_key (const TAO::ObjectKey &key); + virtual void object_key (const TAO::ObjectKey &key); // Set the object key. - const TAO::ObjectKey &object_key (void) const; + virtual const TAO::ObjectKey &object_key (void) const; // Get the object key. - void in_upcall (int yesno); + virtual void in_upcall (int yesno); // Set whether we're in an upcall (non-zero is yes). - int in_upcall (void) const; + virtual int in_upcall (void) const; // Get whether we're in an upcall (non-zero is yes). + virtual PortableServer::ServantLocator::Cookie locator_cookie (void) const; + // Get the Servant Locator's cookie + + virtual void locator_cookie (PortableServer::ServantLocator::Cookie cookie); + // Set the Servant Locator's cookie + TAO_POA_Current (void); // Constructor virtual ~TAO_POA_Current (void); // Destructor - + private: TAO_POA *poa_impl_; // The POA implementation invoking an upcall - + const PortableServer::ObjectId *object_id_; // The object ID of the current context. - + int in_upcall_; // Flag which indicates whether we're in an upcall. - + const TAO::ObjectKey *object_key_; // The object key of the current context. + PortableServer::ServantLocator::Cookie cookie_; + // Servant Locator's cookie + // = Hidden because we don't allow these TAO_POA_Current (const TAO_POA_Current &); void operator= (const TAO_POA_Current &); diff --git a/TAO/tao/poaC.h b/TAO/tao/poaC.h index 8fa3bfef643..b6946166d36 100644 --- a/TAO/tao/poaC.h +++ b/TAO/tao/poaC.h @@ -10,6 +10,7 @@ class TAO_ServantBase; class TAO_Local_ServantBase; +class TAO_DynamicImplementation; class TAO_Export PortableServer{ public: @@ -18,6 +19,7 @@ public: typedef ServantBase *Servant; typedef TAO_Local_ServantBase LocalServantBase; + typedef TAO_DynamicImplementation DynamicImplementation; typedef CORBA::String Identifier; typedef CORBA::String_var Identifier_var; diff --git a/TAO/tao/poaS.cpp b/TAO/tao/poaS.cpp index f912e4509d0..a5bcd0051e5 100644 --- a/TAO/tao/poaS.cpp +++ b/TAO/tao/poaS.cpp @@ -73,12 +73,12 @@ void* POA_PortableServer::CurrentBase::_downcast ( return 0; } -void POA_PortableServer::CurrentBase::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::CurrentBase::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -224,12 +224,12 @@ void* POA_PortableServer::Policy::_downcast ( return 0; } -void POA_PortableServer::Policy::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::Policy::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -375,12 +375,12 @@ void* POA_PortableServer::ThreadPolicy::_downcast ( return 0; } -void POA_PortableServer::ThreadPolicy::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::ThreadPolicy::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -516,12 +516,12 @@ void* POA_PortableServer::LifespanPolicy::_downcast ( return 0; } -void POA_PortableServer::LifespanPolicy::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::LifespanPolicy::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -657,12 +657,12 @@ void* POA_PortableServer::IdUniquenessPolicy::_downcast ( return 0; } -void POA_PortableServer::IdUniquenessPolicy::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::IdUniquenessPolicy::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -798,12 +798,12 @@ void* POA_PortableServer::IdAssignmentPolicy::_downcast ( return 0; } -void POA_PortableServer::IdAssignmentPolicy::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::IdAssignmentPolicy::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -939,12 +939,12 @@ void* POA_PortableServer::ImplicitActivationPolicy::_downcast ( return 0; } -void POA_PortableServer::ImplicitActivationPolicy::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::ImplicitActivationPolicy::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -1080,12 +1080,12 @@ void* POA_PortableServer::ServantRetentionPolicy::_downcast ( return 0; } -void POA_PortableServer::ServantRetentionPolicy::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::ServantRetentionPolicy::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -1221,12 +1221,12 @@ void* POA_PortableServer::RequestProcessingPolicy::_downcast ( return 0; } -void POA_PortableServer::RequestProcessingPolicy::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::RequestProcessingPolicy::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -1416,12 +1416,12 @@ void* POA_PortableServer::POAManager::_downcast ( return 0; } -void POA_PortableServer::POAManager::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::POAManager::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -1606,12 +1606,12 @@ void* POA_PortableServer::AdapterActivator::_downcast ( return 0; } -void POA_PortableServer::AdapterActivator::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::AdapterActivator::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -1735,12 +1735,12 @@ void* POA_PortableServer::ServantManager::_downcast ( return 0; } -void POA_PortableServer::ServantManager::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::ServantManager::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -1868,12 +1868,12 @@ void* POA_PortableServer::ServantActivator::_downcast ( return 0; } -void POA_PortableServer::ServantActivator::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::ServantActivator::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -2034,12 +2034,12 @@ void* POA_PortableServer::ServantLocator::_downcast ( return 0; } -void POA_PortableServer::ServantLocator::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::ServantLocator::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -2709,12 +2709,12 @@ void* POA_PortableServer::POA::_downcast ( return 0; } -void POA_PortableServer::POA::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::POA::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); @@ -3190,12 +3190,12 @@ void* POA_PortableServer::Current::_downcast ( return 0; } -void POA_PortableServer::Current::dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) +void POA_PortableServer::Current::_dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env) { TAO_Skeleton skel; // pointer to skeleton for operation CORBA::String opname = req.op_name (); // retrieve operation name // find the skeleton corresponding to this opname - if (this->find (opname, skel) == -1) + if (this->_find (opname, skel) == -1) { env.exception (new CORBA_BAD_OPERATION (CORBA::COMPLETED_NO)); ACE_ERROR ((LM_ERROR, "Bad operation <%s>\n", opname)); diff --git a/TAO/tao/poaS.h b/TAO/tao/poaS.h index 04039d91b7c..1fd1ad2a680 100644 --- a/TAO/tao/poaS.h +++ b/TAO/tao/poaS.h @@ -29,7 +29,7 @@ public: ); static void _is_a_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &_tao_enviroment); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::CurrentBase *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -82,7 +82,7 @@ public: static void _is_a_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &_tao_enviroment); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::Policy *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -142,7 +142,7 @@ public: static void destroy_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &env); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::ThreadPolicy *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -200,7 +200,7 @@ public: static void destroy_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &env); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::LifespanPolicy *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -258,7 +258,7 @@ public: static void destroy_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &env); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::IdUniquenessPolicy *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -316,7 +316,7 @@ public: static void destroy_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &env); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::IdAssignmentPolicy *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -374,7 +374,7 @@ public: static void destroy_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &env); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::ImplicitActivationPolicy *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -432,7 +432,7 @@ public: static void destroy_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &env); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::ServantRetentionPolicy *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -490,7 +490,7 @@ public: static void destroy_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &env); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::RequestProcessingPolicy *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -553,7 +553,7 @@ public: static void _is_a_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &_tao_enviroment); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::POAManager *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -619,7 +619,7 @@ public: static void _is_a_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &_tao_enviroment); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::AdapterActivator *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -671,7 +671,7 @@ public: ); static void _is_a_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &_tao_enviroment); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::ServantManager *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -724,7 +724,7 @@ public: static void _is_a_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &_tao_enviroment); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::ServantActivator *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -791,7 +791,7 @@ public: static void _is_a_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &_tao_enviroment); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::ServantLocator *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -944,7 +944,7 @@ public: static void _is_a_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &_tao_enviroment); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::POA *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; @@ -1116,7 +1116,7 @@ public: static void _is_a_skel (CORBA::ServerRequest &req, void *obj, void *context, CORBA::Environment &_tao_enviroment); - virtual void dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); + virtual void _dispatch (CORBA::ServerRequest &req, void *context, CORBA::Environment &env); PortableServer::Current *_this (CORBA::Environment &_tao_environment); virtual const char* _interface_repository_id (void) const; diff --git a/TAO/tao/servant_base.cpp b/TAO/tao/servant_base.cpp index c9f5266a4dd..b70894d06ef 100644 --- a/TAO/tao/servant_base.cpp +++ b/TAO/tao/servant_base.cpp @@ -43,36 +43,36 @@ TAO_ServantBase::_is_a (const char* logical_type_id, } void -TAO_ServantBase::set_parent (TAO_IUnknown *p) +TAO_ServantBase::_set_parent (TAO_IUnknown *p) { this->parent_ = p; ACE_ASSERT (this->parent_ != 0); } TAO_IUnknown * -TAO_ServantBase::get_parent (void) const +TAO_ServantBase::_get_parent (void) const { return this->parent_; } int -TAO_ServantBase::find (const CORBA::String &opname, - TAO_Skeleton& skelfunc) +TAO_ServantBase::_find (const CORBA::String &opname, + TAO_Skeleton& skelfunc) { return optable_->find (opname, skelfunc); } int -TAO_ServantBase::bind (const CORBA::String &opname, - const TAO_Skeleton skel_ptr) +TAO_ServantBase::_bind (const CORBA::String &opname, + const TAO_Skeleton skel_ptr) { return optable_->bind (opname, skel_ptr); } void -TAO_ServantBase::dispatch (CORBA::ServerRequest &req, - void *context, - CORBA::Environment &env) +TAO_ServantBase::_dispatch (CORBA::ServerRequest &req, + void *context, + CORBA::Environment &env) { // XXXASG - we should check here if the call was for _non_existant, else // issue an error. For the time being we issue an error @@ -89,7 +89,7 @@ TAO_ServantBase::dispatch (CORBA::ServerRequest &req, } STUB_Object * -TAO_ServantBase::_create_stub (CORBA_Environment &_env) +TAO_ServantBase::_create_stub (CORBA_Environment &env) { STUB_Object *stub; @@ -103,15 +103,15 @@ TAO_ServantBase::_create_stub (CORBA_Environment &_env) } else { - PortableServer::POA_var poa = this->_default_POA (_env); - if (_env.exception () != 0) + PortableServer::POA_var poa = this->_default_POA (env); + if (env.exception () != 0) return 0; - CORBA::Object_var object = poa->servant_to_reference (this, _env); - if (_env.exception () != 0) + CORBA::Object_var object = poa->servant_to_reference (this, env); + if (env.exception () != 0) return 0; - TAO::ObjectKey_var object_key = object->key (_env); + TAO::ObjectKey_var object_key = object->key (env); stub = new IIOP_Object (CORBA::string_copy (this->_interface_repository_id ()), IIOP::Profile (orb_core->orb_params ()->addr (), object_key.in ())); @@ -121,10 +121,86 @@ TAO_ServantBase::_create_stub (CORBA_Environment &_env) } STUB_Object * -TAO_Local_ServantBase::_create_stub (CORBA_Environment &_env) +TAO_Local_ServantBase::_create_stub (CORBA_Environment &env) { // Note the use of a fake key and no registration with POAs return new IIOP_Object (CORBA::string_copy (this->_interface_repository_id ()), IIOP::Profile (TAO_ORB_Core_instance ()->orb_params ()->addr (), "0")); } + +CORBA::Object_ptr +TAO_DynamicImplementation::_this (CORBA::Environment &env) +{ + // The _this() function returns a CORBA::Object_ptr for the target + // object. Unlike _this() for static skeletons, its return type is + // not interface-specific because a DSI servant may very well + // incarnate multiple CORBA objects of different types. + STUB_Object *stub = this->_create_stub (env); + if (env.exception () != 0) + return CORBA::Object::_nil (); + + // Create a object + return new CORBA::Object (stub, this, CORBA::B_TRUE); +} + +const char * +TAO_DynamicImplementation::_interface_repository_id (void) const +{ + // This should never be called + return 0; +} + +void * +TAO_DynamicImplementation::_downcast (const char *repository_id) +{ + ACE_UNUSED_ARG (repository_id); + + // Don't know enough to do better + return this; +} + +STUB_Object * +TAO_DynamicImplementation::_create_stub (CORBA::Environment &env) +{ + // If DynamicImplementation::_this() is invoked outside of the + // context of a request invocation on a target object being served + // by the DSI servant, it raises the PortableServer::WrongPolicy + // exception. + TAO_ORB_Core *orb_core = TAO_ORB_Core_instance (); + TAO_POA_Current *poa_current = orb_core->poa_current (); + if (!poa_current->in_upcall ()) + { + CORBA::Exception *exception = new PortableServer::POA::WrongPolicy; + env.exception (exception); + return 0; + } + + PortableServer::POA_var poa = poa_current->get_POA (env); + if (env.exception () != 0) + return 0; + + // CORBA::RepositoryId interface = this->_primary_interface (poa_current->object_id (), + // poa.in (), + // env); + PortableServer::RepositoryId interface = this->_primary_interface (poa_current->object_id (), + poa.in (), + env); + if (env.exception () != 0) + return 0; + + return new IIOP_Object (interface, + IIOP::Profile (orb_core->orb_params ()->addr (), + poa_current->object_key ())); +} + +void +TAO_DynamicImplementation::_dispatch (CORBA::ServerRequest &request, + void *context, + CORBA::Environment &env) +{ + ACE_UNUSED_ARG (context); + + // Delegate to user + this->invoke (&request, env); +} diff --git a/TAO/tao/servant_base.h b/TAO/tao/servant_base.h index 7411ebb62e5..4efae8dcc01 100644 --- a/TAO/tao/servant_base.h +++ b/TAO/tao/servant_base.h @@ -13,6 +13,9 @@ class TAO_Export TAO_ServantBase // The POA spec requires that all servants inherit from this // class. // + + friend class TAO_POA; + public: virtual ~TAO_ServantBase (void); // destructor @@ -22,57 +25,57 @@ public: virtual PortableServer::POA_ptr _default_POA (CORBA::Environment &env); + virtual void *_downcast (const char *repository_id) = 0; + // Get the correct vtable + + virtual STUB_Object *_create_stub (CORBA_Environment &env); + // This is an auxiliar method for _this() and _narrow(). + +protected: + TAO_ServantBase (void); + // Default constructor, only derived classes can be created. + + TAO_ServantBase (const TAO_ServantBase &); + // Copy constructor, protected so no instances can be created. + + void _set_parent (TAO_IUnknown *p); + // Set the "parent" in the QueryInterface hierarchy. + // @@ TODO use a conformant name; since it is an + // internal (implementation) method its name should start with '_' + virtual CORBA::Boolean _is_a (const char* logical_type_id, - CORBA::Environment &_tao_environment); + CORBA::Environment &env); // Local implementation of the CORBA::Object::_is_a method. - virtual void dispatch (CORBA::ServerRequest &_tao_request, - void *_tao_context, - CORBA::Environment &_tao_environment); + virtual void _dispatch (CORBA::ServerRequest &request, + void *context, + CORBA::Environment &env); // Dispatches a request to the object: find the operation, cast // the type to the most derived type, demarshall all the // parameters from the request and finally invokes the operation, // storing the results and out parameters (if any) or the - // exceptions thrown into <_tao_request>. + // exceptions thrown into <request>. // @@ TODO use a conformant name; since it is an // internal (implementation) method its name should start with '_' - virtual int find (const CORBA::String &opname, - TAO_Skeleton &skelfunc); + virtual int _find (const CORBA::String &opname, + TAO_Skeleton &skelfunc); // Find an operation in the operation table. // @@ TODO use a conformant name; since it is an // internal (implementation) method its name should start with '_' - virtual int bind (const CORBA::String &opname, - const TAO_Skeleton skel_ptr); + virtual int _bind (const CORBA::String &opname, + const TAO_Skeleton skel_ptr); // Register a CORBA IDL operation name. // @@ TODO use a conformant name; since it is an // internal (implementation) method its name should start with '_' - TAO_IUnknown *get_parent (void) const; + TAO_IUnknown *_get_parent (void) const; // Get the "parent" in the QueryInterface hierarchy. virtual const char *_interface_repository_id (void) const = 0; // Get this interface's repository id - virtual void *_downcast (const char *repository_id) = 0; - // Get the correct vtable - - virtual STUB_Object *_create_stub (CORBA_Environment &_env); - // This is an auxiliar method for _this() and _narrow(). - -protected: - TAO_ServantBase (void); - // Default constructor, only derived classes can be created. - - TAO_ServantBase (const TAO_ServantBase &); - // Copy constructor, protected so no instances can be created. - - void set_parent (TAO_IUnknown *p); - // Set the "parent" in the QueryInterface hierarchy. - // @@ TODO use a conformant name; since it is an - // internal (implementation) method its name should start with '_' - protected: TAO_Operation_Table *optable_; // The operation table for this servant, it is initialized by the @@ -88,9 +91,59 @@ class TAO_Export TAO_Local_ServantBase : public TAO_ServantBase // Base class for local skeletons and servants. // protected: - STUB_Object *_create_stub (CORBA_Environment &_env); + STUB_Object *_create_stub (CORBA_Environment &env); // This is an auxiliar method for _this(). Make sure *not* to // register with the default POA }; +// Base class for DSI +class TAO_DynamicImplementation : public virtual TAO_ServantBase +{ + // + // = DESCRIPTION + // + // It is expected that the invoke() and _primary_interface() + // methods will be only invoked by the POA in the context of + // serving a CORBA request. Invoking this method in other + // circumstances may lead to unpredictable results. + +public: + + virtual void invoke (CORBA::ServerRequest_ptr request, + CORBA::Environment &env) = 0; + // The invoke() method receives requests issued to any CORBA object + // incarnated by the DSI servant and performs the processing + // necessary to execute the request. + + // virtual CORBA::RepositoryId _primary_interface (const PortableServer::ObjectId &oid, + // PortableServer::POA_ptr poa, + // CORBA::Environment &env) = 0; + + virtual PortableServer::RepositoryId _primary_interface (const PortableServer::ObjectId &oid, + PortableServer::POA_ptr poa, + CORBA::Environment &env) = 0; + // The _primary_interface() method receives an ObjectId value and a + // POA_ptr as input parameters and returns a valid RepositoryId + // representing the most-derived interface for that oid. + + CORBA::Object_ptr _this (CORBA::Environment &env); + // Returns a CORBA::Object_ptr for the target object. + +protected: + + virtual const char *_interface_repository_id (void) const; + // Return 0. Should never be used. + + virtual void *_downcast (const char *repository_id); + // Simply returns "this" + + virtual STUB_Object *_create_stub (CORBA_Environment &env); + // This is an auxiliar method for _this() and _narrow(). + + virtual void _dispatch (CORBA::ServerRequest &request, + void *context, + CORBA::Environment &env); + // Turns around and calls invoke +}; + #endif /* SERVANT_BASE_H */ diff --git a/TAO/tests/POA/Explicit_Activation_POA_Ids/server.cpp b/TAO/tests/POA/Explicit_Activation_POA_Ids/server.cpp index 61d903ccb66..0bc51d2689c 100644 --- a/TAO/tests/POA/Explicit_Activation_POA_Ids/server.cpp +++ b/TAO/tests/POA/Explicit_Activation_POA_Ids/server.cpp @@ -29,10 +29,11 @@ main (int argc, char **argv) return -1; } - // CORBA::PolicyList policies (1); - PortableServer::PolicyList policies (1); - policies.length (1); + // CORBA::PolicyList policies (2); + PortableServer::PolicyList policies (2); + policies.length (2); policies[0] = root_poa->create_id_assignment_policy (PortableServer::USER_ID, env); + policies[1] = root_poa->create_lifespan_policy (PortableServer::PERSISTENT, env); ACE_CString name = "firstPOA"; PortableServer::POA_var first_poa = root_poa->create_POA (name.c_str (), |