TAO::Invocation_Adapter Class Reference

Generic interface for the invocation object visible to the IDL compiler. More...

#include <Invocation_Adapter.h>

Collaboration diagram for TAO::Invocation_Adapter:

Collaboration graph
[legend]
List of all members.

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_Stubget_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_Adapteroperator= (const Invocation_Adapter &)

Detailed Description

Generic interface for the invocation object visible to the IDL compiler.

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.


Constructor & Destructor Documentation

TAO::Invocation_Adapter::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 
)

Parameters:
target Points to the object on which this invocation is being invoked.
args Array of pointers to the argument list in the operation declaration. This includes the return, inout and out arguments.
arg_number Number of arguments in the above array. This is the number of elements in the above array.
operation The name of the operation being invoked.
op_len Number of charecters in the operation name. This is an optimization which helps us to avoid calling strlen () while creating a message format.
cpb The collocation proxy broker for the target if one exists. This is useful especially to route the call to the collocated target.
type The operation type which could be a oneway or two way operation. This information is available in the IDL file.
mode Invocation mode. This information is also available in the IDL file and in the generated code.

TAO::Invocation_Adapter::~Invocation_Adapter ( void   )  [virtual]

Definition at line 32 of file Invocation_Adapter.cpp.

00033   {
00034   }

TAO::Invocation_Adapter::Invocation_Adapter ( void   )  [private]

Dont allow default initializations.

TAO::Invocation_Adapter::Invocation_Adapter ( Invocation_Adapter const &   )  [private]


Member Function Documentation

TAO_Stub * TAO::Invocation_Adapter::get_stub ( void   )  const [protected]

Helper method that extracts TAO_Stub from the target object.

Definition at line 132 of file Invocation_Adapter.cpp.

References CORBA::Object::_stubobj(), CORBA::SystemException::_tao_minor_code(), CORBA::COMPLETED_NO, target_, and TAO::VMCID.

Referenced by invoke().

00133   {
00134     TAO_Stub * const stub = this->target_->_stubobj ();
00135 
00136     if (stub == 0)
00137       throw ::CORBA::INTERNAL (
00138         CORBA::SystemException::_tao_minor_code (
00139           TAO::VMCID,
00140           EINVAL),
00141         CORBA::COMPLETED_NO);
00142 
00143     return stub;
00144   }

bool TAO::Invocation_Adapter::get_timeout ( TAO_Stub stub,
ACE_Time_Value val 
) [protected]

Helper function that extracts the roundtrip timeout policies set in the ORB.

Definition at line 123 of file Invocation_Adapter.cpp.

References TAO_ORB_Core::call_timeout_hook(), CORBA::Object::orb_core(), and target_.

Referenced by invoke_remote_i().

00124   {
00125     bool has_timeout = false;
00126     this->target_->orb_core ()->call_timeout_hook (stub, has_timeout, timeout);
00127 
00128     return has_timeout;
00129   }

void TAO::Invocation_Adapter::invoke ( TAO::Exception_Data *  ex,
unsigned long  ex_count 
) [virtual]

Invoke the target, and used by the generated code.

The implementation decides whether the target is remote or collocated and takes the right decision.

Parameters:
ex Array of exception data declared by the application in their IDL.
ex_count Number of elements in the array.

Definition at line 37 of file Invocation_Adapter.cpp.

References get_stub(), and invoke_i().

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   }

Invocation_Status TAO::Invocation_Adapter::invoke_collocated_i ( TAO_Stub stub,
TAO_Operation_Details details,
CORBA::Object_var effective_target,
Collocation_Strategy  strat 
) [protected, virtual]

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

Parameters:
stub The stub object on which the invocation is made.
details The operations details of the operation that is being invoked.

Definition at line 147 of file Invocation_Adapter.cpp.

References ACE_ASSERT, cpb_, TAO_Pseudo_Var_T< T >::in(), object_forwarded(), TAO::TAO_CS_THRU_POA_STRATEGY, TAO::TAO_INVOKE_RESTART, TAO::TAO_INVOKE_START, TAO::TAO_TWOWAY_INVOCATION, and type_.

Referenced by invoke_i().

