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;
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("example");
62 name
[1].id
= CORBA::string_dup("Hello");
66 tmp
= root
->resolve (name
);
67 ACE_DEBUG ((LM_INFO
, "**** Resolved #example/Hello\n"));
69 Test::Hello_var hello
=
70 Test::Hello::_narrow(tmp
.in ());
72 if (CORBA::is_nil (hello
.in ()))
74 ACE_ERROR_RETURN ((LM_DEBUG
,
75 "Nil Test::Hello reference\n"),
79 CORBA::String_var the_string
= hello
->get_string ();
81 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) - string returned <%C>\n",
86 catch (const CosNaming::NamingContext::CannotProceed
&)
88 ACE_DEBUG ((LM_DEBUG
, "Caught correct exception\n"));
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:");