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

#include "Servant_Activator.h"
#include "MyFooServant.h"

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

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

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

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

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

void
MyFooServantActivator::forward_requests (ACE_ENV_SINGLE_ARG_DECL)
{
  if (CORBA::is_nil (this->forward_to_.in ()))
    ACE_THROW (Foo::Cannot_Forward ());
}