summaryrefslogtreecommitdiff
path: root/tests/POA/Forwarding/Servant_Activator.cpp
blob: 605a43debafbd3187ad6c0294204ddf51ebc2f38 (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
// $Id$

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

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)
{
  this->orb_->shutdown (0);

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

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

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