Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / TAO / orbsvcs / ImplRepo_Service / Activator_Loader.cpp
blobf23b234e7e22472191632ac339c0b8e29b4c5c3e
1 #include "orbsvcs/Log_Macros.h"
2 #include "Activator_Loader.h"
3 #include "ace/Dynamic_Service.h"
4 #include "ace/Task.h"
6 class ImR_Activator_ORB_Runner : public ACE_Task_Base
8 ImR_Activator_Loader& service_;
9 public:
10 ImR_Activator_ORB_Runner (ImR_Activator_Loader& service)
11 : service_ (service)
14 virtual int svc ()
16 // Block until service_.fini() calls orb->destroy()
17 this->service_.run ();
18 return 0;
22 ImR_Activator_Loader::ImR_Activator_Loader ()
26 // For now, we will assume that it's sufficient to start
27 // the service in its own thread. Later, if necessary, we
28 // can add a command line option to allow the imr to use
29 // the same orb as other tao services, however the imr
30 // is currently written with the assumption that it's running
31 // in its own orb.
32 int
33 ImR_Activator_Loader::init (int argc, ACE_TCHAR *argv[])
35 try
37 int err = this->opts_.init (argc, argv);
38 if (err != 0)
39 return -1;
41 // Creates it's own internal orb, which we must run later
42 err = this->service_.init (this->opts_);
43 if (err != 0)
44 return -1;
46 // Create a thread in which to run the service
47 ACE_ASSERT (this->runner_.get () == 0);
48 this->runner_.reset (new ImR_Activator_ORB_Runner (*this));
49 this->runner_->activate ();
51 catch (const CORBA::Exception&)
53 return -1;
55 return 0;
58 int
59 ImR_Activator_Loader::fini ()
61 ACE_ASSERT (this->runner_.get() != 0);
62 try
64 int ret = this->service_.fini ();
66 this->runner_->wait ();
67 this->runner_.reset (0);
68 return ret;
70 catch (const CORBA::Exception&)
72 return -1;
76 CORBA::Object_ptr
77 ImR_Activator_Loader::create_object (CORBA::ORB_ptr,
78 int,
79 ACE_TCHAR **)
81 throw CORBA::NO_IMPLEMENT ();
84 int
85 ImR_Activator_Loader::run ()
87 try
89 return this->service_.run ();
91 catch (...)
93 ORBSVCS_ERROR ((LM_ERROR, "Exception in ImR_Locator_ORB_Runner()\n"));
94 return -1;
98 ACE_FACTORY_DEFINE (Activator, ImR_Activator_Loader)