blob: f23b234e7e22472191632ac339c0b8e29b4c5c3e (
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#include "orbsvcs/Log_Macros.h"
#include "Activator_Loader.h"
#include "ace/Dynamic_Service.h"
#include "ace/Task.h"
class ImR_Activator_ORB_Runner : public ACE_Task_Base
{
ImR_Activator_Loader& service_;
public:
ImR_Activator_ORB_Runner (ImR_Activator_Loader& service)
: service_ (service)
{
}
virtual int svc ()
{
// Block until service_.fini() calls orb->destroy()
this->service_.run ();
return 0;
}
};
ImR_Activator_Loader::ImR_Activator_Loader ()
{
}
// For now, we will assume that it's sufficient to start
// the service in its own thread. Later, if necessary, we
// can add a command line option to allow the imr to use
// the same orb as other tao services, however the imr
// is currently written with the assumption that it's running
// in its own orb.
int
ImR_Activator_Loader::init (int argc, ACE_TCHAR *argv[])
{
try
{
int err = this->opts_.init (argc, argv);
if (err != 0)
return -1;
// Creates it's own internal orb, which we must run later
err = this->service_.init (this->opts_);
if (err != 0)
return -1;
// Create a thread in which to run the service
ACE_ASSERT (this->runner_.get () == 0);
this->runner_.reset (new ImR_Activator_ORB_Runner (*this));
this->runner_->activate ();
}
catch (const CORBA::Exception&)
{
return -1;
}
return 0;
}
int
ImR_Activator_Loader::fini ()
{
ACE_ASSERT (this->runner_.get() != 0);
try
{
int ret = this->service_.fini ();
this->runner_->wait ();
this->runner_.reset (0);
return ret;
}
catch (const CORBA::Exception&)
{
return -1;
}
}
CORBA::Object_ptr
ImR_Activator_Loader::create_object (CORBA::ORB_ptr,
int,
ACE_TCHAR **)
{
throw CORBA::NO_IMPLEMENT ();
}
int
ImR_Activator_Loader::run ()
{
try
{
return this->service_.run ();
}
catch (...)
{
ORBSVCS_ERROR ((LM_ERROR, "Exception in ImR_Locator_ORB_Runner()\n"));
return -1;
}
}
ACE_FACTORY_DEFINE (Activator, ImR_Activator_Loader)
|