#include "tao/LocateRequest_Invocation_Adapter.h"#include "tao/Profile_Transport_Resolver.h"#include "tao/operation_details.h"#include "tao/LocateRequest_Invocation.h"#include "tao/Transport.h"#include "tao/Transport_Mux_Strategy.h"#include "tao/GIOP_Utils.h"#include "tao/ORB_Core.h"#include "tao/Stub.h"#include "tao/SystemException.h"#include "ace/Service_Config.h"
Go to the source code of this file.
Functions | |
| ACE_RCSID (tao, LocateRequest_Invocation_Adapter,"$Id: LocateRequest_Invocation_Adapter.cpp 85483 2009-06-02 06:48:10Z johnnyw $") 1 namespace TAO | |
| ACE_RCSID | ( | tao | , | |
| LocateRequest_Invocation_Adapter | , | |||
| "$Id: LocateRequest_Invocation_Adapter.cpp 85483 2009-06-02 06:48:10Z johnnyw $" | ||||
| ) |
Definition at line 13 of file LocateRequest_Invocation_Adapter.cpp.
00015 : LocateRequest_Invocation_Adapter.cpp 85483 2009-06-02 06:48:10Z johnnyw $") 00016 00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00018 00019 namespace TAO 00020 { 00021 LocateRequest_Invocation_Adapter::LocateRequest_Invocation_Adapter ( 00022 CORBA::Object_ptr target) 00023 : target_ (target) 00024 , list_ (0) 00025 { 00026 } 00027 00028 void 00029 LocateRequest_Invocation_Adapter::invoke (void) 00030 { 00031 CORBA::Object_var effective_target = 00032 CORBA::Object::_duplicate (this->target_); 00033 00034 TAO_Stub * const stub = 00035 this->target_->_stubobj (); 00036 if (stub == 0) 00037 throw ::CORBA::INTERNAL ( 00038 CORBA::SystemException::_tao_minor_code ( 00039 0, 00040 EINVAL), 00041 CORBA::COMPLETED_NO); 00042 00043 // The invocation has got to be within the context of the 00044 // corresponding ORB's configuration. Otherwise things like 00045 // timeout hooks, etc may not work as expected. Especially if 00046 // there are multiple ORB instances in the process, each with its 00047 // own, local configuration. 00048 ACE_Service_Config_Guard scg (stub->orb_core ()->configuration ()); 00049 00050 ACE_Time_Value tmp_wait_time; 00051 ACE_Time_Value *max_wait_time = 0; 00052 00053 if (this->get_timeout (tmp_wait_time)) 00054 max_wait_time = &tmp_wait_time; 00055 00056 Invocation_Status s = TAO_INVOKE_START; 00057 00058 while (s == TAO_INVOKE_START || s == TAO_INVOKE_RESTART) 00059 { 00060 Profile_Transport_Resolver resolver (effective_target.in (), stub, true); 00061 00062 try 00063 { 00064 resolver.init_inconsistent_policies (); 00065 00066 resolver.resolve (max_wait_time); 00067 00068 if (!resolver.transport ()) 00069 { 00070 // We failed to find a profile we could connect to. 00071 throw CORBA::TRANSIENT (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO); 00072 } 00073 00074 // Dummy operation details that is used to instantiate the 00075 // LocateRequest class. 00076 TAO_Operation_Details op (0, 0); 00077 00078 op.request_id (resolver.transport ()->tms ()->request_id ()); 00079 TAO::LocateRequest_Invocation synch (this->target_, resolver, op); 00080 00081 s = synch.invoke (max_wait_time); 00082 if (s == TAO_INVOKE_RESTART && 00083 (synch.reply_status () == GIOP::LOCATION_FORWARD || 00084 synch.reply_status () == GIOP::LOCATION_FORWARD_PERM)) 00085 { 00086 CORBA::Boolean const is_permanent_forward = 00087 (synch.reply_status () == GIOP::LOCATION_FORWARD_PERM); 00088 00089 effective_target = synch.steal_forwarded_reference (); 00090 00091 this->object_forwarded (effective_target, 00092 resolver.stub (), 00093 is_permanent_forward); 00094 } 00095 } 00096 catch (const ::CORBA::INV_POLICY&) 00097 { 00098 this->list_ = resolver.steal_inconsistent_policies (); 00099 throw; 00100 } 00101 } 00102 00103 return; 00104 } 00105 00106 CORBA::PolicyList * 00107 LocateRequest_Invocation_Adapter::get_inconsistent_policies (void) 00108 { 00109 return this->list_._retn (); 00110 } 00111 00112 bool 00113 LocateRequest_Invocation_Adapter::get_timeout (ACE_Time_Value &timeout) 00114 { 00115 bool has_timeout = false; 00116 this->target_->orb_core ()->call_timeout_hook (this->target_->_stubobj (), 00117 has_timeout, 00118 timeout); 00119 00120 return has_timeout; 00121 } 00122 00123 void 00124 LocateRequest_Invocation_Adapter::object_forwarded ( 00125 CORBA::Object_var &effective_target, 00126 TAO_Stub *stub, 00127 CORBA::Boolean permanent_forward) 00128 { 00129 // The object pointer has to be changed to a TAO_Stub pointer 00130 // in order to obtain the profiles. 00131 TAO_Stub *stubobj = 0; 00132 00133 bool nil_forward_ref = false; 00134 if (CORBA::is_nil (effective_target.in ())) 00135 nil_forward_ref = true; 00136 else 00137 { 00138 stubobj = 00139 effective_target->_stubobj (); 00140 00141 if (stubobj && stubobj->base_profiles ().size () == 0) 00142 nil_forward_ref = true; 00143 } 00144 00145 if (nil_forward_ref) 00146 throw ::CORBA::TRANSIENT ( 00147 CORBA::SystemException::_tao_minor_code ( 00148 TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE, 00149 errno), 00150 CORBA::COMPLETED_NO); 00151 00152 if (stubobj == 0) 00153 throw ::CORBA::INTERNAL ( 00154 CORBA::SystemException::_tao_minor_code ( 00155 TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE, 00156 errno), 00157 CORBA::COMPLETED_NO); 00158 00159 // Reset the profile in the stubs 00160 stub->add_forward_profiles (stubobj->base_profiles (), permanent_forward); 00161 00162 if (stub->next_profile () == 0) 00163 throw ::CORBA::TRANSIENT ( 00164 CORBA::SystemException::_tao_minor_code ( 00165 TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE, 00166 errno), 00167 CORBA::COMPLETED_NO); 00168 00169 return; 00170 } 00171 00172 } // End namespace TAO
1.6.1