3 //=============================================================================
5 * @file Servant_Upcall.h
7 * @author Irfan Pyarali
9 //=============================================================================
11 #ifndef TAO_SERVANT_UPCALL_H
12 #define TAO_SERVANT_UPCALL_H
14 #include /**/ "ace/pre.h"
16 #include "tao/PortableServer/portableserver_export.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "tao/PortableServer/POA_Current_Impl.h"
26 #pragma warning(disable:4250)
29 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
31 // Forward declaration
33 class TAO_ServerRequest
;
34 class TAO_Object_Adapter
;
35 class TAO_RT_Collocation_Resolver
;
36 struct TAO_Active_Object_Map_Entry
;
41 typedef Object
*Object_ptr
;
42 typedef TAO_Pseudo_Var_T
<Object
> Object_var
;
43 typedef TAO_Pseudo_Out_T
<Object
> Object_out
;
48 namespace Portable_Server
51 * @class Servant_Upcall
53 * @brief This class finds out the POA and the servant to perform an
54 * upcall. It can only be instantiated without the object
55 * adapter's lock held. For each upcall a new instance of this
58 class TAO_PortableServer_Export Servant_Upcall
61 friend class ::TAO_RT_Collocation_Resolver
;
64 * @class Pre_Invoke_State
66 * @brief This struct keeps track of state related to pre- and
67 * post-invoke operations.
69 class Pre_Invoke_State
78 PRIORITY_RESET_REQUIRED
81 /// Indicates whether the priority of the thread needs to be
82 /// reset back to its original value.
85 /// Original native priority of the thread.
86 CORBA::Short original_native_priority_
;
88 /// Original CORBA priority of the thread.
89 CORBA::Short original_CORBA_priority_
;
93 explicit Servant_Upcall (TAO_ORB_Core
*orb_core
);
98 /// Locate POA and servant.
99 int prepare_for_upcall (const TAO::ObjectKey
&key
,
100 const char *operation
,
101 CORBA::Object_out forward_to
);
104 int prepare_for_upcall_i (const TAO::ObjectKey
&key
,
105 const char *operation
,
106 CORBA::Object_out forward_to
,
107 bool &wait_occurred_restart_call
);
109 /// Run pre_invoke for a remote request.
110 void pre_invoke_remote_request (TAO_ServerRequest
&req
);
112 /// Run pre_invoke for a collocated request.
113 void pre_invoke_collocated_request ();
115 /// Run post_invoke for a request.
119 ::TAO_Root_POA
*lookup_POA (const TAO::ObjectKey
&key
);
122 ::TAO_Root_POA
&poa () const;
124 /// Object Adapter accessor.
125 TAO_Object_Adapter
&object_adapter () const;
127 /// System ID accessor.
128 const PortableServer::ObjectId
&id () const;
130 /// User ID accessors. This is the same value returned by
131 /// PortableServer::Current::get_object_id().
132 void user_id (const PortableServer::ObjectId
*);
133 const PortableServer::ObjectId
&user_id () const;
135 /// Servant accessor.
136 PortableServer::Servant
servant () const;
138 #if (TAO_HAS_MINIMUM_POA == 0)
140 /// Get the Servant Locator's cookie
141 void* locator_cookie () const;
143 /// Set the Servant Locator's cookie
144 void locator_cookie (void* cookie
);
146 /// Get the operation name.
147 const char *operation () const;
149 /// Set the operation name.
150 void operation (const char *);
152 #endif /* TAO_HAS_MINIMUM_POA == 0 */
154 /// Set the active_object_map_entry.
155 void active_object_map_entry (TAO_Active_Object_Map_Entry
*entry
);
157 /// Get the active_object_map_entry.
158 TAO_Active_Object_Map_Entry
*active_object_map_entry () const;
160 /// Get the priority for the current upcall.
161 CORBA::Short
priority () const;
166 OBJECT_ADAPTER_LOCK_ACQUIRED
,
168 OBJECT_ADAPTER_LOCK_RELEASED
,
169 SERVANT_LOCK_ACQUIRED
173 State
state () const;
178 /// Increment the refcount
179 void increment_servant_refcount ();
182 void post_invoke_servant_cleanup ();
183 void single_threaded_poa_setup ();
184 void single_threaded_poa_cleanup ();
185 void servant_cleanup ();
188 /// Clean-up / reset state of this Servant_Upcall object.
189 void upcall_cleanup ();
192 TAO_Object_Adapter
*object_adapter_
;
194 ::TAO_Root_POA
*poa_
;
196 PortableServer::Servant servant_
;
200 CORBA::Octet system_id_buf_
[TAO_POA_OBJECT_ID_BUF_SIZE
];
201 PortableServer::ObjectId system_id_
;
203 const PortableServer::ObjectId
*user_id_
;
205 POA_Current_Impl current_context_
;
207 #if (TAO_HAS_MINIMUM_POA == 0)
209 /// Servant Locator's cookie
212 /// Operation name for this current.
213 const char *operation_
;
215 #endif /* TAO_HAS_MINIMUM_POA == 0 */
217 /// Pointer to the entry in the TAO_Active_Object_Map corresponding
218 /// to the servant for this request.
219 TAO_Active_Object_Map_Entry
*active_object_map_entry_
;
221 /// Preinvoke data for the upcall.
222 Pre_Invoke_State pre_invoke_state_
;
225 Servant_Upcall (const Servant_Upcall
&);
226 void operator= (const Servant_Upcall
&);
231 TAO_END_VERSIONED_NAMESPACE_DECL
233 #if defined(_MSC_VER)
235 #endif /* _MSC_VER */
237 #if defined (__ACE_INLINE__)
238 # include "tao/PortableServer/Servant_Upcall.inl"
239 #endif /* __ACE_INLINE__ */
241 #include /**/ "ace/post.h"
243 #endif /* TAO_SERVANT_UPCALL_H */