2 #include "orbsvcs/CosNamingC.h"
3 #include "ace/Get_Opt.h"
6 const ACE_TCHAR
*ior
= ACE_TEXT("file://shutdown.ior");
7 bool shutdown_nsmain
= false;
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
16 while ((c
= get_opts ()) != -1)
20 ior
= get_opts
.opt_arg ();
21 shutdown_nsmain
= true;
24 ACE_ERROR_RETURN ((LM_ERROR
,
30 // Indicates successful parsing of the command line
35 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
39 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
41 if (parse_args (argc
, argv
) != 0)
44 CORBA::Object_var tmp
=
45 orb
->string_to_object("corbaloc:iiop:1.2@localhost:9931/NameService");
47 CosNaming::NamingContext_var root
=
48 CosNaming::NamingContext::_narrow(tmp
.in());
50 if (CORBA::is_nil (root
.in ()))
52 ACE_ERROR_RETURN ((LM_DEBUG
,
53 "Nil NamingService reference\n"),
57 ACE_DEBUG ((LM_INFO
, "**** Narrowed root NamingContext\n"));
61 name
[0].id
= CORBA::string_dup("This");
62 name
[0].kind
= CORBA::string_dup("");
63 name
[1].id
= CORBA::string_dup("eat");
64 name
[1].kind
= CORBA::string_dup("");
65 name
[2].id
= CORBA::string_dup("my");
66 name
[2].kind
= CORBA::string_dup("");
67 name
[3].id
= CORBA::string_dup("memory");
68 name
[3].kind
= CORBA::string_dup("");
70 for (int i
= 0; i
< test_count
; i
++)
74 tmp
= root
->resolve (name
);
75 ACE_DEBUG ((LM_INFO
, "**** Resolved #example/Hello\n"));
77 Test::Hello_var hello
=
78 Test::Hello::_narrow(tmp
.in ());
80 ACE_ERROR_RETURN ((LM_DEBUG
,
81 "Nil Test::Hello reference\n"),
84 catch (const CosNaming::NamingContext::NotFound
&)
86 ACE_DEBUG ((LM_DEBUG
, "Caught correct exception for iteration %d\n", i
));
92 CORBA::Object_var shutdowntmp
= orb
->string_to_object(ior
);
94 Test::NsShutdown_var shutdown
=
95 Test::NsShutdown::_narrow(shutdowntmp
.in ());
97 ACE_DEBUG ((LM_DEBUG
, "Shutdown nsmain\n"));
98 shutdown
->shutdown ();
104 catch (const CORBA::Exception
& ex
)
106 ex
._tao_print_exception ("Exception caught:");