summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Concurrency/Concurrency_Loader.cpp
blob: 74555ec8ed7bc240a782b402f2bb54312ec1c3fb (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
65
66
67
68
69
70
71
72
73
74
75
76
// ================================================================
// LIBRARY
//   libTAO_CosConcurrency.so
//
// DESCRIPTION
//   This class allows for dynamically loading
//   the Concurrency Service.
//
// AUTHORS
//   Priyanka Gontla <pgontla@ece.uci.edu>
//   Jaiganesh Balasubramanian <jai@doc.ece.uci.edu>
// ================================================================

#include "orbsvcs/Concurrency/Concurrency_Loader.h"
#include "ace/Dynamic_Service.h"



TAO_BEGIN_VERSIONED_NAMESPACE_DECL

TAO_Concurrency_Loader::TAO_Concurrency_Loader ()
{
}

TAO_Concurrency_Loader::~TAO_Concurrency_Loader ()
{
}

int
TAO_Concurrency_Loader::init (int argc, ACE_TCHAR *argv[])
{
  try
    {
      // Initialize the ORB
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      // This function call initializes the Concurrency Service
      CORBA::Object_var object =
        this->create_object (orb.in (), argc, argv);
    }
  catch (const CORBA::Exception&)
    {
      // @@ Should we log this???
      return -1;
    }
  return 0;
}

int
TAO_Concurrency_Loader::fini ()
{
  // Remove the Concurrency Service.
  this->concurrency_server_.fini();
  return 0;
}

CORBA::Object_ptr
TAO_Concurrency_Loader::create_object (CORBA::ORB_ptr orb,
                                       int /* argc */,
                                       ACE_TCHAR * /* argv */ [])
{
  CORBA::Object_var object =
    orb->resolve_initial_references ("RootPOA");
  PortableServer::POA_var poa =
    PortableServer::POA::_narrow (object.in ());
  PortableServer::POAManager_var poa_manager =
    poa->the_POAManager ();
  poa_manager->activate ();

  return this->concurrency_server_.init (orb, poa.in ());
}

TAO_END_VERSIONED_NAMESPACE_DECL

ACE_FACTORY_DEFINE (TAO_Concurrency_Serv, TAO_Concurrency_Loader)