#include <Invocation_Adapter.h>
Collaboration diagram for TAO::Invocation_Adapter:
Public Member Functions | |
Invocation_Adapter (CORBA::Object_ptr target, Argument **args, int arg_number, const char *operation, size_t op_len, Collocation_Proxy_Broker *cpb, TAO::Invocation_Type type=TAO_TWOWAY_INVOCATION, TAO::Invocation_Mode mode=TAO_SYNCHRONOUS_INVOCATION) | |
virtual | ~Invocation_Adapter (void) |
virtual void | invoke (TAO::Exception_Data *ex, unsigned long ex_count) |
Invoke the target, and used by the generated code. | |
Protected Member Functions | |
virtual void | invoke_i (TAO_Stub *stub, TAO_Operation_Details &details) |
bool | get_timeout (TAO_Stub *stub, ACE_Time_Value &val) |
TAO_Stub * | get_stub (void) const |
Helper method that extracts TAO_Stub from the target object. | |
void | object_forwarded (CORBA::Object_var &effective_target, TAO_Stub *stub, CORBA::Boolean permanent_forward) |
void | set_response_flags (TAO_Stub *stub, TAO_Operation_Details &details) |
Helper method to set the response flags within details. | |
Helper methods for making different types of invocations. | |
These methods useful for various types of invocations like SII, AMI, DII and DSI. All the subclasses implement these methods to get the right behaviour at their level. | |
virtual Invocation_Status | invoke_remote_i (TAO_Stub *stub, TAO_Operation_Details &details, CORBA::Object_var &effective_target, ACE_Time_Value *&max_wait_time) |
virtual Invocation_Status | invoke_collocated_i (TAO_Stub *stub, TAO_Operation_Details &details, CORBA::Object_var &effective_target, Collocation_Strategy strat) |
Make a collocated call. | |
virtual Invocation_Status | invoke_twoway (TAO_Operation_Details &details, CORBA::Object_var &effective_target, Profile_Transport_Resolver &r, ACE_Time_Value *&max_wait_time) |
Helper method to make a two way invocation. | |
virtual Invocation_Status | invoke_oneway (TAO_Operation_Details &details, CORBA::Object_var &effective_target, Profile_Transport_Resolver &r, ACE_Time_Value *&max_wait_time) |
Helper method to make a one way invocation. | |
Protected Attributes | |
CORBA::Object_ptr | target_ |
The target object on which this invocation is carried out. | |
Argument **const | args_ |
Array of arguments for this operation. | |
int const | number_args_ |
Number of arguments for this operation. | |
char const * | operation_ |
Name of the operation. | |
size_t const | op_len_ |
String length of the operation name. | |
Collocation_Proxy_Broker *const | cpb_ |
Collocation proxy broker for this operation. | |
Invocation_Type const | type_ |
The invocation type. | |
Invocation_Mode const | mode_ |
The invocation mode. | |
Private Member Functions | |
Invocation_Adapter (void) | |
Dont allow default initializations. | |
Invocation_Adapter (Invocation_Adapter const &) | |
Invocation_Adapter & | operator= (const Invocation_Adapter &) |
The main objective of this class is to adapt the type and invocation specific information declared in the IDL by the application and convert them as CORBA invocations to the target object. Implementation of this class knows how to make invocations on a collocated or a remote object.
This adapter class serves as the base class for various types of invocations like AMI, DII, DSI etc. Adapter classes for AMI, DII, DSI inherit from this class and their local behavioural information before kicking off an invocation.
@ More info.. Wafer thin inclusions All stuff created on stack Only handles starts and restarts
Definition at line 75 of file Invocation_Adapter.h.
|
|
|
Definition at line 32 of file Invocation_Adapter.cpp.
00033 { 00034 } |
|
Dont allow default initializations.
|
|
|
|
Helper method that extracts TAO_Stub from the target object.
Definition at line 133 of file Invocation_Adapter.cpp. References CORBA::Object::_stubobj(). Referenced by invoke().
|
|
Helper function that extracts the roundtrip timeout policies set in the ORB. Definition at line 124 of file Invocation_Adapter.cpp. References TAO_ORB_Core::call_timeout_hook(), and CORBA::Object::orb_core(). Referenced by invoke_remote_i().
00125 { 00126 bool has_timeout = false; 00127 this->target_->orb_core ()->call_timeout_hook (stub, has_timeout, timeout); 00128 00129 return has_timeout; 00130 } |
|
Invoke the target, and used by the generated code. The implementation decides whether the target is remote or collocated and takes the right decision.
Definition at line 37 of file Invocation_Adapter.cpp. References get_stub(), and invoke_i(). Referenced by TAO::Remote_Object_Proxy_Broker::_get_component(), TAO::Remote_Object_Proxy_Broker::_is_a(), TAO::Remote_Object_Proxy_Broker::_non_existent(), TAO::Remote_Object_Proxy_Broker::_repository_id(), CORBA::Policy::copy(), CORBA::Policy::destroy(), and TAO_CORBANAME_Parser::parse_string_dynamic_request_helper().
00039 { 00040 // Should stub object be refcounted here? 00041 TAO_Stub *stub = this->get_stub (); 00042 00043 TAO_Operation_Details op_details (this->operation_, 00044 this->op_len_, 00045 this->args_, 00046 this->number_args_, 00047 ex_data, 00048 ex_count); 00049 00050 this->invoke_i (stub, op_details); 00051 } |
|
Make a collocated call. This method creates an object that takes care of making collocated invocations and calls invoke () on it. If the invoke () returns with a location forwarded reply we return a restart
Definition at line 148 of file Invocation_Adapter.cpp. References ACE_ASSERT, cpb_, TAO_Pseudo_Var_T< T >::in(), TAO::Collocated_Invocation::invoke(), TAO::Invocation_Base::is_forwarded(), object_forwarded(), CORBA::Object_var, TAO::Invocation_Base::reply_status(), TAO::Invocation_Base::steal_forwarded_reference(), TAO::TAO_CS_THRU_POA_STRATEGY, TAO_GIOP_LOCATION_FORWARD_PERM, TAO::TAO_INVOKE_RESTART, TAO::TAO_INVOKE_START, and TAO::TAO_TWOWAY_INVOCATION. Referenced by invoke_i().
00152 { 00153 // To make a collocated call we must have a collocated proxy broker, the 00154 // invoke_i() will make sure that we only come here when we have one 00155 ACE_ASSERT (cpb_ != 0 00156 || (strat == TAO_CS_THRU_POA_STRATEGY 00157 && effective_target->_servant () != 0)); 00158 00159 // Initial state 00160 TAO::Invocation_Status status = TAO_INVOKE_START; 00161 00162 Collocated_Invocation coll_inv (this->target_, 00163 effective_target.in (), 00164 stub, 00165 details, 00166 this->type_ == TAO_TWOWAY_INVOCATION); 00167 00168 status = coll_inv.invoke (this->cpb_, strat); 00169 00170 if (status == TAO_INVOKE_RESTART && coll_inv.is_forwarded ()) 00171 { 00172 effective_target = coll_inv.steal_forwarded_reference (); 00173 00174 #if TAO_HAS_INTERCEPTORS == 1 00175 CORBA::Boolean const is_permanent_forward = 00176 (coll_inv.reply_status() == TAO_GIOP_LOCATION_FORWARD_PERM); 00177 #else 00178 CORBA::Boolean const is_permanent_forward = false; 00179 #endif 00180 00181 this->object_forwarded (effective_target, stub, is_permanent_forward); 00182 } 00183 00184 return status; 00185 } |
|
The stub pointer passed to this call has all the details about the object to which the invocation needs to be routed to. The implementation of this method looks if we are collocated or not and takes care of reinvoking the target if it receives forwarding information or if the first invocation fails for some reason, like a loss of connection during send () etc. Definition at line 54 of file Invocation_Adapter.cpp. References CORBA::Object::_duplicate(), ACE_DEBUG, TAO_ORB_Core::collocation_strategy(), TAO::Collocation_Strategy, TAO_ORB_Core::configuration(), cpb_, TAO_Pseudo_Var_T< T >::in(), invoke_collocated_i(), invoke_remote_i(), LM_DEBUG, CORBA::Object_var, TAO_Stub::orb_core(), TAO_Operation_Details::reset_reply_service_info(), TAO_Operation_Details::reset_request_service_info(), set_response_flags(), TAO::TAO_CS_LAST, TAO::TAO_CS_REMOTE_STRATEGY, TAO::TAO_CS_THRU_POA_STRATEGY, TAO_debug_level, TAO::TAO_INVOKE_RESTART, and TAO::TAO_INVOKE_START. Referenced by invoke().
00055 { 00056 // The invocation has got to be within the context of the 00057 // corresponding ORB's configuration. Otherwise things like 00058 // timeout hooks, etc may not work as expected. Especially if 00059 // there are multiple ORB instances in the process, each with its 00060 // own, local configuration. 00061 ACE_Service_Config_Guard scg (stub->orb_core ()->configuration ()); 00062 00063 // Cache the target to a local variable. 00064 CORBA::Object_var effective_target = 00065 CORBA::Object::_duplicate (this->target_); 00066 00067 // Initial state 00068 TAO::Invocation_Status status = TAO_INVOKE_START; 00069 00070 while (status == TAO_INVOKE_START || 00071 status == TAO_INVOKE_RESTART) 00072 { 00073 // Default we go to remote 00074 Collocation_Strategy strat = TAO_CS_REMOTE_STRATEGY; 00075 00076 // If we have a collocated proxy broker we look if we maybe 00077 // can use a collocated invocation. Similarly, if the 00078 // target object reference contains a pointer to a servant, 00079 // the object reference also refers to a collocated object. 00080 if (cpb_ != 0 || effective_target->_servant () != 0) 00081 { 00082 strat = TAO_ORB_Core::collocation_strategy (effective_target.in ()); 00083 } 00084 00085 if (strat == TAO_CS_REMOTE_STRATEGY || strat == TAO_CS_LAST) 00086 { 00087 ACE_Time_Value *max_wait_time = 0; 00088 status = 00089 this->invoke_remote_i (stub, 00090 details, 00091 effective_target, 00092 max_wait_time); 00093 } 00094 else 00095 { 00096 if (strat == TAO_CS_THRU_POA_STRATEGY) 00097 { 00098 (void) this->set_response_flags (stub, details); 00099 } 00100 00101 status = 00102 this->invoke_collocated_i (stub, 00103 details, 00104 effective_target, 00105 strat); 00106 } 00107 00108 if (status == TAO_INVOKE_RESTART) 00109 { 00110 details.reset_request_service_info (); 00111 details.reset_reply_service_info (); 00112 00113 if (TAO_debug_level > 2) 00114 { 00115 ACE_DEBUG ((LM_DEBUG, 00116 "TAO (%P|%t) - Invocation_Adapter::invoke_i, " 00117 "handling forwarded locations \n")); 00118 } 00119 } 00120 } 00121 } |
|
Helper method to make a one way invocation. This method creates a synchronous oneway invocation object to which the actual task of request handling is delegated. Once the invocation returns this method checks whether the request is forwarded to a new location to take appropriate action. Definition at line 321 of file Invocation_Adapter.cpp. References TAO::Invocation_Status, TAO::Invocation_Base::is_forwarded(), object_forwarded(), CORBA::Object_var, TAO::Synch_Oneway_Invocation::remote_oneway(), TAO::Invocation_Base::reply_status(), TAO::Invocation_Base::steal_forwarded_reference(), TAO::Profile_Transport_Resolver::stub(), TAO_GIOP_LOCATION_FORWARD_PERM, and TAO::TAO_INVOKE_RESTART. Referenced by invoke_remote_i().
00325 { 00326 TAO::Synch_Oneway_Invocation synch (this->target_, r, details); 00327 00328 Invocation_Status const s = synch.remote_oneway (max_wait_time); 00329 00330 if (s == TAO_INVOKE_RESTART && synch.is_forwarded ()) 00331 { 00332 effective_target = synch.steal_forwarded_reference (); 00333 00334 #if TAO_HAS_INTERCEPTORS == 1 00335 CORBA::Boolean const is_permanent_forward = 00336 (synch.reply_status() == TAO_GIOP_LOCATION_FORWARD_PERM); 00337 #else 00338 CORBA::Boolean const is_permanent_forward = false; 00339 #endif 00340 this->object_forwarded (effective_target, 00341 r.stub (), 00342 is_permanent_forward); 00343 } 00344 00345 return s; 00346 } |
|
Helper method that prepares the necessary stuff for a remote invocation. Definition at line 222 of file Invocation_Adapter.cpp. References ACE_DEBUG, ACE_TEXT, get_timeout(), TAO_Pseudo_Var_T< T >::in(), invoke_oneway(), invoke_twoway(), LM_DEBUG, CORBA::Object_var, TAO_Transport_Mux_Strategy::request_id(), TAO_Operation_Details::request_id(), TAO::Profile_Transport_Resolver::resolve(), TAO_Operation_Details::response_flags(), set_response_flags(), TAO_debug_level, TAO::TAO_INVOKE_FAILURE, TAO::TAO_ONEWAY_INVOCATION, TAO::TAO_TWOWAY_INVOCATION, TAO_Transport::tms(), and TAO::Profile_Transport_Resolver::transport(). Referenced by invoke_i().
00226 { 00227 ACE_Time_Value tmp_wait_time; 00228 bool const is_timeout = this->get_timeout (stub, tmp_wait_time); 00229 00230 if (is_timeout) 00231 max_wait_time = &tmp_wait_time; 00232 00233 (void) this->set_response_flags (stub, details); 00234 00235 CORBA::Octet rflags = details.response_flags (); 00236 bool block_connect = 00237 rflags != static_cast<CORBA::Octet> (Messaging::SYNC_NONE) 00238 && rflags != static_cast<CORBA::Octet> (TAO::SYNC_DELAYED_BUFFERING); 00239 00240 // Create the resolver which will pick (or create) for us a 00241 // transport and a profile from the effective_target. 00242 Profile_Transport_Resolver resolver ( 00243 effective_target.in (), 00244 stub, 00245 block_connect); 00246 00247 resolver.resolve (max_wait_time); 00248 00249 if (TAO_debug_level) 00250 { 00251 if (is_timeout && *max_wait_time == ACE_Time_Value::zero) 00252 ACE_DEBUG ((LM_DEBUG, 00253 ACE_TEXT ("(%P|%t)Invocation_Adapter::invoke_remote_i: ") 00254 ACE_TEXT ("max wait time consumed during transport resolution\n"))); 00255 } 00256 00257 00258 // Update the request id now that we have a transport 00259 details.request_id (resolver.transport ()->tms ()->request_id ()); 00260 00261 if (this->type_ == TAO_ONEWAY_INVOCATION) 00262 { 00263 return this->invoke_oneway (details, 00264 effective_target, 00265 resolver, 00266 max_wait_time); 00267 } 00268 else if (this->type_ == TAO_TWOWAY_INVOCATION) 00269 { 00270 return this->invoke_twoway (details, 00271 effective_target, 00272 resolver, 00273 max_wait_time); 00274 } 00275 00276 return TAO_INVOKE_FAILURE; 00277 } |
|
Helper method to make a two way invocation. This method creates a synchronous twoway invocation object to which the actual task of request handling is delegated. Once the invocation returns this method checks whether the request is forwarded to a new location. Definition at line 280 of file Invocation_Adapter.cpp. References TAO::Invocation_Status, TAO::Invocation_Base::is_forwarded(), object_forwarded(), CORBA::Object_var, TAO::Synch_Twoway_Invocation::remote_twoway(), TAO::Invocation_Base::reply_status(), TAO::Invocation_Base::steal_forwarded_reference(), TAO::Profile_Transport_Resolver::stub(), TAO_GIOP_LOCATION_FORWARD_PERM, TAO::TAO_INVOKE_RESTART, TAO::TAO_SYNCHRONOUS_INVOCATION, and TAO::TAO_TWOWAY_INVOCATION. Referenced by invoke_remote_i().
00284 { 00285 // Simple sanity check 00286 if (this->mode_ != TAO_SYNCHRONOUS_INVOCATION || 00287 this->type_ != TAO_TWOWAY_INVOCATION) 00288 { 00289 throw ::CORBA::INTERNAL ( 00290 CORBA::SystemException::_tao_minor_code ( 00291 TAO::VMCID, 00292 EINVAL), 00293 CORBA::COMPLETED_NO); 00294 } 00295 00296 TAO::Synch_Twoway_Invocation synch (this->target_, r, details); 00297 00298 Invocation_Status const status = synch.remote_twoway (max_wait_time); 00299 00300 if (status == TAO_INVOKE_RESTART && 00301 synch.is_forwarded ()) 00302 { 00303 effective_target = synch.steal_forwarded_reference (); 00304 00305 #if TAO_HAS_INTERCEPTORS == 1 00306 CORBA::Boolean const is_permanent_forward = 00307 (synch.reply_status() == TAO_GIOP_LOCATION_FORWARD_PERM); 00308 #else 00309 CORBA::Boolean const is_permanent_forward = false; 00310 #endif 00311 00312 this->object_forwarded (effective_target, 00313 r.stub (), 00314 is_permanent_forward); 00315 } 00316 00317 return status; 00318 } |
|
Helper method that takes care of setting the profiles within the stub object if the target gets forwarded Definition at line 349 of file Invocation_Adapter.cpp. References TAO_Stub::add_forward_profiles(), TAO_Stub::base_profiles(), TAO_Stub::next_profile(), CORBA::Object_var, and TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE. Referenced by invoke_collocated_i(), invoke_oneway(), and invoke_twoway().
00352 { 00353 // The object pointer has to be changed to a TAO_Stub pointer 00354 // in order to obtain the profiles. 00355 TAO_Stub *stubobj = effective_target->_stubobj (); 00356 00357 if (stubobj == 0) 00358 throw ::CORBA::INTERNAL ( 00359 CORBA::SystemException::_tao_minor_code ( 00360 TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE, 00361 errno), 00362 CORBA::COMPLETED_NO); 00363 00364 // Reset the profile in the stubs 00365 stub->add_forward_profiles (stubobj->base_profiles (), permanent_forward); 00366 00367 if (stub->next_profile () == 0) 00368 throw ::CORBA::TRANSIENT ( 00369 CORBA::SystemException::_tao_minor_code ( 00370 TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE, 00371 errno), 00372 CORBA::COMPLETED_NO); 00373 00374 return; 00375 } |
|
|
|
Helper method to set the response flags within details.
Definition at line 188 of file Invocation_Adapter.cpp. References TAO_ORB_Core::call_sync_scope_hook(), TAO_Stub::orb_core(), TAO_Operation_Details::response_flags(), Messaging::SyncScope, TAO::TAO_ONEWAY_INVOCATION, TAO::TAO_TWOWAY_INVOCATION, and TAO_TWOWAY_RESPONSE_FLAG. Referenced by invoke_i(), and invoke_remote_i().
00191 { 00192 switch (this->type_) 00193 { 00194 case TAO_ONEWAY_INVOCATION: 00195 { 00196 // Grab the syncscope policy from the ORB. 00197 Messaging::SyncScope sync_scope; 00198 00199 bool has_synchronization = false; 00200 00201 stub->orb_core ()->call_sync_scope_hook (stub, 00202 has_synchronization, 00203 sync_scope); 00204 if (has_synchronization) 00205 details.response_flags (CORBA::Octet (sync_scope)); 00206 else 00207 details.response_flags ( 00208 CORBA::Octet (Messaging::SYNC_WITH_TRANSPORT)); 00209 break; 00210 } 00211 case TAO_TWOWAY_INVOCATION: 00212 { 00213 // @@note: Need to change this to something better. Too many 00214 // hash defines meaning the same things. 00215 details.response_flags (TAO_TWOWAY_RESPONSE_FLAG); 00216 break; 00217 } 00218 } 00219 } |
|
Array of arguments for this operation.
Definition at line 245 of file Invocation_Adapter.h. |
|
Collocation proxy broker for this operation.
Definition at line 260 of file Invocation_Adapter.h. Referenced by invoke_collocated_i(), and invoke_i(). |
|
The invocation mode.
Definition at line 266 of file Invocation_Adapter.h. |
|
Number of arguments for this operation. This includes the return values too Definition at line 251 of file Invocation_Adapter.h. |
|
String length of the operation name.
Definition at line 257 of file Invocation_Adapter.h. |
|
Name of the operation.
Definition at line 254 of file Invocation_Adapter.h. |
|
The target object on which this invocation is carried out.
Definition at line 242 of file Invocation_Adapter.h. |
|
The invocation type.
Definition at line 263 of file Invocation_Adapter.h. |