Invocation_Adapter.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Invocation_Adapter.h
00006  *
00007  *  $Id: Invocation_Adapter.h 78128 2007-04-20 08:07:58Z johnnyw $
00008  *
00009  *  @author Balachandran Natarajan <bala@dre.vanderbilt.edu>
00010  */
00011 //=============================================================================
00012 #ifndef TAO_INVOCATION_ADAPTER_H
00013 #define TAO_INVOCATION_ADAPTER_H
00014 
00015 #include /**/ "ace/pre.h"
00016 
00017 #include "ace/Global_Macros.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #include /**/ "tao/TAO_Export.h"
00024 #include "tao/Invocation_Utils.h"
00025 #include "tao/Collocation_Strategy.h"
00026 #include "tao/CORBA_methods.h"
00027 #include "tao/Pseudo_VarOut_T.h"
00028 
00029 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00030 class ACE_Time_Value;
00031 ACE_END_VERSIONED_NAMESPACE_DECL
00032 
00033 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00034 
00035 class TAO_Operation_Details;
00036 class TAO_Stub;
00037 
00038 namespace  CORBA
00039 {
00040   class Object;
00041   typedef Object *Object_ptr;
00042   typedef TAO_Pseudo_Var_T<Object> Object_var;
00043 }
00044 
00045 namespace TAO
00046 {
00047   class Argument;
00048   struct Exception_Data;
00049   class Collocation_Proxy_Broker;
00050   class Profile_Transport_Resolver;
00051 
00052   /**
00053    * @class Invocation_Adapter
00054    *
00055    * @brief Generic interface for the invocation object visible to the
00056    * IDL compiler.
00057    *
00058    * The main objective of this class is to adapt the type and
00059    * invocation specific information declared in the IDL by the
00060    * application and convert them as CORBA invocations to the target
00061    * object. Implementation of this class knows how to make
00062    * invocations on a collocated or a remote object.
00063    *
00064    * This adapter class serves as the base class for various types of
00065    * invocations like AMI, DII, DSI etc. Adapter classes for AMI, DII,
00066    * DSI inherit from this class and their local behavioural
00067    * information before kicking off an invocation.
00068    *
00069    * @@ More info..
00070    * Wafer thin inclusions
00071    * All stuff created on stack
00072    * Only handles starts and restarts
00073    *
00074    */
00075   class TAO_Export Invocation_Adapter
00076   {
00077   public:
00078     /// The only constructor used by the IDL compiler, and only way to
00079     /// create this adapter.
00080     /**
00081      * @param target Points to the object on which this invocation is
00082      * being invoked.
00083      *
00084      * @param args Array of pointers to the argument list in the
00085      * operation declaration. This includes the return, inout and out
00086      * arguments.
00087      *
00088      * @param arg_number Number of arguments in the above array. This
00089      * is the number of elements in the above array.
00090      *
00091      * @param operation The name of the operation being invoked.
00092      *
00093      * @param op_len Number of charecters in the operation name. This
00094      * is an optimization which helps us to avoid calling strlen ()
00095      * while creating a message format.
00096      *
00097      * @param cpb The collocation proxy broker for the target if one
00098      * exists. This is useful especially to route the call to the
00099      * collocated target.
00100      *
00101      * @param type The operation type which could be a oneway or two
00102      * way operation. This information is available in the IDL file.
00103      *
00104      * @param mode Invocation mode. This information is also available
00105      * in the IDL file and in the generated code.
00106      */
00107     Invocation_Adapter (CORBA::Object_ptr target,
00108                         Argument **args,
00109                         int arg_number,
00110                         const char *operation,
00111                         size_t op_len,
00112                         Collocation_Proxy_Broker *cpb,
00113                         TAO::Invocation_Type type = TAO_TWOWAY_INVOCATION,
00114                         TAO::Invocation_Mode mode = TAO_SYNCHRONOUS_INVOCATION);
00115 
00116     virtual ~Invocation_Adapter (void);
00117 
00118     /// Invoke the target, and used by the generated code.
00119     /**
00120      * The implementation decides whether the target is remote or
00121      * collocated and takes the right decision.
00122      *
00123      * @param ex Array of exception data declared by the application
00124      * in their IDL.
00125      *
00126      * @param ex_count Number of elements in the array.
00127      */
00128     virtual void invoke (TAO::Exception_Data *ex, unsigned long ex_count);
00129   protected:
00130     /**
00131      * The stub pointer passed to this call has all the details about
00132      * the object to which the invocation needs to be routed to. The
00133      * implementation of this method looks if we are collocated or not
00134      * and takes care of reinvoking the target if it receives
00135      * forwarding information or if the first invocation fails
00136      * for some reason, like a loss of connection during send () etc.
00137      */
00138     virtual void invoke_i (TAO_Stub *stub, TAO_Operation_Details &details);
00139 
00140     /**
00141      * @name Helper methods for making different types of invocations.
00142      *
00143      * These methods useful for various types of invocations like
00144      * SII, AMI, DII and DSI. All the subclasses implement these
00145      * methods to get the right behaviour at their level.
00146      */
00147     //@{
00148 
00149     /// Helper method that prepares the necessary stuff for a remote
00150     /// invocation.
00151 
00152     /*
00153      * This method does the following essential activities needed for
00154      * a remote invocation.
00155      *
00156      * - Extracts the roundtrip timeout policies set in the ORB or
00157      *   Object or at the thread level
00158      * - Uses the target information to pick a profile and a transport
00159      *   object on which the invocation needs to be sent
00160      *
00161      * - Checks whether the operation is a oneway or twoway and
00162      *   delegates the call.
00163      */
00164     virtual Invocation_Status invoke_remote_i (
00165         TAO_Stub *stub,
00166         TAO_Operation_Details &details,
00167         CORBA::Object_var &effective_target,
00168         ACE_Time_Value *&max_wait_time);
00169 
00170     /// Make a collocated call.
00171     /**
00172      * This method creates an object that takes care of making collocated
00173      * invocations and calls invoke () on it. If the invoke ()
00174      * returns with a location forwarded reply we return a restart
00175      *
00176      * @param stub The stub object on which the invocation is made.
00177      *
00178      * @param details The operations details of the operation that is being
00179      * invoked.
00180      */
00181     virtual Invocation_Status invoke_collocated_i (
00182         TAO_Stub *stub,
00183         TAO_Operation_Details &details,
00184         CORBA::Object_var &effective_target,
00185         Collocation_Strategy strat);
00186 
00187     /// Helper method to make a two way invocation.
00188     /**
00189      * This method creates a synchronous twoway invocation object to
00190      * which the actual task of request handling is delegated. Once
00191      * the invocation returns this method checks whether the request
00192      * is forwarded to a new location.
00193      */
00194     virtual Invocation_Status invoke_twoway (
00195         TAO_Operation_Details &details,
00196         CORBA::Object_var &effective_target,
00197         Profile_Transport_Resolver &r,
00198         ACE_Time_Value *&max_wait_time);
00199 
00200     /// Helper method to make a one way invocation.
00201     /**
00202      * This method creates a synchronous oneway invocation object to
00203      * which the actual task of request handling is delegated. Once
00204      * the invocation returns this method checks whether the request
00205      * is forwarded to a new location to take appropriate action.
00206      */
00207     virtual Invocation_Status invoke_oneway (
00208         TAO_Operation_Details &details,
00209         CORBA::Object_var &effective_target,
00210         Profile_Transport_Resolver &r,
00211         ACE_Time_Value *&max_wait_time);
00212     //@}
00213 
00214     /// Helper function that extracts the roundtrip timeout policies
00215     /// set in the ORB.
00216     bool get_timeout (TAO_Stub *stub, ACE_Time_Value &val);
00217 
00218     /// Helper method that extracts TAO_Stub from the target object.
00219     TAO_Stub *get_stub (void) const;
00220 
00221     /// Helper method that takes care of setting the profiles within
00222     /// the stub object if the target gets forwarded
00223     void object_forwarded (CORBA::Object_var &effective_target,
00224                            TAO_Stub *stub,
00225                            CORBA::Boolean permanent_forward);
00226 
00227     /// Helper method to set the response flags within @a details
00228     void set_response_flags (TAO_Stub *stub,
00229                              TAO_Operation_Details &details);
00230 
00231   private:
00232     /// Dont allow default initializations
00233     Invocation_Adapter (void);
00234 
00235     // Prevent copying
00236     Invocation_Adapter (Invocation_Adapter const &);
00237     Invocation_Adapter & operator= (const Invocation_Adapter &);
00238 
00239   protected:
00240 
00241     /// The target object on which this invocation is carried out.
00242     CORBA::Object_ptr target_;
00243 
00244     /// Array of arguments for this operation
00245     Argument ** const args_;
00246 
00247     /// Number of arguments for this operation.
00248     /**
00249      * This includes the return values too
00250      */
00251     int const number_args_;
00252 
00253     /// Name of the operation.
00254     char const * operation_;
00255 
00256     /// String length of the operation name.
00257     size_t const op_len_;
00258 
00259     /// Collocation proxy broker for this operation.
00260     Collocation_Proxy_Broker * const cpb_;
00261 
00262     /// The invocation type
00263     Invocation_Type const type_;
00264 
00265     /// The invocation mode
00266     Invocation_Mode const mode_;
00267   };
00268 } // End namespace TAO
00269 
00270 TAO_END_VERSIONED_NAMESPACE_DECL
00271 
00272 #if defined (__ACE_INLINE__)
00273 # include "tao/Invocation_Adapter.inl"
00274 #endif /* __ACE_INLINE__ */
00275 
00276 #include /**/ "ace/post.h"
00277 
00278 #endif /*TAO_INVOCATION_ADAPTER_H*/

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7