summaryrefslogtreecommitdiff
path: root/TAO/tao/PI_Server/ServerRequestDetails.cpp
blob: 3bc4852ec1addadc247a2b05d858f0f2746a74d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "tao/PI_Server/ServerRequestDetails.h"

#if TAO_HAS_INTERCEPTORS == 1

#if !defined (__ACE_INLINE__)
#include "tao/PI_Server/ServerRequestDetails.inl"
#endif /* defined INLINE */

ACE_RCSID (PI_Server,
           ServerRequestDetails,
           "$Id$")

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

namespace TAO
{
  void
  ServerRequestDetails::apply_policies (
      const CORBA::PolicyList &policies
      ACE_ENV_ARG_DECL)
  {
    // Flag to check for duplicate ProcessingModePolicy objects in the list.
    bool processing_mode_applied = false;

    const CORBA::ULong plen = policies.length ();

    for (CORBA::ULong i = 0; i < plen; ++i)
      {
        CORBA::Policy_var policy = policies[i];

        if (CORBA::is_nil (policy.in ()))
          {
            // Just ignore nil policies...
            continue;
          }

        // Obtain the PolicyType from the current Policy object.
        const CORBA::PolicyType policy_type =
          policy->policy_type (ACE_ENV_SINGLE_ARG_PARAMETER);
        ACE_CHECK;

        if (policy_type == PortableInterceptor::PROCESSING_MODE_POLICY_TYPE)
          {
            if (processing_mode_applied)
              {
                // This is the second time we have run into this policy type,
                // and that is not allowed.
                ACE_THROW (CORBA::INV_POLICY ());
              }

            // Flip the flag to true in order to trap any dupes.
            processing_mode_applied = true;

            // Narrow the Policy to the ProcessingModePolicy interface.
            PortableInterceptor::ProcessingModePolicy_var pm_policy =
                    PortableInterceptor::ProcessingModePolicy::_narrow (
                                                 policy.in ()
                                                 ACE_ENV_ARG_PARAMETER);
            ACE_CHECK;

            // Save the value of the ProcessingModePolicy in our data member.
            this->processing_mode_ =
              pm_policy->processing_mode (ACE_ENV_SINGLE_ARG_PARAMETER);
            ACE_CHECK;
          }
        else
          {
            // We don't support the current policy type.
            ACE_THROW (CORBA::INV_POLICY ());
          }
      }
  }
}

TAO_END_VERSIONED_NAMESPACE_DECL

#endif  /* TAO_HAS_INTERCEPTORS == 1 */