00151   {
00152     // To make a collocated call we must have a collocated proxy broker, the
00153     // invoke_i() will make sure that we only come here when we have one
00154     ACE_ASSERT (cpb_ != 0
00155                 || (strat == TAO_CS_THRU_POA_STRATEGY
00156                     && effective_target->_servant () != 0));
00157 
00158     // Initial state
00159     TAO::Invocation_Status status = TAO_INVOKE_START;
00160 
00161     Collocated_Invocation coll_inv (this->target_,
00162                                     effective_target.in (),
00163                                     stub,
00164                                     details,
00165                                     this->type_ == TAO_TWOWAY_INVOCATION);
00166 
00167     status = coll_inv.invoke (this->cpb_, strat);
00168 
00169     if (status == TAO_INVOKE_RESTART &&
00170         (coll_inv.reply_status () == GIOP::LOCATION_FORWARD ||
00171          coll_inv.reply_status () == GIOP::LOCATION_FORWARD_PERM))
00172       {
00173         CORBA::Boolean const is_permanent_forward =
00174           (coll_inv.reply_status () == GIOP::LOCATION_FORWARD_PERM);
00175 
00176         effective_target = coll_inv.steal_forwarded_reference ();
00177 
00178         this->object_forwarded (effective_target, stub, is_permanent_forward);
00179       }
00180 
00181     return status;
00182   }

void TAO::Invocation_Adapter::invoke_i ( TAO_Stub stub,
TAO_Operation_Details details 
) [protected, virtual]

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_ORB_Core::configuration(), cpb_, invoke_collocated_i(), invoke_remote_i(), LM_DEBUG, TAO_Stub::orb_core(), TAO_Operation_Details::reset_reply_service_info(), TAO_Operation_Details::reset_request_service_info(), 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 || status == TAO_INVOKE_RESTART)
00071       {
00072         // Default we go to remote
00073         Collocation_Strategy strat = TAO_CS_REMOTE_STRATEGY;
00074 
00075         // If we have a collocated proxy broker we look if we maybe
00076         // can use a collocated invocation.  Similarly, if the
00077         // target object reference contains a pointer to a servant,
00078         // the object reference also refers to a collocated object.
00079         if (cpb_ != 0 || effective_target->_servant () != 0)
00080           {
00081             strat = TAO_ORB_Core::collocation_strategy (effective_target.in ());
00082           }
00083 
00084         if (strat == TAO_CS_REMOTE_STRATEGY || strat == TAO_CS_LAST)
00085           {
00086             ACE_Time_Value *max_wait_time = 0;
00087             status =
00088               this->invoke_remote_i (stub,
00089                                      details,
00090                                      effective_target,
00091                                      max_wait_time);
00092           }
00093         else
00094           {
00095             if (strat == TAO_CS_THRU_POA_STRATEGY)
00096               {
00097                 (void) this->set_response_flags (stub, details);
00098               }
00099 
00100             status =
00101               this->invoke_collocated_i (stub,
00102                                          details,
00103                                          effective_target,
00104                                          strat);
00105           }
00106 
00107         if (status == TAO_INVOKE_RESTART)
00108           {
00109             details.reset_request_service_info ();
00110             details.reset_reply_service_info ();
00111 
00112             if (TAO_debug_level > 2)
00113               {
00114                 ACE_DEBUG ((LM_DEBUG,
00115                   "TAO (%P|%t) - Invocation_Adapter::invoke_i, "
00116                   "handling forwarded locations \n"));
00117               }
00118           }
00119       }
00120   }

Invocation_Status TAO::Invocation_Adapter::invoke_oneway ( TAO_Operation_Details details,
CORBA::Object_var effective_target,
Profile_Transport_Resolver r,
ACE_Time_Value *&  max_wait_time 
) [protected, virtual]

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 320 of file Invocation_Adapter.cpp.

References object_forwarded(), TAO::Profile_Transport_Resolver::stub(), and TAO::TAO_INVOKE_RESTART.

Referenced by invoke_remote_i().

00324   {
00325     TAO::Synch_Oneway_Invocation synch (this->target_, r, details);
00326 
00327     Invocation_Status const s = synch.remote_oneway (max_wait_time);
00328 
00329     if (s == TAO_INVOKE_RESTART &&
00330         (synch.reply_status () == GIOP::LOCATION_FORWARD ||
00331          synch.reply_status () == GIOP::LOCATION_FORWARD_PERM))
00332       {
00333         CORBA::Boolean const is_permanent_forward =
00334           (synch.reply_status () == GIOP::LOCATION_FORWARD_PERM);
00335 
00336         effective_target = synch.steal_forwarded_reference ();
00337 
00338         this->object_forwarded (effective_target,
00339                                 r.stub (),
00340                                 is_permanent_forward);
00341       }
00342 
00343     return s;
00344   }

Invocation_Status TAO::Invocation_Adapter::invoke_remote_i ( TAO_Stub stub,
TAO_Operation_Details details,
CORBA::Object_var effective_target,
ACE_Time_Value *&  max_wait_time 
) [protected, virtual]

Helper method that prepares the necessary stuff for a remote invocation.

Definition at line 219 of file Invocation_Adapter.cpp.

