summaryrefslogtreecommitdiff
path: root/TAO/tao/LocateRequest_Invocation_Adapter.cpp
blob: 527999bff53376f4a829f9cfb78f8d38c5ea6bdf (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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#include "LocateRequest_Invocation_Adapter.h"
#include "Profile_Transport_Resolver.h"
#include "operation_details.h"
#include "LocateRequest_Invocation.h"
#include "Transport.h"
#include "Transport_Mux_Strategy.h"
#include "ORB_Core.h"

ACE_RCSID (tao,
           LocateRequest_Invocation_Adapter,
           "$Id$")

namespace TAO
{
  LocateRequest_Invocation_Adapter::LocateRequest_Invocation_Adapter (
      CORBA::Object *target)
    : target_ (target)
      , list_ (0)
  {
  }

  void
  LocateRequest_Invocation_Adapter::invoke (ACE_ENV_SINGLE_ARG_DECL)
  {
    CORBA::Object *effective_target = this->target_;

    TAO_Stub *stub =
      this->target_->_stubobj ();

    if (stub == 0)
      ACE_THROW (CORBA::INTERNAL (
                     CORBA::SystemException::_tao_minor_code (
                       0,
                         EINVAL),
                        CORBA::COMPLETED_NO));

    ACE_Time_Value tmp_wait_time;
    ACE_Time_Value *max_wait_time = 0;

    bool is_timeout  =
      this->get_timeout (tmp_wait_time);

    if (is_timeout)
      max_wait_time = &tmp_wait_time;

    Invocation_Status s = TAO_INVOKE_START;

    while (s == TAO_INVOKE_START ||
           s == TAO_INVOKE_RESTART)
      {
        Profile_Transport_Resolver resolver (effective_target,
                                             stub,
                                             true);

        ACE_TRY
          {
            resolver.init_inconsistent_policies (
                ACE_ENV_SINGLE_ARG_PARAMETER);
            ACE_TRY_CHECK;

            resolver.resolve (max_wait_time
                              ACE_ENV_ARG_PARAMETER);
            ACE_TRY_CHECK;

            // Dummy operation details that is used to instantiate the
            // LocateRequest class.
            TAO_Operation_Details op (0,
                                      0,
                                      0);

            op.request_id (resolver.transport ()->tms ()->request_id ());
            TAO::LocateRequest_Invocation synch (this->target_,
                                                 resolver,
                                                 op);

            s = synch.invoke (max_wait_time
                              ACE_ENV_ARG_PARAMETER);
            ACE_TRY_CHECK;
          }
        ACE_CATCH (CORBA::INV_POLICY, ex)
          {
            this->list_ =
              resolver.steal_inconsistent_policies ();
            ACE_RE_THROW;
          }
        ACE_CATCHANY
          {
            ACE_RE_THROW;
          }
        ACE_ENDTRY;
        ACE_CHECK;
      }

    return;
  }

  CORBA::PolicyList *
  LocateRequest_Invocation_Adapter::get_inconsistent_policies (void)
  {
    return this->list_._retn ();
  }

  bool
  LocateRequest_Invocation_Adapter::get_timeout (ACE_Time_Value &timeout)
  {
    bool has_timeout = false;
    this->target_->orb_core ()->call_timeout_hook (this->target_->_stubobj (),
                                                   has_timeout,
                                                   timeout);

    return has_timeout;
  }
} // End namespace TAO