diff options
author | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-03-31 08:21:50 +0000 |
---|---|---|
committer | nanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-03-31 08:21:50 +0000 |
commit | 8f3abd91652d4565ac60abd46a6f9c52698b1652 (patch) | |
tree | 23527efbb150e55d19ee5e836c66895438d77ad8 | |
parent | 300cd46a27b658ffbcc61cd9fef3d13b1677940d (diff) | |
download | ATCD-8f3abd91652d4565ac60abd46a6f9c52698b1652.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/tao/LocalObject.cpp | 672 | ||||
-rw-r--r-- | TAO/tao/LocalObject.h | 126 | ||||
-rw-r--r-- | TAO/tao/LocalObject.i | 161 | ||||
-rw-r--r-- | TAO/tao/Object.cpp | 12 | ||||
-rw-r--r-- | TAO/tao/Object.h | 15 | ||||
-rw-r--r-- | TAO/tao/Object.i | 2 |
6 files changed, 197 insertions, 791 deletions
diff --git a/TAO/tao/LocalObject.cpp b/TAO/tao/LocalObject.cpp index 5bd3372df1e..d8a09fca406 100644 --- a/TAO/tao/LocalObject.cpp +++ b/TAO/tao/LocalObject.cpp @@ -5,14 +5,13 @@ // // ORB: CORBA_Object operations -#include "tao/Object.h" +#include "tao/LocalObject.h" #include "tao/Object_Adapter.h" #include "tao/Stub.h" #include "tao/Servant_Base.h" #include "tao/Request.h" #include "tao/varout.h" #include "tao/ORB_Core.h" -#include "tao/Invocation.h" #include "tao/Connector_Registry.h" #include "tao/debug.h" @@ -28,175 +27,47 @@ ACE_RCSID(tao, Object, "$Id$") -CORBA_Object::~CORBA_Object (void) +CORBA::LocalObject::~CORBA::LocalObject (void) { - if (this->protocol_proxy_) - this->protocol_proxy_->_decr_refcnt (); } -CORBA_Object::CORBA_Object (TAO_Stub *protocol_proxy, - TAO_ServantBase *servant, - CORBA::Boolean collocated) - : servant_ (servant), - is_collocated_ (collocated), - protocol_proxy_ (protocol_proxy), - refcount_ (1), - refcount_lock_ () +void +CORBA::LocalObject::_add_ref (void) { - // Notice that the refcount_ above is initialized to 1 because - // the semantics of CORBA Objects are such that obtaining one - // implicitly takes a reference. + // Do nothing as per CCM spec. } void -CORBA_Object::_tao_any_destructor (void *x) +CORBA::LocalObject::_remove_ref (void) { - CORBA_Object_ptr tmp = ACE_static_cast(CORBA_Object_ptr,x); - CORBA::release (tmp); + // Do nothing as per CCM spec. } // IS_A ... ask the object if it's an instance of the type whose // logical type ID is passed as a parameter. CORBA::Boolean -CORBA_Object::_is_a (const CORBA::Char *type_id, - CORBA::Environment &ACE_TRY_ENV) +CORBA::LocalObject::_is_a (const CORBA::Char *type_id, + CORBA::Environment &ACE_TRY_ENV) { - // NOTE: if istub->type_id is nonzero and we have local knowledge of - // it, we can answer this question without a costly remote call. - // - // That "local knowledge" could come from stubs or skeletons linked - // into this process in the best case, or a "near" repository in a - // slightly worse case. Or in a trivial case, if the ID being asked - // about is the ID we have recorded, we don't need to ask about the - // inheritance relationships at all! - // - // In real systems having local knowledge will be common, though as - // the systems built atop ORBs become richer it'll also become - // common to have the "real type ID" not be directly understood - // because it's more deeply derived than any locally known types. - // - // XXX if type_id is that of CORBA_Object, "yes, we comply" :-) - - if (this->_stubobj ()->type_id.in () != 0 - && ACE_OS::strcmp (type_id, - this->_stubobj ()->type_id.in ()) == 0) - return 1; - - // If the object is collocated then try locally.... - if (this->is_collocated_) - { - // Which collocation strategy should we use? - if (this->protocol_proxy_ != 0 && - this->protocol_proxy_->servant_orb_var ()->orb_core () - ->get_collocation_strategy () == TAO_ORB_Core::THRU_POA) - { - TAO_Object_Adapter::Servant_Upcall servant_upcall - (*this->_stubobj ()->servant_orb_var ()->orb_core () - ->object_adapter ()); - servant_upcall.prepare_for_upcall (this->_object_key (), - "_is_a", - ACE_TRY_ENV); - ACE_CHECK_RETURN (0); - return servant_upcall.servant ()->_is_a (type_id, ACE_TRY_ENV); - } - - // Direct collocation strategy is used. - if (this->servant_ != 0) - return this->servant_->_is_a (type_id, ACE_TRY_ENV); - } - - CORBA::Boolean _tao_retval = 0; - - TAO_Stub *istub = this->_stubobj (); - if (istub == 0) - ACE_THROW_RETURN (CORBA::INTERNAL (), _tao_retval); - - - TAO_GIOP_Twoway_Invocation _tao_call ( - istub, - "_is_a", - 5, - istub->orb_core () - ); - - - // Loop until we succeed or we raise an exception. - // @@ Nanbor: Do we still need to clear the environment variable? - // ACE_TRY_ENV.clear (); - for (;;) - { - _tao_call.start (ACE_TRY_ENV); - ACE_CHECK_RETURN (_tao_retval); - - CORBA::Short flag = 131; - - _tao_call.prepare_header (ACE_static_cast (CORBA::Octet, flag), - ACE_TRY_ENV); - ACE_CHECK_RETURN (_tao_retval); - - TAO_OutputCDR &_tao_out = _tao_call.out_stream (); - if (!( - (_tao_out << type_id) - )) - ACE_THROW_RETURN (CORBA::MARSHAL (), _tao_retval); - - int _invoke_status = - _tao_call.invoke (0, 0, ACE_TRY_ENV); - ACE_CHECK_RETURN (_tao_retval); - - if (_invoke_status == TAO_INVOKE_RESTART) - continue; - // if (_invoke_status == TAO_INVOKE_EXCEPTION) - // cannot happen - if (_invoke_status != TAO_INVOKE_OK) - { - ACE_THROW_RETURN (CORBA::UNKNOWN (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_YES), - _tao_retval); - - } - break; - } - TAO_InputCDR &_tao_in = _tao_call.inp_stream (); - if (!(_tao_in >> CORBA::Any::to_boolean (_tao_retval))) - ACE_THROW_RETURN (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_YES), - _tao_retval); - return _tao_retval; + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); } const char* -CORBA_Object::_interface_repository_id (void) const -{ - return "IDL:omg.org/CORBA/Object:1.0"; -} - -TAO_ServantBase * -CORBA_Object::_servant (void) const -{ - return this->servant_; -} - -CORBA::Boolean -CORBA_Object::_is_collocated (void) const +CORBA::LocalObject::_interface_repository_id (void) const { - return this->is_collocated_; + return "IDL:omg.org/CORBA/LocalObject:1.0"; } // Quickly hash an object reference's representation data. Used to // create hash tables. CORBA::ULong -CORBA_Object::_hash (CORBA::ULong maximum, - CORBA::Environment &ACE_TRY_ENV) +CORBA::LocalObject::_hash (CORBA::ULong maximum, + CORBA::Environment &ACE_TRY_ENV) { - if (this->protocol_proxy_ != 0) - return this->protocol_proxy_->hash (maximum, ACE_TRY_ENV); - else - // @@ I really don't know how to support this for - // a locality constrained object. -- nw. - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); + // @@ We need a different hash function here. + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); } // Compare two object references to see if they point to the same @@ -206,46 +77,20 @@ CORBA_Object::_hash (CORBA::ULong maximum, // such as strcmp(), to allow more comparison algorithms. CORBA::Boolean -CORBA_Object::_is_equivalent (CORBA_Object_ptr other_obj, - CORBA::Environment &) +CORBA::LocalObject::_is_equivalent (CORBA::LocalObject_ptr other_obj, + CORBA::Environment &) ACE_THROW_SPEC (()) { - if (other_obj == this) - { - return 1; - } - - if (this->protocol_proxy_ != 0) - return this->protocol_proxy_->is_equivalent (other_obj); - else - return this->servant_ == other_obj->servant_; + return (other_obj == this) ? 1 : 0; } // TAO's extensions TAO_ObjectKey * -CORBA::Object::_key (CORBA::Environment &) -{ - if (this->_stubobj () && this->_stubobj ()->profile_in_use ()) - return this->_stubobj ()->profile_in_use ()->_key (); - - ACE_ERROR_RETURN((LM_ERROR, ASYS_TEXT ("(%P|%t) Null stub obj!!!\n")), 0); -} - -const TAO_ObjectKey & -CORBA::Object::_object_key (void) -{ - return this->_stubobj ()->profile_in_use ()->object_key (); -} - -// @@ This doesn't seemed to be used anyplace! It should go away!! FRED -void -CORBA::Object::_use_locate_requests (CORBA::Boolean use_it) +CORBA::LObject::_key (CORBA::Environment &ACE_TRY_ENV) { - if ( this->_stubobj () ) - this->_stubobj ()->use_locate_requests (use_it); - - return; + ACE_ERROR((LM_ERROR, ASYS_TEXT ("(%P|%t) Cannot get _key froma LocalObject!!!\n"))); + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); } #if (TAO_HAS_MINIMUM_CORBA == 0) @@ -255,483 +100,96 @@ CORBA::Object::_use_locate_requests (CORBA::Boolean use_it) // the latter case, return FALSE. CORBA::Boolean -CORBA_Object::_non_existent (CORBA::Environment &ACE_TRY_ENV) +CORBA::LocalObject::_non_existent (CORBA::Environment &) { - CORBA::Boolean _tao_retval = 0; - - ACE_TRY - { - // If the object is collocated then try locally.... - if (this->is_collocated_) - { - // Which collocation strategy should we use? - if (this->protocol_proxy_ != 0 && - this->protocol_proxy_->servant_orb_var ()->orb_core () - ->get_collocation_strategy () == TAO_ORB_Core::THRU_POA) - { - TAO_Object_Adapter::Servant_Upcall servant_upcall - (*this->_stubobj ()->servant_orb_var ()->orb_core ()->object_adapter ()); - servant_upcall.prepare_for_upcall (this->_object_key (), - "_non_existent", - ACE_TRY_ENV); - ACE_TRY_CHECK; - return servant_upcall.servant ()->_non_existent (ACE_TRY_ENV); - } - - // Direct collocation strategy is used. - if (this->servant_ != 0) - return this->servant_->_non_existent (ACE_TRY_ENV); - } - - // Must catch exceptions, if the server raises a - // CORBA::OBJECT_NOT_EXIST then we must return 1, instead of - // propagating the exception. - TAO_Stub *istub = this->_stubobj (); - if (istub == 0) - ACE_THROW_RETURN (CORBA::INTERNAL (), _tao_retval); - - - TAO_GIOP_Twoway_Invocation _tao_call ( - istub, - "_non_existent", - 13, - istub->orb_core () - ); - - - // ACE_TRY_ENV.clear (); - for (;;) - { - _tao_call.start (ACE_TRY_ENV); - ACE_TRY_CHECK; - - CORBA::Short flag = 131; - - _tao_call.prepare_header (ACE_static_cast (CORBA::Octet, flag), - ACE_TRY_ENV); - ACE_TRY_CHECK; - - int _invoke_status = - _tao_call.invoke (0, 0, ACE_TRY_ENV); - ACE_TRY_CHECK; - - if (_invoke_status == TAO_INVOKE_RESTART) - continue; - ACE_ASSERT (_invoke_status != TAO_INVOKE_EXCEPTION); - if (_invoke_status != TAO_INVOKE_OK) - { - ACE_THROW_RETURN (CORBA::UNKNOWN (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_YES), - _tao_retval); - } - break; - } - TAO_InputCDR &_tao_in = _tao_call.inp_stream (); - if (!( - (_tao_in >> CORBA::Any::to_boolean (_tao_retval)) - )) - ACE_THROW_RETURN (CORBA::MARSHAL (), _tao_retval); - } - ACE_CATCH (CORBA::OBJECT_NOT_EXIST, ex) - { - _tao_retval = 1; - } - ACE_CATCHANY - { - ACE_RETHROW; - } - ACE_ENDTRY; - return _tao_retval; + return 0; // Always returns false. } void -CORBA_Object::_create_request (CORBA::Context_ptr ctx, - const CORBA::Char *operation, - CORBA::NVList_ptr arg_list, - CORBA::NamedValue_ptr result, - CORBA::Request_ptr &request, - CORBA::Flags req_flags, - CORBA::Environment &ACE_TRY_ENV) +CORBA::LocalObject::_create_request (CORBA::Context_ptr, + const CORBA::Char *, + CORBA::NVList_ptr, + CORBA::NamedValue_ptr, + CORBA::Request_ptr &, + CORBA::Flags, + CORBA::Environment &ACE_TRY_ENV) { - // Since we don't really support Context, anything but a null pointer - // is a no-no. - Jeff - // Neither can we create a request object from locality constraint - // object references. - if (ctx || this->protocol_proxy_ == 0) - ACE_THROW (CORBA::NO_IMPLEMENT ()); - - ACE_NEW_THROW_EX (request, - CORBA::Request (this, - this->protocol_proxy_->orb_core ()-> orb (), - operation, - arg_list, - result, - req_flags, - ACE_TRY_ENV), - CORBA::NO_MEMORY ()); + ACE_THROW (CORBA::NO_IMPLEMENT ()); } void -CORBA_Object::_create_request (CORBA::Context_ptr ctx, - const CORBA::Char *operation, - CORBA::NVList_ptr arg_list, - CORBA::NamedValue_ptr result, - CORBA::ExceptionList_ptr, - CORBA::ContextList_ptr, - CORBA::Request_ptr &request, - CORBA::Flags req_flags, - CORBA::Environment &ACE_TRY_ENV) +CORBA::LocalObject::_create_request (CORBA::Context_ptr, + const CORBA::Char *, + CORBA::NVList_ptr, + CORBA::NamedValue_ptr, + CORBA::ExceptionList_ptr, + CORBA::ContextList_ptr, + CORBA::Request_ptr &, + CORBA::Flags, + CORBA::Environment &ACE_TRY_ENV) { - // Since we don't really support Context, anything but a null pointer - // is a no-no. - // Neither can we create a request object from locality constraint - // object references. - if (ctx || this->protocol_proxy_ == 0) - ACE_THROW (CORBA::NO_IMPLEMENT ()); - - ACE_NEW_THROW_EX (request, - CORBA::Request (this, - this->protocol_proxy_->orb_core ()->orb (), - operation, - arg_list, - result, - req_flags, - ACE_TRY_ENV), - CORBA::NO_MEMORY ()); + ACE_THROW (CORBA::NO_IMPLEMENT ()); } CORBA::Request_ptr -CORBA_Object::_request (const CORBA::Char *operation, - CORBA::Environment &ACE_TRY_ENV) +CORBA::LocalObject::_request (const CORBA::Char *, + CORBA::Environment &ACE_TRY_ENV) { - // ACE_TRY_ENV.clear (); - if (this->protocol_proxy_) - { - CORBA::Request_ptr req = CORBA::Request::_nil (); - ACE_NEW_THROW_EX (req, - CORBA::Request (this, - this->protocol_proxy_->orb_core ()->orb (), - operation, - ACE_TRY_ENV), - CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (CORBA::Request::_nil ()); - - return req; - } - else - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::Request::_nil ()); + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::Request::_nil ()); } CORBA::InterfaceDef_ptr -CORBA_Object::_get_interface (CORBA::Environment &ACE_TRY_ENV) +CORBA::LocalObject::_get_interface (CORBA::Environment &ACE_TRY_ENV) { -#if (TAO_HAS_INTERFACE_REPOSITORY == 1) - CORBA::InterfaceDef_ptr _tao_retval = CORBA::InterfaceDef::_nil(); -#else - CORBA::InterfaceDef_ptr _tao_retval = 0; -#endif /* TAO_HAS_INTERFACE_REPOSITORY == 1 */ - - TAO_Stub *istub = this->_stubobj (); - if (istub == 0) - ACE_THROW_RETURN (CORBA::INTERNAL (), _tao_retval); - - - TAO_GIOP_Twoway_Invocation _tao_call ( - istub, - "_interface", - 10, - istub->orb_core () - ); - - for (;;) - { - _tao_call.start (ACE_TRY_ENV); - ACE_CHECK_RETURN (_tao_retval); - - CORBA::Short flag = 131; - - _tao_call.prepare_header (ACE_static_cast (CORBA::Octet, flag), - ACE_TRY_ENV); - ACE_CHECK_RETURN (_tao_retval); - - int _invoke_status = - _tao_call.invoke (0, 0, ACE_TRY_ENV); - ACE_CHECK_RETURN (_tao_retval); - - if (_invoke_status == TAO_INVOKE_RESTART) - continue; - // if (_invoke_status == TAO_INVOKE_EXCEPTION) - // cannot happen - if (_invoke_status != TAO_INVOKE_OK) - { - ACE_THROW_RETURN (CORBA::UNKNOWN (TAO_DEFAULT_MINOR_CODE, - CORBA::COMPLETED_YES), - _tao_retval); - } - break; - } - -#if (TAO_HAS_INTERFACE_REPOSITORY == 1) - TAO_InputCDR &_tao_in = _tao_call.inp_stream (); - if (!( - (_tao_in >> _tao_retval) - )) - ACE_THROW_RETURN (CORBA::MARSHAL (), _tao_retval); - - return _tao_retval; -#else - ACE_UNUSED_ARG (_tao_retval); - ACE_THROW_RETURN (CORBA::INTF_REPOS (), _tao_retval); -#endif /* TAO_HAS_INTERFACE_REPOSITORY == 1 */ + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::InterfaceDef::_nil ()); } CORBA::ImplementationDef_ptr -CORBA_Object::_get_implementation (CORBA::Environment &) +CORBA::LocalObject::_get_implementation (CORBA::Environment &ACE_TRY_ENV) { - return 0; + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::ImplementationDef::_nil ()); } #endif /* TAO_HAS_MINIMUM_CORBA */ // **************************************************************** -// @@ Does it make sense to support policy stuff for locality constrained -// objects? Also, does it make sense to bind policies with stub object? -// - nw. - #if (TAO_HAS_CORBA_MESSAGING == 1) CORBA::Policy_ptr -CORBA_Object::_get_policy ( - CORBA::PolicyType type, - CORBA::Environment &ACE_TRY_ENV) +CORBA::LocalObject::_get_policy (CORBA::PolicyType, + CORBA::Environment &ACE_TRY_ENV) { - if (this->protocol_proxy_) - return this->protocol_proxy_->get_policy (type, ACE_TRY_ENV); - else - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::Policy::_nil ()); + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::Policy::_nil ()); } CORBA::Policy_ptr -CORBA_Object::_get_client_policy ( - CORBA::PolicyType type, - CORBA::Environment &ACE_TRY_ENV) +CORBA::LocalObject::_get_client_policy (CORBA::PolicyType, + CORBA::Environment &ACE_TRY_ENV) { - if (this->protocol_proxy_) - return this->_stubobj ()->get_client_policy (type, ACE_TRY_ENV); - else - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::Policy::_nil ()); + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::Policy::_nil ()); } CORBA::Object_ptr -CORBA_Object::_set_policy_overrides ( - const CORBA::PolicyList & policies, - CORBA::SetOverrideType set_add, - CORBA::Environment &ACE_TRY_ENV) +CORBA::LocalObject::_set_policy_overrides (const CORBA::PolicyList &, + CORBA::SetOverrideType, + CORBA::Environment &ACE_TRY_ENV) { - if (!this->protocol_proxy_) - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::Policy::_nil ()); - - TAO_Stub* stub = - this->protocol_proxy_->set_policy_overrides (policies, - set_add, - ACE_TRY_ENV); - ACE_CHECK_RETURN (CORBA::Object::_nil ()); - - CORBA::Object_ptr obj = CORBA::Object::_nil (); - - ACE_NEW_THROW_EX (obj, - CORBA_Object (stub, - this->servant_, - this->is_collocated_), - CORBA::NO_MEMORY ()); - ACE_CHECK_RETURN (CORBA::Object::_nil ()); - - return obj; + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), CORBA::Policy::_nil ()); } CORBA::PolicyList * -CORBA_Object::_get_policy_overrides (const CORBA::PolicyTypeSeq & types, - CORBA::Environment &ACE_TRY_ENV) +CORBA::LocalObject::_get_policy_overrides (const CORBA::PolicyTypeSeq &, + CORBA::Environment &ACE_TRY_ENV) { - if (this->protocol_proxy_) - return this->protocol_proxy_->get_policy_overrides (types, ACE_TRY_ENV); - else - ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); } CORBA::Boolean -CORBA_Object::_validate_connection (CORBA::PolicyList_out inconsistent_policies, - CORBA::Environment &ACE_TRY_ENV) +CORBA::LocalObject::_validate_connection (CORBA::PolicyList_out, + CORBA::Environment &ACE_TRY_ENV) { - inconsistent_policies = 0; - -#if (TAO_HAS_MINIMUM_CORBA == 1) - - ACE_UNUSED_ARG (ACE_TRY_ENV); - -#else - - // If the object is collocated then use non_existent to see whether - // it's there. - if (this->is_collocated_) - return !(this->_non_existent (ACE_TRY_ENV)); - - if (this->protocol_proxy_) - return this->protocol_proxy_->validate_connection (inconsistent_policies, - ACE_TRY_ENV); - -#endif /* TAO_HAS_MINIMUM_CORBA */ - - return 0; + ACE_THROW_RETURN (CORBA::NO_IMPLEMENT (), 0); } #endif /* TAO_HAS_CORBA_MESSAGING == 1 */ - -// **************************************************************** - -CORBA::Boolean -operator<< (TAO_OutputCDR& cdr, const CORBA_Object* x) -{ - if (x == 0) - { - // NIL objrefs ... marshal as empty type hint, no elements. - cdr.write_ulong (1); - cdr.write_char ('\0'); - cdr.write_ulong (0); - return (CORBA::Boolean) cdr.good_bit (); - } - - TAO_Stub *stubobj = x->_stubobj (); - - if (stubobj == 0) - return 0; - - // STRING, a type ID hint - if ((cdr << stubobj->type_id.in ()) == 0) - return 0; - - const TAO_MProfile& mprofile = stubobj->base_profiles (); - - CORBA::ULong profile_count = mprofile.profile_count (); - if ((cdr << profile_count) == 0) - return 0; - - // @@ The MProfile should be locked during this iteration, is there - // anyway to achieve that? - for (CORBA::ULong i = 0; i < profile_count; ++i) - { - const TAO_Profile* p = mprofile.get_profile (i); - if (p->encode (cdr) == 0) - return 0; - } - return (CORBA::Boolean) cdr.good_bit (); -} - -CORBA::Boolean -operator>> (TAO_InputCDR& cdr, CORBA_Object*& x) -{ - CORBA::String_var type_hint; - - if ((cdr >> type_hint.inout ()) == 0) - return 0; - - CORBA::ULong profile_count; - if ((cdr >> profile_count) == 0) - return 0; - - if (profile_count == 0) - { - x = CORBA::Object::_nil (); - return (CORBA::Boolean) cdr.good_bit (); - } - - // get a profile container to store all profiles in the IOR. - TAO_MProfile mp (profile_count); - - TAO_ORB_Core *orb_core = cdr.orb_core (); - if (orb_core == 0) - { - orb_core = TAO_ORB_Core_instance (); - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("WARNING: extracting object from default ORB_Core\n"))); - } - } - - TAO_Connector_Registry *connector_registry = - orb_core->connector_registry (); - for (CORBA::ULong i = 0; i != profile_count && cdr.good_bit (); ++i) - { - TAO_Profile *pfile = - connector_registry->create_profile (cdr); - if (pfile != 0) - mp.give_profile (pfile); - } - - // make sure we got some profiles! - if (mp.profile_count () != profile_count) - { - ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("TAO (%P|%t) could not create all ") - ASYS_TEXT ("the profiles\n"))); - return 0; - } - - // Ownership of type_hint is given to TAO_Stub - // TAO_Stub will make a copy of mp! - TAO_Stub *objdata = 0; - ACE_NEW_RETURN (objdata, TAO_Stub (type_hint._retn (), - mp, - cdr.orb_core ()), 0); - - TAO_Stub_Auto_Ptr safe_objdata (objdata); - - // Figure out if the servant is collocated. - TAO_ServantBase *servant = 0; - TAO_SERVANT_LOCATION servant_location = - objdata->orb_core ()->orb ()->_get_collocated_servant (safe_objdata.get (), - servant); - - int collocated = 0; - if (servant_location != TAO_SERVANT_NOT_FOUND) - collocated = 1; - - // Create a new CORBA_Object and give it the TAO_Stub just created. - ACE_NEW_RETURN (x, - CORBA_Object (safe_objdata.get (), - servant, - (CORBA::Boolean) collocated), - 0); - - // It is now safe to release the TAO_Stub from the TAO_Stub_Auto_Ptr. - objdata = safe_objdata.release (); - - // the corba proxy would have already incremented the reference count on - // the objdata. So we decrement it here by 1 so that the objdata is now - // fully owned by the corba_proxy that was created. - // objdata->_decr_refcnt (); - - return (CORBA::Boolean) cdr.good_bit (); -} - -// **************************************************************** - -TAO_Object_Field::~TAO_Object_Field (void) -{ -} - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) - -template class TAO_Object_Field_T<CORBA_Object,CORBA_Object_var>; -template class auto_ptr<TAO_MProfile>; -template class ACE_Auto_Basic_Ptr<TAO_MProfile>; - -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) - -#pragma instantiate TAO_Object_Field_T<CORBA_Object,CORBA_Object_var> -#pragma instantiate auto_ptr<TAO_MProfile> -#pragma instantiate ACE_Auto_Basic_Ptr<TAO_MProfile> - -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/TAO/tao/LocalObject.h b/TAO/tao/LocalObject.h index b22b71d60e0..d8478839361 100644 --- a/TAO/tao/LocalObject.h +++ b/TAO/tao/LocalObject.h @@ -53,16 +53,6 @@ public: TAO_default_environment ()); // no-op it is just here to simplify some templates. - static void _tao_any_destructor (void*); - // @@ Does this stuff make sense at all in LocalObject? - // Used in the implementation of CORBA::Any - - // These calls correspond to over-the-wire operations, or at least - // do so in many common cases. The normal implementation assumes a - // particular simple, efficient, protocol-neutral interface for - // making such calls, but may be overridden when it appears - // appropriate. - virtual CORBA::Boolean _is_a (const CORBA::Char *logical_type_id, CORBA_Environment &ACE_TRY_ENV = TAO_default_environment ()); @@ -72,14 +62,6 @@ public: // The repository ID for the most derived class, this is an // implementation method and does no remote invocations! - virtual TAO_ServantBase *_servant (void) const; - // return 0. - - virtual CORBA::Boolean _is_collocated (void) const; - // return 0 (even if local object is always collocated, there's no - // servant associate with the object (the object itself implement - // all operations. - #if (TAO_HAS_MINIMUM_CORBA == 0) virtual CORBA::Boolean _non_existent (CORBA_Environment &ACE_TRY_ENV = @@ -96,6 +78,34 @@ public: TAO_default_environment ()); // throws NO_IMPLEMENT. + virtual void _create_request (CORBA::Context_ptr ctx, + const CORBA::Char *operation, + CORBA::NVList_ptr arg_list, + CORBA::NamedValue_ptr result, + CORBA::Request_ptr &request, + CORBA::Flags req_flags, + CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment ()); + // throws NO_IMPLEMENT. + + virtual void _create_request (CORBA::Context_ptr ctx, + const CORBA::Char *operation, + CORBA::NVList_ptr arg_list, + CORBA::NamedValue_ptr result, + CORBA::ExceptionList_ptr exclist, + CORBA::ContextList_ptr ctxtlist, + CORBA::Request_ptr &request, + CORBA::Flags req_flags, + CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment ()); + + // throws NO_IMPLEMENT. + + virtual CORBA::Request_ptr _request (const CORBA::Char *operation, + CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment ()); + // throws NO_IMPLEMENT. + #endif /* TAO_HAS_MINIMUM_CORBA */ #if (TAO_HAS_CORBA_MESSAGING == 1) @@ -156,75 +166,43 @@ public: // private state. Since that changes easily (when different ORB // protocols are in use) there is no default implementation. + virtual TAO_ObjectKey *_key (CORBA_Environment &ACE_TRY_ENV = + TAO_default_environment ()); + // throws NO_IMPLEMENT. + +#if 0 + virtual const TAO_ObjectKey &_object_key (void); + // Return a reference to the object key of profile in-use. + // If there's no in-use profile, then the program will + // probably crash. This method does not create a new copy. +#endif /* 0 */ + #if !defined(__GNUC__) || __GNUC__ > 2 || __GNUC_MINOR__ >= 8 - typedef CORBA_Object_ptr _ptr_type; - typedef CORBA_Object_var _var_type; + typedef CORBA::LocalObject_ptr _ptr_type; + typedef CORBA::LocalObject_var _var_type; #endif /* __GNUC__ */ // Useful for template programming. - // = TAO extensions - // = Reference count managment. - CORBA::ULong _incr_refcnt (void); + virtual void _add_ref (void); // Increment the reference count. - CORBA::ULong _decr_refcnt (void); + virtual void _remove_ref (void); // Decrement the reference count. + // = TAO extensions + protected: private: -#if (TAO_HAS_MINIMUM_CORBA==0) - virtual void _create_request (CORBA::Context_ptr ctx, - const CORBA::Char *operation, - CORBA::NVList_ptr arg_list, - CORBA::NamedValue_ptr result, - CORBA::Request_ptr &request, - CORBA::Flags req_flags, - CORBA_Environment &ACE_TRY_ENV = - TAO_default_environment ()); - - virtual void _create_request (CORBA::Context_ptr ctx, - const CORBA::Char *operation, - CORBA::NVList_ptr arg_list, - CORBA::NamedValue_ptr result, - CORBA::ExceptionList_ptr exclist, - CORBA::ContextList_ptr ctxtlist, - CORBA::Request_ptr &request, - CORBA::Flags req_flags, - CORBA_Environment &ACE_TRY_ENV = - TAO_default_environment ()); - - // The default implementation of this method uses the same simple, - // multi-protocol remote invocation interface as is assumed by the - // calls above ... that's how it can have a default implementation. - - virtual CORBA::Request_ptr _request (const CORBA::Char *operation, - CORBA_Environment &ACE_TRY_ENV = - TAO_default_environment ()); - // DII operation to create a request. - -#endif /* TAO_HAS_MINIMUM_CORBA == 0 */ - - virtual TAO_ObjectKey *_key (CORBA_Environment &ACE_TRY_ENV = - TAO_default_environment ()); - // Return the object key as an out parameter. Caller should release - // return value when finished with it. - - virtual const TAO_ObjectKey &_object_key (void); - // Return a reference to the object key of profile in-use. - // If there's no in-use profile, then the program will - // probably crash. This method does not create a new copy. - - virtual TAO_Stub *_stubobj (void) const; - // get the underlying stub object - - virtual void _use_locate_requests (CORBA::Boolean use_it); - // the the object to use a locate request for the first call to - // the object // = Unimplemented methods - CORBA_Object (const CORBA_Object &); - CORBA_Object &operator = (const CORBA_Object &); + LocalObject (TAO_Stub *p = 0, + TAO_ServantBase *servant = 0, + CORBA::Boolean collocated = 0); + // constructor + + LocalObject (const CORBA_Object &); + LocalObject &operator = (const CORBA_Object &); }; class TAO_Export CORBA::LocalObject_var diff --git a/TAO/tao/LocalObject.i b/TAO/tao/LocalObject.i index 232315bddfc..87e03ecda21 100644 --- a/TAO/tao/LocalObject.i +++ b/TAO/tao/LocalObject.i @@ -2,29 +2,8 @@ // **************************************************************** -ACE_INLINE CORBA::ULong -CORBA_Object::_incr_refcnt (void) -{ - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, guard, this->refcount_lock_, 0); - return this->refcount_++; -} - -ACE_INLINE CORBA::ULong -CORBA_Object::_decr_refcnt (void) -{ - { - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, mon, this->refcount_lock_, 0); - this->refcount_--; - if (this->refcount_ != 0) - return this->refcount_; - } - - delete this; - return 0; -} - -ACE_INLINE CORBA_Object_ptr -CORBA_Object::_duplicate (CORBA_Object_ptr obj) +ACE_INLINE CORBA::LocalObject_ptr +CORBA::LocalObject::_duplicate (CORBA::LocalObject_ptr obj) { if (obj) obj->_incr_refcnt (); @@ -33,209 +12,181 @@ CORBA_Object::_duplicate (CORBA_Object_ptr obj) // Null pointers represent nil objects. -ACE_INLINE CORBA_Object_ptr -CORBA_Object::_nil (void) +ACE_INLINE CORBA::LocalObject_ptr +CORBA::LocalObject::_nil (void) { return 0; } -ACE_INLINE CORBA_Object_ptr -CORBA_Object::_narrow (CORBA_Object_ptr obj, CORBA::Environment&) -{ - return CORBA_Object::_duplicate (obj); -} - -ACE_INLINE CORBA_Object_ptr -CORBA_Object::_unchecked_narrow (CORBA_Object_ptr obj, CORBA::Environment&) -{ - return CORBA_Object::_duplicate (obj); -} - -ACE_INLINE TAO_Stub * -CORBA_Object::_stubobj (void) const +ACE_INLINE CORBA::LocalObject_ptr +CORBA::LocalObject::_narrow (CORBA_Object_ptr obj, CORBA::Environment&) { - return this->protocol_proxy_; + return CORBA::LocalObject::_duplicate (obj); } -// ************************************************************ -// These are in CORBA namespace - -ACE_INLINE CORBA::Boolean -CORBA::is_nil (CORBA::Object_ptr obj) +ACE_INLINE CORBA::LocalObject_ptr +CORBA::LocalObject::_unchecked_narrow (CORBA_Object_ptr obj, CORBA::Environment&) { - return obj == 0; + return CORBA::LocalObject::_duplicate (obj); } -ACE_INLINE void -CORBA::release (CORBA_Object_ptr obj) -{ - if (obj) - obj->_decr_refcnt (); -} - -// DII hook to objref -// -// The mapping for create_request is split into two forms, -// corresponding to the two usage styles described in CORBA section -// 6.2.1. - // ************************************************************* -// Inline operations for class CORBA_Object_var +// Inline operations for class CORBA::LocalObject_var // ************************************************************* ACE_INLINE -CORBA_Object_var::CORBA_Object_var (void) - : ptr_ (CORBA_Object::_nil ()) +CORBA::LocalObject_var::CORBA::LocalObject_var (void) + : ptr_ (CORBA::LocalObject::_nil ()) { } ACE_INLINE -CORBA_Object_var::CORBA_Object_var (CORBA_Object_ptr p) +CORBA::LocalObject_var::CORBA::LocalObject_var (CORBA::LocalObject_ptr p) : ptr_ (p) {} ACE_INLINE -CORBA_Object_var::~CORBA_Object_var (void) +CORBA::LocalObject_var::~CORBA::LocalObject_var (void) { CORBA::release (this->ptr_); } ACE_INLINE CORBA_Object_ptr -CORBA_Object_var::ptr (void) const +CORBA::LocalObject_var::ptr (void) const { return this->ptr_; } ACE_INLINE -CORBA_Object_var::CORBA_Object_var (const CORBA_Object_var &p) // copy constructor - : ptr_ (CORBA_Object::_duplicate (p.ptr ())) +CORBA::LocalObject_var::CORBA::LocalObject_var (const CORBA::LocalObject_var &p) // copy constructor + : ptr_ (CORBA::LocalObject::_duplicate (p.ptr ())) {} -ACE_INLINE CORBA_Object_var & -CORBA_Object_var::operator= (CORBA_Object_ptr p) +ACE_INLINE CORBA::LocalObject_var & +CORBA::LocalObject_var::operator= (CORBA::LocalObject_ptr p) { CORBA::release (this->ptr_); this->ptr_ = p; return *this; } -ACE_INLINE CORBA_Object_var & -CORBA_Object_var::operator= (const CORBA_Object_var &p) +ACE_INLINE CORBA::LocalObject_var & +CORBA::LocalObject_var::operator= (const CORBA::LocalObject_var &p) { if (this != &p) { CORBA::release (this->ptr_); - this->ptr_ = CORBA_Object::_duplicate (p.ptr ()); + this->ptr_ = CORBA::LocalObject::_duplicate (p.ptr ()); } return *this; } ACE_INLINE -CORBA_Object_var::operator const CORBA_Object_ptr &() const // cast +CORBA::LocalObject_var::operator const CORBA::LocalObject_ptr &() const // cast { return this->ptr_; } ACE_INLINE -CORBA_Object_var::operator CORBA_Object_ptr &() // cast +CORBA::LocalObject_var::operator CORBA::LocalObject_ptr &() // cast { return this->ptr_; } -ACE_INLINE CORBA_Object_ptr -CORBA_Object_var::operator-> (void) const +ACE_INLINE CORBA::LocalObject_ptr +CORBA::LocalObject_var::operator-> (void) const { return this->ptr_; } -ACE_INLINE CORBA_Object_ptr -CORBA_Object_var::in (void) const +ACE_INLINE CORBA::LocalObject_ptr +CORBA::LocalObject_var::in (void) const { return this->ptr_; } -ACE_INLINE CORBA_Object_ptr & -CORBA_Object_var::inout (void) +ACE_INLINE CORBA::LocalObject_ptr & +CORBA::LocalObject_var::inout (void) { return this->ptr_; } -ACE_INLINE CORBA_Object_ptr & -CORBA_Object_var::out (void) +ACE_INLINE CORBA::LocalObject_ptr & +CORBA::LocalObject_var::out (void) { CORBA::release (this->ptr_); - this->ptr_ = CORBA_Object::_nil (); + this->ptr_ = CORBA::LocalObject::_nil (); return this->ptr_; } -ACE_INLINE CORBA_Object_ptr -CORBA_Object_var::_retn (void) +ACE_INLINE CORBA::LocalObject_ptr +CORBA::LocalObject_var::_retn (void) { // yield ownership of managed obj reference - CORBA_Object_ptr val = this->ptr_; - this->ptr_ = CORBA_Object::_nil (); + CORBA::LocalObject_ptr val = this->ptr_; + this->ptr_ = CORBA::LocalObject::_nil (); return val; } // ************************************************************* -// Inline operations for class CORBA_Object_out +// Inline operations for class CORBA::LocalObject_out // ************************************************************* ACE_INLINE -CORBA_Object_out::CORBA_Object_out (CORBA_Object_ptr &p) +CORBA::LocalObject_out::CORBA::LocalObject_out (CORBA::LocalObject_ptr &p) : ptr_ (p) { - this->ptr_ = CORBA_Object::_nil (); + this->ptr_ = CORBA::LocalObject::_nil (); } ACE_INLINE -CORBA_Object_out::CORBA_Object_out (CORBA_Object_var &p) // constructor from _var +CORBA::LocalObject_out::CORBA::LocalObject_out (CORBA::LocalObject_var &p) // constructor from _var : ptr_ (p.out ()) { CORBA::release (this->ptr_); - this->ptr_ = CORBA_Object::_nil (); + this->ptr_ = CORBA::LocalObject::_nil (); } ACE_INLINE -CORBA_Object_out::CORBA_Object_out (const CORBA_Object_out &p) // copy constructor +CORBA::LocalObject_out::CORBA::LocalObject_out (const CORBA::LocalObject_out &p) // copy constructor : ptr_ (p.ptr_) {} -ACE_INLINE CORBA_Object_out & -CORBA_Object_out::operator= (const CORBA_Object_out &p) +ACE_INLINE CORBA::LocalObject_out & +CORBA::LocalObject_out::operator= (const CORBA::LocalObject_out &p) { this->ptr_ = p.ptr_; return *this; } -ACE_INLINE CORBA_Object_out & -CORBA_Object_out::operator= (const CORBA_Object_var &p) +ACE_INLINE CORBA::LocalObject_out & +CORBA::LocalObject_out::operator= (const CORBA::LocalObject_var &p) { - this->ptr_ = CORBA_Object::_duplicate (p.ptr ()); + this->ptr_ = CORBA::LocalObject::_duplicate (p.ptr ()); return *this; } -ACE_INLINE CORBA_Object_out & -CORBA_Object_out::operator= (CORBA_Object_ptr p) +ACE_INLINE CORBA::LocalObject_out & +CORBA::LocalObject_out::operator= (CORBA::LocalObject_ptr p) { this->ptr_ = p; return *this; } ACE_INLINE -CORBA_Object_out::operator CORBA_Object_ptr &() // cast +CORBA::LocalObject_out::operator CORBA::LocalObject_ptr &() // cast { return this->ptr_; } -ACE_INLINE CORBA_Object_ptr & -CORBA_Object_out::ptr (void) // ptr +ACE_INLINE CORBA::LocalObject_ptr & +CORBA::LocalObject_out::ptr (void) // ptr { return this->ptr_; } -ACE_INLINE CORBA_Object_ptr -CORBA_Object_out::operator-> (void) +ACE_INLINE CORBA::LocalObject_ptr +CORBA::LocalObject_out::operator-> (void) { return this->ptr_; } diff --git a/TAO/tao/Object.cpp b/TAO/tao/Object.cpp index 5bd3372df1e..8e948611999 100644 --- a/TAO/tao/Object.cpp +++ b/TAO/tao/Object.cpp @@ -49,6 +49,18 @@ CORBA_Object::CORBA_Object (TAO_Stub *protocol_proxy, } void +CORBA_Object::_add_ref (void) +{ + this->incr_refcnt (); +} + +void +CORBA_Object::_remove_ref (void) +{ + this->decr_refcnt (); +} + +void CORBA_Object::_tao_any_destructor (void *x) { CORBA_Object_ptr tmp = ACE_static_cast(CORBA_Object_ptr,x); diff --git a/TAO/tao/Object.h b/TAO/tao/Object.h index 0bf684025b0..575d3e6d075 100644 --- a/TAO/tao/Object.h +++ b/TAO/tao/Object.h @@ -197,15 +197,15 @@ public: #endif /* __GNUC__ */ // Useful for template programming. - // = TAO extensions - // = Reference count managment. - CORBA::ULong _incr_refcnt (void); + virtual void _add_ref (void); // Increment the reference count. - CORBA::ULong _decr_refcnt (void); + virtual void _remove_ref (void); // Decrement the reference count. + // = TAO extensions + CORBA_Object (TAO_Stub *p = 0, TAO_ServantBase *servant = 0, CORBA::Boolean collocated = 0); @@ -219,6 +219,13 @@ public: // the object protected: + // = Internal Reference count managment. + CORBA::ULong _incr_refcnt (void); + // Increment the reference count. + + CORBA::ULong _decr_refcnt (void); + // Decrement the reference count. + TAO_ServantBase *servant_; // Servant pointer. It is 0 except for collocated objects. diff --git a/TAO/tao/Object.i b/TAO/tao/Object.i index 232315bddfc..f4acc070d1e 100644 --- a/TAO/tao/Object.i +++ b/TAO/tao/Object.i @@ -70,7 +70,7 @@ ACE_INLINE void CORBA::release (CORBA_Object_ptr obj) { if (obj) - obj->_decr_refcnt (); + obj->_remove_ref (); } // DII hook to objref |