Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / orbsvcs / DevGuideExamples / NamingService / Naming_Server / NamingTask.cpp
blob8f84e2918a83172ea4638bda3eed564a140374a8
1 #include "NamingTask.h"
2 #include "orbsvcs/Naming/Naming_Server.h"
3 #include "ace/OS_NS_unistd.h"
4 #include <iostream>
6 NamingTask::NamingTask (int argc, ACE_TCHAR** argv)
7 : argc_ (argc),
8 argv_ (argv),
9 initialized_(false)
11 orb_ = CORBA::ORB_init(argc, argv, "NamingORB");
14 void NamingTask::waitInit ()
16 // Wait for Naming Service initialized.
17 while (! initialized_) {
18 ACE_OS::sleep(ACE_Time_Value(0, 100 * 1000));
22 void NamingTask::end()
24 orb_->shutdown(0);
25 this->wait();
28 int NamingTask::svc()
30 try {
31 // Get reference to Root POA
32 CORBA::Object_var obj = orb_->resolve_initial_references("RootPOA");
33 PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in());
35 // Activate POA Manager
36 PortableServer::POAManager_var poaManager = poa->the_POAManager();
37 poaManager->activate();
39 // Initialize the naming service
40 // We are not going to look for other naming servers
41 TAO_Naming_Server naming;
42 if (naming.init(orb_.in(),
43 poa.in(),
44 ACE_DEFAULT_MAP_SIZE,
46 0) == 0) {
47 std::cout << "The Naming Service Task is ready." << std::endl;
48 initialized_ = true;
49 // Accept requests
50 orb_->run();
51 orb_->destroy();
52 return 0;
54 else {
55 std::cerr << "Unable to initialize the Naming Service." << std::endl;
58 catch(const CORBA::Exception& ex) {
59 std::cerr << "NamingTask::svc() CORBA::Exception: " << ex << std::endl;
62 return -1;