diff options
author | bala <balanatarajan@users.noreply.github.com> | 2003-03-21 23:52:14 +0000 |
---|---|---|
committer | bala <balanatarajan@users.noreply.github.com> | 2003-03-21 23:52:14 +0000 |
commit | 318a20871384d7350346f95cc25314706258cb8c (patch) | |
tree | 56cfd89a72c2c4dad9aaae61a89e9a74b3ea85da | |
parent | 41d3b2be8a903913ed3018282992e72f81066b7f (diff) | |
download | ATCD-318a20871384d7350346f95cc25314706258cb8c.tar.gz |
ChangeLogTag: Sat Feb 22 09:50:31 2003 Ossama Othman <ossama@uci.edu>
-rw-r--r-- | TAO/tao/Adapter.cpp | 15 | ||||
-rw-r--r-- | TAO/tao/Adapter.h | 9 | ||||
-rw-r--r-- | TAO/tao/ChangeLog | 33 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.cpp | 6 | ||||
-rw-r--r-- | TAO/tao/Object.cpp | 34 | ||||
-rw-r--r-- | TAO/tao/Object.h | 22 | ||||
-rw-r--r-- | TAO/tao/Object.i | 24 | ||||
-rw-r--r-- | TAO/tao/PortableServer/Object_Adapter.cpp | 63 | ||||
-rw-r--r-- | TAO/tao/PortableServer/Object_Adapter.h | 3 |
9 files changed, 194 insertions, 15 deletions
diff --git a/TAO/tao/Adapter.cpp b/TAO/tao/Adapter.cpp index c5951915b33..31441af4ab7 100644 --- a/TAO/tao/Adapter.cpp +++ b/TAO/tao/Adapter.cpp @@ -174,6 +174,21 @@ TAO_Adapter_Registry::create_collocated_object (TAO_Stub *stub, return 0; } +CORBA::Long +TAO_Adapter_Registry::initialize_collocated_object (TAO_Stub *stub, + CORBA::Object_ptr obj) +{ + for (size_t i = 0; i != this->adapters_count_; ++i) + { + int retval = + this->adapters_[i]->initialize_collocated_object (stub, + obj); + if (retval != 0) + return retval; + } + return 0; +} + TAO_Adapter * TAO_Adapter_Registry::find_adapter (const char *name) const { diff --git a/TAO/tao/Adapter.h b/TAO/tao/Adapter.h index dd3e5057303..bb604ec0aa7 100644 --- a/TAO/tao/Adapter.h +++ b/TAO/tao/Adapter.h @@ -99,6 +99,10 @@ public: /// Create a collocated object using the given profile and stub. virtual CORBA::Object_ptr create_collocated_object (TAO_Stub *, const TAO_MProfile &) = 0; + /// Initialize a collocated object using the given stub and object + /// pointer for lazily evaluated object references. + virtual CORBA::Long initialize_collocated_object (TAO_Stub *, + CORBA::Object_ptr) = 0; }; // **************************************************************** @@ -151,6 +155,11 @@ public: CORBA::Object_ptr create_collocated_object (TAO_Stub *, const TAO_MProfile &); + /// Initialize a collocated object using the given stub and object + /// pointer for lazily evaluated object references. + CORBA::Long initialize_collocated_object (TAO_Stub *, + CORBA::Object_ptr o); + /// Fetch the adapter named <name> TAO_Adapter *find_adapter (const char *name) const; diff --git a/TAO/tao/ChangeLog b/TAO/tao/ChangeLog index ce4b91e2eff..68ce48c35dc 100644 --- a/TAO/tao/ChangeLog +++ b/TAO/tao/ChangeLog @@ -1,3 +1,36 @@ +Fri Mar 21 17:07:11 2003 Balachandran Natarajan <bala@isis-server.isis.vanderbilt.edu> + + * tao/Adapter.h: + * tao/Adapter.cpp: Added a method initialize_collocated_object () + in the TAO_Adapter_Factory and TAO_Adapter. + + * tao/ORB_Core.pp: Implemented the initialize_collocated_object () + which basically calls the + TAO_Adapter_Registry::initialize_collocated_object (). + + * tao/PortableServer/Object_Adapter.cpp: + * tao/PortableServer/Object_Adapter.h: Added a new method + initialize_collocated_object (). The implementation is pretty + much similar to the create_collocated_object (), but instead of + creating a new object, initializes an existing object. + + * tao/Object.h: + * tao/Object.cpp: + * tao/Object.i: + + Added the following methods + + - set_collocated_servant () which helps to initialize the + CORBA::Object with TAO_Abstract_ServantBase + + - Accessors for orb_core () and IOP::IOR + + Added initialization of collocated objects in + tao_initialize_object (). + + The above checkin has lots of duplicated code. Need to refactor + them in the next round. + Fri Mar 21 16:37:12 2003 Balachandran Natarajan <bala@isis-server.isis.vanderbilt.edu> * TAO_IDL/be/be_interface.cpp: Added a new argument to the diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index e2d7ce698db..94fc35d4e4e 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -1715,10 +1715,8 @@ TAO_ORB_Core::initialize_collocated_object (TAO_Stub *stub, // OK, the target ORB and the mprofile match, use the Adapter // Registry of each ORB to find the right one. - - return -1; - /*orb_core->adapter_registry ()->create_collocated_object (stub, - mprofile);*/ + return orb_core->adapter_registry ()->initialize_collocated_object (stub, + obj); } int diff --git a/TAO/tao/Object.cpp b/TAO/tao/Object.cpp index dbd41548a5b..cddbdd69dc4 100644 --- a/TAO/tao/Object.cpp +++ b/TAO/tao/Object.cpp @@ -66,9 +66,11 @@ CORBA::Object::Object (TAO_Stub * protocol_proxy, // factory otherwise use the remote proxy broker. if (this->is_collocated_ && _TAO_collocation_Object_Proxy_Broker_Factory_function_pointer != 0) - this->proxy_broker_ = _TAO_collocation_Object_Proxy_Broker_Factory_function_pointer (this); + this->proxy_broker_ = + _TAO_collocation_Object_Proxy_Broker_Factory_function_pointer (this); else - this->proxy_broker_ = the_tao_remote_object_proxy_broker (); + this->proxy_broker_ = + the_tao_remote_object_proxy_broker (); } CORBA::Object::Object (IOP::IOR *ior, @@ -87,13 +89,7 @@ CORBA::Object::Object (IOP::IOR *ior, this->refcount_lock_ = this->orb_core_->resource_factory ()->create_corba_object_lock (); - // If the object is collocated then set the broker using the - // factory otherwise use the remote proxy broker. - /*if (this->is_collocated_ && - _TAO_collocation_Object_Proxy_Broker_Factory_function_pointer != 0) - this->proxy_broker_ = _TAO_collocation_Object_Proxy_Broker_Factory_function_pointer (this); - else - this->proxy_broker_ = the_tao_remote_object_proxy_broker ();*/ + } // Too tired to do this check in every method properly! @@ -673,6 +669,10 @@ operator<< (TAO_OutputCDR& cdr, const CORBA::Object* x) /*static*/ void CORBA::Object::tao_object_initialize (CORBA::Object *obj) { + // Check if already evaluated.. + if (obj->is_evaluated_) + return; + CORBA::ULong profile_count = obj->ior_->profiles.length (); @@ -772,10 +772,22 @@ CORBA::Object::tao_object_initialize (CORBA::Object *obj) if (retval == 0) obj->protocol_proxy_ = objdata; - // Transfer ownership to the CORBA::Object - (void) safe_objdata.release (); + // If the object is collocated then set the broker using the + // factory otherwise use the remote proxy broker. + if (obj->is_collocated_ && + _TAO_collocation_Object_Proxy_Broker_Factory_function_pointer != 0) + obj->proxy_broker_ = + _TAO_collocation_Object_Proxy_Broker_Factory_function_pointer (obj); + else + obj->proxy_broker_ = the_tao_remote_object_proxy_broker (); obj->is_evaluated_ = 1; + + // Release the contents of the ior to keep memory consumption down. + obj->ior_ = 0; + + // Transfer ownership to the CORBA::Object + (void) safe_objdata.release (); return; } diff --git a/TAO/tao/Object.h b/TAO/tao/Object.h index ab8ae2e4ade..357207fcdbf 100644 --- a/TAO/tao/Object.h +++ b/TAO/tao/Object.h @@ -255,6 +255,28 @@ namespace CORBA /// Accessor to the flag.. CORBA::Boolean is_evaluated (void) const; + /// Mutator for setting the servant in collocated cases. + /** + * This is used by the Object_Adapter to set the servant for + * collocated cases and only when the object is initialized. The + * object initialization takes place when IOR's are lazily + * evaluated. + */ + void set_collocated_servant (TAO_Abstract_ServantBase *); + + /// Accessor for the ORB_Core.. + TAO_ORB_Core *orb_core (void) const; + + /// Accessors for the underlying IOP::IOR's. + /** + * The steal_ior () call basically relinquishes the ownership of + * the IOR. This is useful for cases when one wants to initialize + * a new CORBA Object + */ + IOP::IOR *steal_ior (void); + + const IOP::IOR &ior (void) const; + protected: /// Initializing a local object. diff --git a/TAO/tao/Object.i b/TAO/tao/Object.i index f8c5034f84f..924fac04cba 100644 --- a/TAO/tao/Object.i +++ b/TAO/tao/Object.i @@ -98,6 +98,30 @@ CORBA::Object::is_evaluated (void) const return this->is_evaluated_; } +ACE_INLINE void +CORBA::Object::set_collocated_servant (TAO_Abstract_ServantBase *b) +{ + this->servant_ = b; + this->is_collocated_ = 1; +} + +ACE_INLINE TAO_ORB_Core * +CORBA::Object::orb_core (void) const +{ + return this->orb_core_; +} + +ACE_INLINE IOP::IOR * +CORBA::Object::steal_ior (void) +{ + return this->ior_._retn (); +} +ACE_INLINE const IOP::IOR & +CORBA::Object::ior (void) const +{ + return this->ior_.in (); +} + // ************************************************************* // Inline operations for class CORBA::Object_var // ************************************************************* diff --git a/TAO/tao/PortableServer/Object_Adapter.cpp b/TAO/tao/PortableServer/Object_Adapter.cpp index cd05ddc4cc5..4728e2ed78a 100644 --- a/TAO/tao/PortableServer/Object_Adapter.cpp +++ b/TAO/tao/PortableServer/Object_Adapter.cpp @@ -860,6 +860,69 @@ TAO_Object_Adapter::create_collocated_object (TAO_Stub *stub, return 0; } +CORBA::Long +TAO_Object_Adapter::initialize_collocated_object (TAO_Stub *stub, + CORBA::Object_ptr obj) +{ + // @@ What about forwarding. With this approach we are never + // forwarded when we use collocation! + const TAO_MProfile &mp = + stub->base_profiles (); + + for (TAO_PHandle j = 0; + j != mp.profile_count (); + ++j) + { + const TAO_Profile *profile = mp.get_profile (j); + TAO_ObjectKey_var objkey = profile->_key (); + + if (ACE_OS::memcmp (objkey->get_buffer (), + &TAO_POA::objectkey_prefix[0], + TAO_POA::TAO_OBJECTKEY_PREFIX_SIZE) != 0) + continue; + + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + TAO_ServantBase *servant = 0; + + TAO_SERVANT_LOCATION servant_location = + this->find_servant (objkey.in (), + servant + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (servant_location != TAO_SERVANT_NOT_FOUND) + { + // Found collocated object. Perhaps we can get around + // by simply setting the servant_orb, but let get this + // to work first. + + // There could only be one ORB which is us. + + // @@ Do not duplicate the ORB here! + // TAO_Stub::servant_orb() duplicates it. + // -Ossama + stub->servant_orb (this->orb_core_.orb ()); + + obj->set_collocated_servant (servant); + + // Here we set the strategized Proxy Broker. + obj->_proxy_broker (the_tao_strategized_object_proxy_broker ()); + + return 1; + } + } + ACE_CATCHANY + { + // Ignore the exception and continue with the next one. + } + ACE_ENDTRY; + } + + return 0; +} + // **************************************************************** TAO_Object_Adapter_Factory::TAO_Object_Adapter_Factory (void) diff --git a/TAO/tao/PortableServer/Object_Adapter.h b/TAO/tao/PortableServer/Object_Adapter.h index 22a365e4607..7218a66024e 100644 --- a/TAO/tao/PortableServer/Object_Adapter.h +++ b/TAO/tao/PortableServer/Object_Adapter.h @@ -328,6 +328,9 @@ public: virtual CORBA::Object_ptr create_collocated_object (TAO_Stub *, const TAO_MProfile &); + virtual CORBA::Long initialize_collocated_object (TAO_Stub *, + CORBA::Object_ptr); + protected: int locate_servant_i (const TAO_ObjectKey &key |