Servant_Upcall.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Servant_Upcall.h
00006  *
00007  *  Servant_Upcall.h,v 1.10 2006/06/19 14:51:14 parsons Exp
00008  *
00009  *  @author Irfan Pyarali
00010  */
00011 //=============================================================================
00012 
00013 #ifndef TAO_SERVANT_UPCALL_H
00014 #define TAO_SERVANT_UPCALL_H
00015 
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "tao/PortableServer/portableserver_export.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "tao/PortableServer/POA_Current_Impl.h"
00025 
00026 #if defined(_MSC_VER)
00027 #pragma warning(push)
00028 #pragma warning(disable:4250)
00029 #endif /* _MSC_VER */
00030 
00031 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00032 
00033 // Forward declaration
00034 class TAO_Root_POA;
00035 class TAO_ServerRequest;
00036 class TAO_Object_Adapter;
00037 class TAO_RT_Collocation_Resolver;
00038 struct TAO_Active_Object_Map_Entry;
00039 
00040 namespace CORBA
00041 {
00042   class Object;
00043   typedef Object *Object_ptr;
00044   typedef TAO_Pseudo_Var_T<Object> Object_var;
00045   typedef TAO_Pseudo_Out_T<Object> Object_out;
00046 }
00047 
00048 namespace TAO
00049 {
00050   namespace Portable_Server
00051   {
00052     /**
00053      * @class Servant_Upcall
00054      *
00055      * @brief This class finds out the POA and the servant to perform an
00056      * upcall.  It can only be instantiated without the object
00057      * adapter's lock held. For each upcall a new instance of this
00058      * class is created.
00059      */
00060     class TAO_PortableServer_Export Servant_Upcall
00061     {
00062     public:
00063       friend class ::TAO_RT_Collocation_Resolver;
00064 
00065       /**
00066        * @class Pre_Invoke_State
00067        *
00068        * @brief This struct keeps track of state related to pre- and
00069        * post-invoke operations.
00070        */
00071       class Pre_Invoke_State
00072       {
00073       public:
00074         /// Constructor.
00075         Pre_Invoke_State (void);
00076 
00077         enum State
00078         {
00079           NO_ACTION_REQUIRED,
00080           PRIORITY_RESET_REQUIRED
00081         };
00082 
00083         /// Indicates whether the priority of the thread needs to be
00084         /// reset back to its original value.
00085         State state_;
00086 
00087         /// Original native priority of the thread.
00088         CORBA::Short original_native_priority_;
00089 
00090         /// Original CORBA priority of the thread.
00091         CORBA::Short original_CORBA_priority_;
00092       };
00093 
00094       /// Constructor.
00095       explicit Servant_Upcall (TAO_ORB_Core *orb_core);
00096 
00097       /// Destructor.
00098       ~Servant_Upcall (void);
00099 
00100       /// Locate POA and servant.
00101       int prepare_for_upcall (const TAO::ObjectKey &key,
00102                               const char *operation,
00103                               CORBA::Object_out forward_to
00104                               ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00105 
00106       /// Helper.
00107       int prepare_for_upcall_i (const TAO::ObjectKey &key,
00108                                 const char *operation,
00109                                 CORBA::Object_out forward_to,
00110                                 int &wait_occurred_restart_call
00111                                 ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00112 
00113       /// Run pre_invoke for a remote request.
00114       void pre_invoke_remote_request (TAO_ServerRequest &req
00115                                       ACE_ENV_ARG_DECL);
00116 
00117       /// Run pre_invoke for a collocated request.
00118       void pre_invoke_collocated_request (ACE_ENV_SINGLE_ARG_DECL);
00119 
00120       /// Run post_invoke for a request.
00121       void post_invoke (void);
00122 
00123       /// Locate POA.
00124       ::TAO_Root_POA *lookup_POA (const TAO::ObjectKey &key
00125                                   ACE_ENV_ARG_DECL);
00126 
00127       /// POA accessor.
00128       ::TAO_Root_POA &poa (void) const;
00129 
00130       /// Object Adapter accessor.
00131       TAO_Object_Adapter &object_adapter (void) const;
00132 
00133       /// System ID accessor.
00134       const PortableServer::ObjectId &id (void) const;
00135 
00136       /// User ID accessors.  This is the same value returned by
00137       /// PortableServer::Current::get_object_id().
00138       void user_id (const PortableServer::ObjectId *);
00139       const PortableServer::ObjectId &user_id (void) const;
00140 
00141       /// Servant accessor.
00142       PortableServer::Servant servant (void) const;
00143 
00144   #if (TAO_HAS_MINIMUM_POA == 0)
00145 
00146       /// Get the Servant Locator's cookie
00147       void* locator_cookie (void) const;
00148 
00149       /// Set the Servant Locator's cookie
00150       void locator_cookie (void* cookie);
00151 
00152       /// Get the operation name.
00153       const char *operation (void) const;
00154 
00155       /// Set the operation name.
00156       void operation (const char *);
00157 
00158   #endif /* TAO_HAS_MINIMUM_POA == 0 */
00159 
00160       /// Set the active_object_map_entry.
00161       void active_object_map_entry (TAO_Active_Object_Map_Entry *entry);
00162 
00163       /// Get the active_object_map_entry.
00164       TAO_Active_Object_Map_Entry *active_object_map_entry (void) const;
00165 
00166       /// Get the priority for the current upcall.
00167       CORBA::Short priority (void) const;
00168 
00169       enum State
00170       {
00171         INITIAL_STAGE,
00172         OBJECT_ADAPTER_LOCK_ACQUIRED,
00173         POA_CURRENT_SETUP,
00174         OBJECT_ADAPTER_LOCK_RELEASED,
00175         SERVANT_LOCK_ACQUIRED
00176       };
00177 
00178       /// Get the state.
00179       State state (void) const;
00180 
00181       /// Set the state.
00182       void state (State);
00183 
00184       /// Increment the refcount
00185       void increment_servant_refcount (void);
00186 
00187     protected:
00188 
00189       void post_invoke_servant_cleanup (void);
00190       void single_threaded_poa_setup (ACE_ENV_SINGLE_ARG_DECL);
00191       void single_threaded_poa_cleanup (void);
00192       void servant_cleanup (void);
00193       void poa_cleanup (void);
00194 
00195       /// Clean-up / reset state of this Servant_Upcall object.
00196       void upcall_cleanup (void);
00197 
00198     protected:
00199 
00200       TAO_Object_Adapter *object_adapter_;
00201 
00202       ::TAO_Root_POA *poa_;
00203 
00204       PortableServer::Servant servant_;
00205 
00206       State state_;
00207 
00208       PortableServer::ObjectId system_id_;
00209 
00210       const PortableServer::ObjectId *user_id_;
00211 
00212       POA_Current_Impl current_context_;
00213 
00214   #if (TAO_HAS_MINIMUM_POA == 0)
00215 
00216       /// Servant Locator's cookie
00217       void* cookie_;
00218 
00219       /// Operation name for this current.
00220       const char *operation_;
00221 
00222   #endif /* TAO_HAS_MINIMUM_POA == 0 */
00223 
00224       /// Pointer to the entry in the TAO_Active_Object_Map corresponding
00225       /// to the servant for this request.
00226       TAO_Active_Object_Map_Entry *active_object_map_entry_;
00227 
00228       /// Preinvoke data for the upcall.
00229       Pre_Invoke_State pre_invoke_state_;
00230 
00231     private:
00232       Servant_Upcall (const Servant_Upcall &);
00233       void operator= (const Servant_Upcall &);
00234     };
00235   }
00236 }
00237 
00238 TAO_END_VERSIONED_NAMESPACE_DECL
00239 
00240 #if defined(_MSC_VER)
00241 #pragma warning(pop)
00242 #endif /* _MSC_VER */
00243 
00244 #if defined (__ACE_INLINE__)
00245 # include "tao/PortableServer/Servant_Upcall.inl"
00246 #endif /* __ACE_INLINE__ */
00247 
00248 #include /**/ "ace/post.h"
00249 
00250 #endif /* TAO_SERVANT_UPCALL_H */

Generated on Thu Nov 9 12:40:44 2006 for TAO_PortableServer by doxygen 1.3.6