summaryrefslogtreecommitdiff
path: root/TAO/tao/Monitor/Monitor.cpp
blob: ea13255cb38dc5eefb4a7e78dce3ec7d26750b76 (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
// -*- C++ -*-
#include "tao/Monitor/Monitor.h"
#include "tao/Monitor/Monitor_Impl.h"

#if defined (TAO_HAS_MONITOR_FRAMEWORK) && (TAO_HAS_MONITOR_FRAMEWORK == 1)

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

TAO_Monitor_Init::TAO_Monitor_Init (void)
{
}

CORBA::Object_ptr
TAO_Monitor_Init::create_object (CORBA::ORB_ptr orb,
                                 int,
                                 ACE_TCHAR *[])
{
  try
    {
      CORBA::Object_var obj =
        orb->resolve_initial_references ("RootPOA");

      PortableServer::POA_var poa =
        PortableServer::POA::_narrow (obj.in ());

      PortableServer::POAManager_var mgr =
        poa->the_POAManager ();

      mgr->activate ();

      Monitor_Impl *servant = 0;
      ACE_NEW_RETURN (servant,
                      Monitor_Impl (orb),
                      CORBA::Object::_nil ());

      PortableServer::ObjectId_var id =
        poa->activate_object (servant);

      PortableServer::ServantBase_var safe_servant = servant;
      obj = servant->_this ();

      return obj._retn ();
    }
  catch (const CORBA::Exception&)
    {
    }

  return CORBA::Object::_nil ();
}

// This initializer is very similar to the ORBInitializer_Registry::init.
// This one is used during static initialization while the other is used
// when Monitor is a shared library.
int
TAO_Monitor_Init::Initializer (void)
{
  return ACE_Service_Config::process_directive (ace_svc_desc_TAO_Monitor_Init);
}


ACE_STATIC_SVC_DEFINE (TAO_Monitor_Init,
                       ACE_TEXT ("Monitor_Init"),
                       ACE_SVC_OBJ_T,
                       &ACE_SVC_NAME (TAO_Monitor_Init),
                       ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
                       0)
ACE_FACTORY_DEFINE (TAO_Monitor, TAO_Monitor_Init)

TAO_END_VERSIONED_NAMESPACE_DECL

#endif /* TAO_HAS_MONITOR_FRAMEWORK==1 */