References ACE_DEBUG, ACE_TEXT, get_timeout(), TAO_Pseudo_Var_T< T >::in(), invoke_oneway(), invoke_twoway(), LM_DEBUG, TAO_Operation_Details::request_id(), TAO_Operation_Details::response_flags(), TAO_debug_level, TAO::TAO_INVOKE_FAILURE, TAO::TAO_ONEWAY_INVOCATION, TAO::TAO_TWOWAY_INVOCATION, and ACE_Time_Value::zero.

Referenced by invoke_i().

00223   {
00224     ACE_Time_Value tmp_wait_time;
00225     bool const is_timeout = this->get_timeout (stub, tmp_wait_time);
00226 
00227     if (is_timeout)
00228       max_wait_time = &tmp_wait_time;
00229 
00230     (void) this->set_response_flags (stub, details);
00231 
00232     CORBA::Octet const rflags = details.response_flags ();
00233     bool const block_connect =
00234       rflags != static_cast<CORBA::Octet> (Messaging::SYNC_NONE)
00235       && rflags != static_cast<CORBA::Octet> (TAO::SYNC_DELAYED_BUFFERING);
00236 
00237     // Create the resolver which will pick (or create) for us a
00238     // transport and a profile from the effective_target.
00239     Profile_Transport_Resolver resolver (
00240       effective_target.in (),
00241       stub,
00242       block_connect);
00243 
00244     resolver.resolve (max_wait_time);
00245 
00246     if (TAO_debug_level)
00247       {
00248         if (is_timeout && *max_wait_time == ACE_Time_Value::zero)
00249           ACE_DEBUG ((LM_DEBUG,
00250                       ACE_TEXT ("(%P|%t)Invocation_Adapter::invoke_remote_i: ")
00251                       ACE_TEXT ("max wait time consumed during transport resolution\n")));
00252       }
00253 
00254     // Update the request id now that we have a transport
00255     if (resolver.transport ())
00256       {
00257         details.request_id (resolver.transport ()->tms ()->request_id ());
00258       }
00259 
00260     switch (this->type_)
00261       {
00262         case TAO_ONEWAY_INVOCATION:
00263           {
00264             return this->invoke_oneway (details,
00265                                         effective_target,
00266                                         resolver,
00267                                         max_wait_time);
00268           }
00269         case TAO_TWOWAY_INVOCATION:
00270           {
00271             return this->invoke_twoway (details,
00272                                         effective_target,
00273                                         resolver,
00274                                         max_wait_time);
00275 
00276           }
00277       }
00278     return TAO_INVOKE_FAILURE;
00279   }

Invocation_Status TAO::Invocation_Adapter::invoke_twoway ( TAO_Operation_Details details,
CORBA::Object_var effective_target,
Profile_Transport_Resolver r,
ACE_Time_Value *&  max_wait_time 
) [protected, virtual]

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 282 of file Invocation_Adapter.cpp.

References CORBA::SystemException::_tao_minor_code(), CORBA::COMPLETED_NO, object_forwarded(), TAO::Profile_Transport_Resolver::stub(), TAO::TAO_INVOKE_RESTART, TAO::TAO_SYNCHRONOUS_INVOCATION, TAO::TAO_TWOWAY_INVOCATION, and TAO::VMCID.

Referenced by invoke_remote_i().

00286   {
00287     // Simple sanity check
00288     if (this->mode_ != TAO_SYNCHRONOUS_INVOCATION ||
00289         this->type_ != TAO_TWOWAY_INVOCATION)
00290       {
00291         throw ::CORBA::INTERNAL (
00292           CORBA::SystemException::_tao_minor_code (
00293             TAO::VMCID,
00294             EINVAL),
00295           CORBA::COMPLETED_NO);
00296       }
00297 
00298     TAO::Synch_Twoway_Invocation synch (this->target_,  r, details);
00299 
00300     Invocation_Status const status = synch.remote_twoway (max_wait_time);
00301 
00302     if (status == TAO_INVOKE_RESTART &&
00303         (synch.reply_status () == GIOP::LOCATION_FORWARD ||
00304          synch.reply_status () == GIOP::LOCATION_FORWARD_PERM))
00305       {
00306         CORBA::Boolean const is_permanent_forward =
00307           (synch.reply_status () == GIOP::LOCATION_FORWARD_PERM);
00308 
00309         effective_target = synch.steal_forwarded_reference ();
00310 
00311         this->object_forwarded (effective_target,
00312                                 r.stub (),
00313                                 is_permanent_forward);
00314       }
00315 
00316     return status;
00317   }

void TAO::Invocation_Adapter::object_forwarded ( CORBA::Object_var effective_target,
TAO_Stub stub,
CORBA::Boolean  permanent_forward 
) [protected]

Helper method that takes care of setting the profiles within the stub object if the target gets forwarded

Definition at line 347 of file Invocation_Adapter.cpp.

