1 #include "tao/RTCORBA/RT_Service_Context_Handler.h"
3 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
5 #include "tao/RTCORBA/RT_Policy_i.h"
6 #include "tao/RTCORBA/RT_Protocols_Hooks.h"
7 #include "tao/RTCORBA/RT_Stub.h"
9 #include "tao/TAO_Server_Request.h"
10 #include "tao/Transport.h"
11 #include "tao/ORB_Core.h"
12 #include "tao/GIOP_Message_Base.h"
13 #include "tao/operation_details.h"
14 #include "tao/Transport_Mux_Strategy.h"
16 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
19 TAO_RT_Service_Context_Handler::process_service_context (
21 const IOP::ServiceContext
&,
28 TAO_RT_Service_Context_Handler::generate_service_context (
31 TAO_Operation_Details
&opdetails
,
32 TAO_Target_Specification
&,
35 TAO_RT_Stub
*rt_stub
=
36 dynamic_cast<TAO_RT_Stub
*> (stub
);
40 CORBA::Policy_var priority_model_policy
=
41 rt_stub
->get_cached_policy (TAO_CACHED_POLICY_PRIORITY_MODEL
);
43 RTCORBA::PriorityModelPolicy_var model_policy_ptr
=
44 RTCORBA::PriorityModelPolicy::_narrow (priority_model_policy
.in ());
46 if (!CORBA::is_nil (model_policy_ptr
.in ()))
48 TAO_PriorityModelPolicy
*priority_model
=
49 static_cast<TAO_PriorityModelPolicy
*> (model_policy_ptr
.in ());
51 if (priority_model
->get_priority_model () == RTCORBA::CLIENT_PROPAGATED
)
53 CORBA::Short client_priority
= -1;
54 TAO_Protocols_Hooks
*protocol_hooks
= stub
->orb_core ()->get_protocols_hooks ();
55 // Get client thread priority from 'Current' or if not set by implying one
56 // from the native thread priority via the mapping.
58 (protocol_hooks
->get_thread_CORBA_priority (client_priority
) != -1 ||
59 protocol_hooks
->get_thread_implicit_CORBA_priority (client_priority
) != -1))
65 if (TAO_debug_level
> 0)
66 TAOLIB_ERROR ((LM_ERROR
, "ERROR: TAO_RT_Protocols_Hooks::rt_service_context. "
67 "Unable to access RT CORBA Priority in client thread "
68 "accessing object with CLIENT_PROPAGATED priority model.\n"));
69 throw CORBA::DATA_CONVERSION (CORBA::OMGVMCID
| 2, CORBA::COMPLETED_NO
);
72 // Encapsulate the priority of the current thread into
75 if (!(cdr
<< ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER
))
76 || !(cdr
<< client_priority
))
78 throw CORBA::MARSHAL ();
81 opdetails
.request_service_context ().set_context (IOP::RTCorbaPriority
, cdr
);
86 // The Object does not contain PriorityModel policy in its IOR.
87 // We must be talking to a non-RT ORB. Do nothing.
94 TAO_END_VERSIONED_NAMESPACE_DECL