4 #include "tao/PortableServer/PortableServer.h"
5 #include "orbsvcs/CosNamingC.h"
7 int ACE_TMAIN (int argc
, ACE_TCHAR
* argv
[])
11 // First initialize the ORB, that will remove some arguments...
13 CORBA::ORB_init (argc
, argv
);
17 ACE_DEBUG ((LM_DEBUG
, "\nUsage:\n %s [NAME to insert in Naming Service]\n", argv
[0]));
20 // Get a reference to the RootPOA
21 CORBA::Object_var poa_object
=
22 orb
->resolve_initial_references ("RootPOA");
24 // narrow down to the correct reference
25 PortableServer::POA_var poa
=
26 PortableServer::POA::_narrow (poa_object
.in ());
29 PortableServer::POAManager_var poa_manager
=
30 poa
->the_POAManager ();
32 // Activate the POA Manager
33 poa_manager
->activate ();
36 corbaloc_Status_i status_i
;
37 status_i
.set_name (ACE_TEXT_ALWAYS_CHAR (argv
[1]));
38 // Activate it to obtain the reference
39 PortableServer::ObjectId_var id
=
40 poa
->activate_object (&status_i
);
42 CORBA::Object_var object
= poa
->id_to_reference (id
.in ());
44 corbaloc::Status_var status
=
45 corbaloc::Status::_narrow (object
.in ());
47 // Get a reference to Naming Context
48 CORBA::Object_var naming_context_object
=
49 orb
->resolve_initial_references ("NameService");
51 // Narrow down the reference
52 CosNaming::NamingContext_var naming_context
=
53 CosNaming::NamingContext::_narrow (naming_context_object
.in ());
55 // Bind Iterator_Factory to the Naming Context
56 CosNaming::Name
name (1);
58 name
[0].id
= CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (argv
[1]));
60 naming_context
->rebind (name
, status
.in ());
65 // Destroy the POA, waiting until the destruction terminates
66 poa
->destroy (true, true);
69 catch (const CORBA::SystemException
& ex
){
70 ex
._tao_print_exception ("CORBA exception raised! ");
72 catch (const CORBA::Exception
& ex
){
73 ex
._tao_print_exception ("Exception caught in server");