Invocation_Adapter.h

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

Generated on Thu Nov 9 11:54:14 2006 for TAO by doxygen 1.3.6