summaryrefslogtreecommitdiff
path: root/TAO/tests/POA/On_Demand_Act_Direct_Coll/Servant_Activator.cpp
blob: 646f86ba81b1a8d111db2db6e16a88b32bbfbc93 (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

//=============================================================================
/**
 *  @file     Servant_Activator.cpp
 *
 *  $Id$
 *
 *   Implementation of ServantActivator, which is used by a POA with
 *   a RETAIN policy.
 *
 *
 *  @author  Irfan Pyarali
 */
//=============================================================================


#include "Servant_Activator.h"
#include "test_i.h"
#include "ace/OS_NS_string.h"

ServantActivator::ServantActivator (CORBA::ORB_ptr orb,
                                    ACE_thread_t thrid)
  : orb_ (CORBA::ORB::_duplicate (orb)),
    thr_id_ (thrid)
{
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("ServantActivator::ServantActivator\n")));
}

PortableServer::Servant
ServantActivator::incarnate (const PortableServer::ObjectId &oid,
                             PortableServer::POA_ptr poa)
{
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("ServantActivator::incarnate\n")));
  // Convert ObjectId to String.
  CORBA::String_var s = PortableServer::ObjectId_to_string (oid);

  // If ObjectId string has a test substring, create and return a
  // test_i.

  if (ACE_OS::strstr (s.in (), "test") != 0)
    return new test_i (this->orb_.in (), poa, this->thr_id_);
  else
    {
      throw CORBA::OBJECT_NOT_EXIST ();
    }
}


void
ServantActivator::etherealize (const PortableServer::ObjectId &,
                               PortableServer::POA_ptr ,
                               PortableServer::Servant servant,
                               CORBA::Boolean ,
                               CORBA::Boolean remaining_activations)
{
  ACE_DEBUG ((LM_DEBUG,
               ACE_TEXT ("ServantActivator::etherealize\n")));
  // If there are no remaining activations i.e ObjectIds associated
  // with test_i delete it.
  if (!remaining_activations)
    delete servant;
}