Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / tao / PI_Server / ServerRequestDetails.cpp
blob5ff18752ff7e787361b8e87c2fc540dbd1a09681
1 // -*- C++ -*-
2 #include "tao/PI_Server/ServerRequestDetails.h"
4 #if TAO_HAS_INTERCEPTORS == 1
6 #if !defined (__ACE_INLINE__)
7 #include "tao/PI_Server/ServerRequestDetails.inl"
8 #endif /* defined INLINE */
10 #include "tao/SystemException.h"
12 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
14 namespace TAO
16 void
17 ServerRequestDetails::apply_policies (const CORBA::PolicyList &policies)
19 // Flag to check for duplicate ProcessingModePolicy objects in the list.
20 bool processing_mode_applied = false;
22 CORBA::ULong const plen = policies.length ();
24 for (CORBA::ULong i = 0; i < plen; ++i)
26 CORBA::Policy_var policy = CORBA::Policy::_duplicate (policies[i]);
28 if (CORBA::is_nil (policy.in ()))
30 // Just ignore nil policies...
31 continue;
34 // Obtain the PolicyType from the current Policy object.
35 CORBA::PolicyType const policy_type = policy->policy_type ();
37 if (policy_type == PortableInterceptor::PROCESSING_MODE_POLICY_TYPE)
39 if (processing_mode_applied)
41 // This is the second time we have run into this policy type,
42 // and that is not allowed.
43 throw ::CORBA::INV_POLICY ();
46 // Flip the flag to true in order to trap any dupes.
47 processing_mode_applied = true;
49 // Narrow the Policy to the ProcessingModePolicy interface.
50 PortableInterceptor::ProcessingModePolicy_var pm_policy =
51 PortableInterceptor::ProcessingModePolicy::_narrow (
52 policy.in ());
54 // Save the value of the ProcessingModePolicy in our data member.
55 this->processing_mode_ = pm_policy->processing_mode ();
57 else
59 // We don't support the current policy type.
60 throw ::CORBA::INV_POLICY ();
66 TAO_END_VERSIONED_NAMESPACE_DECL
68 #endif /* TAO_HAS_INTERCEPTORS == 1 */