References CORBA::SystemException::_tao_minor_code(), TAO_Stub::add_forward_profiles(), TAO_Stub::base_profiles(), CORBA::COMPLETED_NO, TAO_Pseudo_Var_T< T >::in(), CORBA::is_nil(), TAO_Stub::next_profile(), TAO_MProfile::size(), and TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE.

Referenced by invoke_collocated_i(), invoke_oneway(), and invoke_twoway().

00350   {
00351     // The object pointer has to be changed to a TAO_Stub pointer
00352     // in order to obtain the profiles.
00353     TAO_Stub *stubobj = 0;
00354 
00355     bool nil_forward_ref = false;
00356     if (CORBA::is_nil (effective_target.in ()))
00357       nil_forward_ref = true;
00358     else
00359       {
00360         stubobj =
00361           effective_target->_stubobj ();
00362 
00363         if (stubobj && stubobj->base_profiles ().size () == 0)
00364           nil_forward_ref = true;
00365       }
00366 
00367     if (nil_forward_ref)
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     if (stubobj == 0)
00375       throw ::CORBA::INTERNAL (
00376         CORBA::SystemException::_tao_minor_code (
00377           TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE,
00378           errno),
00379         CORBA::COMPLETED_NO);
00380 
00381     // Reset the profile in the stubs
00382     stub->add_forward_profiles (stubobj->base_profiles (), permanent_forward);
00383 
00384     if (stub->next_profile () == 0)
00385       throw ::CORBA::TRANSIENT (
00386         CORBA::SystemException::_tao_minor_code (
00387           TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE,
00388           errno),
00389         CORBA::COMPLETED_NO);
00390   }

Invocation_Adapter& TAO::Invocation_Adapter::operator= ( const Invocation_Adapter  )  [private]

void TAO::Invocation_Adapter::set_response_flags ( TAO_Stub stub,
TAO_Operation_Details details 
) [protected]

Helper method to set the response flags within details.

Definition at line 185 of file Invocation_Adapter.cpp.

References TAO_ORB_Core::call_sync_scope_hook(), TAO_Stub::orb_core(), TAO_Operation_Details::response_flags(), TAO::TAO_ONEWAY_INVOCATION, TAO::TAO_TWOWAY_INVOCATION, and TAO_TWOWAY_RESPONSE_FLAG.

00188   {
00189     switch (this->type_)
00190       {
00191       case TAO_ONEWAY_INVOCATION:
00192         {
00193           // Grab the syncscope policy from the ORB.
00194           Messaging::SyncScope sync_scope;
00195 
00196           bool has_synchronization = false;
00197 
00198           stub->orb_core ()->call_sync_scope_hook (stub,
00199                                                    has_synchronization,
00200                                                    sync_scope);
00201           if (has_synchronization)
00202             details.response_flags (CORBA::Octet (sync_scope));
00203           else
00204             details.response_flags (
00205               CORBA::Octet (Messaging::SYNC_WITH_TRANSPORT));
00206           break;
00207         }
00208       case TAO_TWOWAY_INVOCATION:
00209         {
00210           // @@note: Need to change this to something better. Too many
00211           // hash defines meaning the same things.
00212           details.response_flags (TAO_TWOWAY_RESPONSE_FLAG);
00213           break;
00214         }
00215       }
00216   }


Member Data Documentation

Argument** const TAO::Invocation_Adapter::args_ [protected]

Array of arguments for this operation.

Definition at line 245 of file Invocation_Adapter.h.

Collocation_Proxy_Broker* const TAO::Invocation_Adapter::cpb_ [protected]

Collocation proxy broker for this operation.

Definition at line 260 of file Invocation_Adapter.h.

Referenced by invoke_collocated_i(), and invoke_i().

Invocation_Mode const TAO::Invocation_Adapter::mode_ [protected]

The invocation mode.

Definition at line 266 of file Invocation_Adapter.h.

int const TAO::Invocation_Adapter::number_args_ [protected]

Number of arguments for this operation.

This includes the return values too

Definition at line 251 of file Invocation_Adapter.h.

size_t const TAO::Invocation_Adapter::op_len_ [protected]

String length of the operation name.

Definition at line 257 of file Invocation_Adapter.h.

char const* TAO::Invocation_Adapter::operation_ [protected]

Name of the operation.

Definition at line 254 of file Invocation_Adapter.h.

CORBA::Object_ptr TAO::Invocation_Adapter::target_ [protected]

The target object on which this invocation is carried out.

Definition at line 242 of file Invocation_Adapter.h.

Referenced by get_stub(), and get_timeout().

Invocation_Type const TAO::Invocation_Adapter::type_ [protected]

The invocation type.

Definition at line 263 of file Invocation_Adapter.h.

Referenced by invoke_collocated_i().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:39:14 2010 for TAO by  doxygen 1.4.7