2 #include "orbsvcs/CosNamingC.h"
3 #include "ace/Get_Opt.h"
7 const ACE_TCHAR
*ior
= ACE_TEXT("file://shutdown.ior");
8 bool shutdown_nsmain
= false;
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
17 while ((c
= get_opts ()) != -1)
21 ior
= get_opts
.opt_arg ();
22 shutdown_nsmain
= true;
25 ACE_ERROR_RETURN ((LM_ERROR
,
31 // Indicates successful parsing of the command line
36 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
40 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
42 if (parse_args (argc
, argv
) != 0)
45 CORBA::Object_var tmp
=
46 orb
->string_to_object("corbaloc:iiop:1.2@localhost:9931/NameService");
48 CosNaming::NamingContext_var root
=
49 CosNaming::NamingContext::_narrow(tmp
.in());
51 if (CORBA::is_nil (root
.in ()))
53 ACE_ERROR_RETURN ((LM_DEBUG
,
54 "Nil NamingService reference\n"),
58 ACE_DEBUG ((LM_INFO
, "**** Narrowed root NamingContext\n"));
62 name
[0].id
= CORBA::string_dup("This");
63 name
[0].kind
= CORBA::string_dup("");
64 name
[1].id
= CORBA::string_dup("eat");
65 name
[1].kind
= CORBA::string_dup("");
66 name
[2].id
= CORBA::string_dup("my");
67 name
[2].kind
= CORBA::string_dup("");
68 name
[3].id
= CORBA::string_dup("memory");
69 name
[3].kind
= CORBA::string_dup("");
71 for (int i
= 0; i
< test_count
; i
++)
75 tmp
= root
->resolve (name
);
76 ACE_DEBUG ((LM_INFO
, "**** Resolved #example/Hello\n"));
78 Test::Hello_var hello
=
79 Test::Hello::_narrow(tmp
.in ());
81 ACE_ERROR_RETURN ((LM_DEBUG
,
82 "Nil Test::Hello reference\n"),
85 catch (const CosNaming::NamingContext::NotFound
&)
87 ACE_DEBUG ((LM_DEBUG
, "Caught correct exception for iteration %d\n", i
));
93 CORBA::Object_var shutdowntmp
= orb
->string_to_object(ior
);
95 Test::NsShutdown_var shutdown
=
96 Test::NsShutdown::_narrow(shutdowntmp
.in ());
98 ACE_DEBUG ((LM_DEBUG
, "Shutdown nsmain\n"));
99 shutdown
->shutdown ();
105 catch (const CORBA::Exception
& ex
)
107 ex
._tao_print_exception ("Exception caught:");