Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / TAO / tao / RTCORBA / RT_Service_Context_Handler.cpp
blob2f4d823ff3768b2d5ae78bd5ab774387e284d6b8
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"
8 #include "tao/CDR.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
18 int
19 TAO_RT_Service_Context_Handler::process_service_context (
20 TAO_Transport&,
21 const IOP::ServiceContext&,
22 TAO_ServerRequest*)
24 return 0;
27 int
28 TAO_RT_Service_Context_Handler::generate_service_context (
29 TAO_Stub *stub,
30 TAO_Transport&,
31 TAO_Operation_Details &opdetails,
32 TAO_Target_Specification &,
33 TAO_OutputCDR &)
35 TAO_RT_Stub *rt_stub =
36 dynamic_cast<TAO_RT_Stub *> (stub);
38 if (rt_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.
57 if (protocol_hooks &&
58 (protocol_hooks->get_thread_CORBA_priority (client_priority) != -1 ||
59 protocol_hooks->get_thread_implicit_CORBA_priority (client_priority) != -1))
61 // OK
63 else
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
73 // a service context.
74 TAO_OutputCDR cdr;
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);
84 else
86 // The Object does not contain PriorityModel policy in its IOR.
87 // We must be talking to a non-RT ORB. Do nothing.
90 return 0;
94 TAO_END_VERSIONED_NAMESPACE_DECL
96 #endif