diff options
author | sma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2012-03-16 16:07:43 +0000 |
---|---|---|
committer | sma <sma@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2012-03-16 16:07:43 +0000 |
commit | 4e832a2a47b6c1d2babd5e4b6cb7c4c52146053e (patch) | |
tree | 6352b7ece234441d75118f8e05f485e3a0230d31 /TAO/tao | |
parent | 9c9e192843317880052ada586d5e6b045d3b9685 (diff) | |
download | ATCD-4e832a2a47b6c1d2babd5e4b6cb7c4c52146053e.tar.gz |
Fri Mar 16 16:07:00 UTC 2012 Simon Massey <simon dot massey at prismtech dot com>
* tao/ZIOP/ZIOP_Service_Context_Handler.cpp:
Correction to generate_service_context() to use a new OutputCDR for
each policy being encoded. (The later policies were being incorrectly
appended to the earlier polices as the slots in the policy sequence
were populated.) Provide the decode functionality for later use of
these policies in the server via process_service_context().
Diffstat (limited to 'TAO/tao')
-rw-r--r-- | TAO/tao/ZIOP/ZIOP_Service_Context_Handler.cpp | 87 |
1 files changed, 79 insertions, 8 deletions
diff --git a/TAO/tao/ZIOP/ZIOP_Service_Context_Handler.cpp b/TAO/tao/ZIOP/ZIOP_Service_Context_Handler.cpp index b8f4614192c..c7ed55b5a43 100644 --- a/TAO/tao/ZIOP/ZIOP_Service_Context_Handler.cpp +++ b/TAO/tao/ZIOP/ZIOP_Service_Context_Handler.cpp @@ -3,7 +3,6 @@ #include "tao/ZIOP/ZIOP_Service_Context_Handler.h" #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 - #include "tao/CDR.h" #include "tao/Transport.h" #include "tao/ORB_Core.h" @@ -18,8 +17,71 @@ TAO_BEGIN_VERSIONED_NAMESPACE_DECL int TAO_ZIOP_Service_Context_Handler::process_service_context ( TAO_Transport&, - const IOP::ServiceContext &) + const IOP::ServiceContext &ctx) { + // Ensure this context is actually for us to decode. + if (ctx.context_id != IOP::INVOCATION_POLICIES) + { + return 0; + } + + // Create an input CDR from the context buffer + TAO_InputCDR cdr (reinterpret_cast<const char*> (ctx.context_data.get_buffer ()), + ctx.context_data.length () ); + CORBA::Boolean byte_order; + if (!(cdr >> TAO_InputCDR::to_boolean (byte_order))) + { + return 0; + } + cdr.reset_byte_order (static_cast<int> (byte_order)); + + // Extract the sequence of policy values that was sent. + Messaging::PolicyValueSeq policy_value_seq; + if (!(cdr >> policy_value_seq)) + { + return 0; + } + + // Extract each policy from the slots we recieved. + for (size_t i = 0u; i < policy_value_seq.length (); ++i) + { + TAO_InputCDR policy_cdr ( + reinterpret_cast<const char*> (policy_value_seq[i].pvalue.get_buffer ()), + policy_value_seq[i].pvalue.length ()); + + if (policy_cdr >> TAO_InputCDR::to_boolean (byte_order)) + { + policy_cdr.reset_byte_order (static_cast<int> (byte_order)); + switch (policy_value_seq[i].ptype) + { + case ::ZIOP::COMPRESSION_ENABLING_POLICY_ID: + { + TAO::CompressionEnablingPolicy enabled; + if (enabled._tao_decode (policy_cdr)) + { + // TODO deal with this information sent from the client + // ACE_DEBUG ((LM_DEBUG, "*** ENABLING_POLICY decoded ***\n")); + } + break; + } + + case ::ZIOP::COMPRESSOR_ID_LEVEL_LIST_POLICY_ID: + { + TAO::CompressorIdLevelListPolicy id_list; + if (id_list._tao_decode (policy_cdr)) + { + // TODO deal with this information sent from the client + // ACE_DEBUG ((LM_DEBUG, "*** ID_LEVEL_LIST decoded ***\n")); + } + break; + } + + default: + break; + } + } + } + return 0; } @@ -33,29 +95,31 @@ TAO_ZIOP_Service_Context_Handler::generate_service_context ( { if (stub) { + // Obtain the two policies we are interested in sending to the server. CORBA::Policy_var idpolicy = stub->get_cached_policy (TAO_CACHED_COMPRESSION_ID_LEVEL_LIST_POLICY); - CORBA::Policy_var enabledpolicy = stub->get_cached_policy (TAO_CACHED_COMPRESSION_ENABLING_POLICY); + // upcast to the actual policy types. ::ZIOP::CompressorIdLevelListPolicy_var idpolicyp = ::ZIOP::CompressorIdLevelListPolicy::_narrow (idpolicy.in ()); - ::ZIOP::CompressionEnablingPolicy_var enabledpolicyp = ::ZIOP::CompressionEnablingPolicy::_narrow (enabledpolicy.in ()); + // Put these into a sequence of policy values. Messaging::PolicyValueSeq policy_value_seq; policy_value_seq.length (0); - TAO_OutputCDR out_CDR; CORBA::ULong i = 0; size_t length = 0; + // If we do have an COMPRESSION_ID_LEVEL_LIST_POLICY, place it in a slot if (!CORBA::is_nil (idpolicyp.in ())) { policy_value_seq.length (i + 1); policy_value_seq[i].ptype = idpolicyp->policy_type (); + TAO_OutputCDR out_CDR; if (!(out_CDR << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER))) return 0; @@ -76,11 +140,14 @@ TAO_ZIOP_Service_Context_Handler::generate_service_context ( } ++i; } + + // If we do have an COMPRESSION_ENABLING_POLICY, place it in a slot if (!CORBA::is_nil (enabledpolicyp.in ())) { policy_value_seq.length (i + 1); policy_value_seq[i].ptype = enabledpolicyp->policy_type (); + TAO_OutputCDR out_CDR; if (!(out_CDR << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER))) return 0; @@ -102,14 +169,19 @@ TAO_ZIOP_Service_Context_Handler::generate_service_context ( ++i; } - if (policy_value_seq.length () > 0) + // If we actually have any policies to send, encode them into the context. + if (0 < policy_value_seq.length ()) { TAO_OutputCDR out_cdr; if (!(out_cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER))) - return 0; + { + return 0; + } if (!(out_cdr << policy_value_seq)) + { return 0; + } opdetails.request_service_context ().set_context (IOP::INVOCATION_POLICIES, out_cdr); } @@ -119,5 +191,4 @@ TAO_ZIOP_Service_Context_Handler::generate_service_context ( } TAO_END_VERSIONED_NAMESPACE_DECL - #endif |