summaryrefslogtreecommitdiff
path: root/TAO/examples/POA/Forwarding/Servant_Activator.cpp
blob: eedc9664cb64a8887f399d2de614547010bad3ce (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
// $Id$

#include "Servant_Activator.h"
#include "test_i.h"

ACE_RCSID(Forwarding, Servant_Activator, "$Id$")

  ServantActivator::ServantActivator (CORBA::ORB_ptr orb,
                                      CORBA::Object_ptr forward_to)
    : orb_ (CORBA::ORB::_duplicate (orb)),
      forward_to_ (CORBA::Object::_duplicate (forward_to))
{
}

PortableServer::Servant
ServantActivator::incarnate (const PortableServer::ObjectId &,
                             PortableServer::POA_ptr)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   PortableServer::ForwardRequest))
{
  this->orb_->shutdown (0);

  // Throw forward exception
  ACE_THROW_RETURN (
                    PortableServer::ForwardRequest (
                                                    this->forward_to_.in ()),
                    0);
}

void
ServantActivator::etherealize (const PortableServer::ObjectId &,
                               PortableServer::POA_ptr,
                               PortableServer::Servant servant,
                               CORBA::Boolean,
                               CORBA::Boolean)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  delete servant;
}

void
ServantActivator::forward_requests (void)
{
  if (CORBA::is_nil (this->forward_to_.in ()))
    throw test::Cannot_Forward ();
}