1 #include "NamingTask.h"
2 #include "orbsvcs/Naming/Naming_Server.h"
3 #include "ace/OS_NS_unistd.h"
4 #include "ace/Argv_Type_Converter.h"
6 NamingTask::NamingTask (const char* orbname
, int argc
, ACE_TCHAR
**argv
, unsigned short port
)
9 ACE_TCHAR
**my_argv
= new ACE_TCHAR
*[argc
+ 2];
12 for(; my_argc
<argc
;++my_argc
)
13 my_argv
[my_argc
] = argv
[my_argc
];
14 ACE_OS::sprintf (buf
, ACE_TEXT ("iiop://localhost:%d"), port
);
15 const ACE_TCHAR
* epopt
= ACE_TEXT ("-ORBEndpoint");
16 my_argv
[my_argc
++] = const_cast<ACE_TCHAR
*> (epopt
);
17 my_argv
[my_argc
++] = buf
;
19 orb_
= CORBA::ORB_init (my_argc
, my_argv
, orbname
);
24 void NamingTask::waitInit ()
26 // Wait for Naming Service initialized.
27 while (! initialized_
) {
28 ACE_OS::sleep(ACE_Time_Value(0, 100 * 1000));
32 void NamingTask::end()
38 const char* NamingTask::ior()
46 // Get reference to Root POA
47 CORBA::Object_var obj
= orb_
->resolve_initial_references("RootPOA");
48 PortableServer::POA_var poa
= PortableServer::POA::_narrow(obj
.in());
50 // Activate POA Manager
51 PortableServer::POAManager_var poaManager
= poa
->the_POAManager();
52 poaManager
->activate();
54 // Initialize the naming service
55 // We are not going to look for other naming servers
56 TAO_Naming_Server naming
;
57 if (naming
.init(orb_
.in(),
66 ACE_DEBUG ((LM_DEBUG
, "The Naming Service Task is ready.\n"));
67 ior_
= naming
.naming_service_ior ();
75 ACE_ERROR ((LM_ERROR
, "Unable to initialize the Naming Service.\n"));
78 catch (const CORBA::Exception
& ex
)
80 ex
._tao_print_exception ("NamingTask::svc() CORBA::Exception: ");