summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/LoadBalancing/DSI_ForwardingProxy.cpp
blob: d0ad39c97388b988056ca29dfa602572cb4ed094 (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
// -*- C++ -*-

// $Id$

#include "DSI_ForwardingProxy.h"
#include "LoadBalancer_i.h"

ACE_RCSID(orbsvcs, DSI_ForwardingProxy, "$Id$")

DSI_ForwardingProxy::DSI_ForwardingProxy (LoadBalancer_Impl *lb,
                                          const char *id)
  : load_balancer_ (lb), // Hopefully these pointers won't be zero!
    interface_id_ (id)
{
  // Nothing else
}

void
DSI_ForwardingProxy::invoke (CORBA::ServerRequest_ptr /* request */,
                             CORBA::Environment &ACE_TRY_ENV)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   PortableServer::ForwardRequest))
{
  CORBA::Object_ptr replica =
    this->load_balancer_->replica (ACE_TRY_ENV);
  ACE_CHECK;

  // Throw a forward exception to force the client to redirect its
  // requests to the Replica chosen by the LoadBalancer.

  // @@ We should NOT be throwing this exception inside user code.
  //    Instead we should be using servant locators.
  ACE_THROW (PortableServer::ForwardRequest (
               CORBA::Object::_duplicate (replica)));
}

CORBA::RepositoryId
DSI_ForwardingProxy::_primary_interface (
                         const PortableServer::ObjectId &,
                         PortableServer::POA_ptr,
                         CORBA::Environment &)
  ACE_THROW_SPEC (())
{
  return CORBA::string_dup (this->interface_id_.in ());
}