2 #include "ace/Get_Opt.h"
5 #include "FOO_IORInterceptor_ORBInitializer.h"
7 #include "tao/ORBInitializer_Registry.h"
8 #include "ace/OS_NS_stdio.h"
10 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("test.ior");
13 parse_args (int argc
, ACE_TCHAR
*argv
[])
15 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
18 while ((c
= get_opts ()) != -1)
22 ior_output_file
= get_opts
.opt_arg ();
25 ACE_ERROR_RETURN ((LM_ERROR
,
33 // Indicates successful parsing of the command line
38 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
42 #if TAO_HAS_INTERCEPTORS == 1
43 PortableInterceptor::ORBInitializer_ptr temp_initializer
=
44 PortableInterceptor::ORBInitializer::_nil ();
46 ACE_NEW_RETURN (temp_initializer
,
47 FOO_IORInterceptor_ORBInitializer
,
48 -1); // No CORBA exceptions yet!
49 PortableInterceptor::ORBInitializer_var orb_initializer
=
52 PortableInterceptor::register_orb_initializer (orb_initializer
.in ());
54 #endif /* TAO_HAS_INTERCEPTORS == 1 */
56 CORBA::ORB_var orb
= CORBA::ORB_init (argc
,
60 CORBA::Object_var obj
=
61 orb
->resolve_initial_references ("RootPOA");
63 PortableServer::POA_var root_poa
=
64 PortableServer::POA::_narrow (obj
.in ());
66 if (CORBA::is_nil (root_poa
.in ()))
67 ACE_ERROR_RETURN ((LM_ERROR
,
68 "Unable to obtain RootPOA reference.\n"),
71 PortableServer::POAManager_var poa_manager
=
72 root_poa
->the_POAManager ();
74 poa_manager
->activate ();
76 if (parse_args (argc
, argv
) != 0)
79 test_i
server_impl (orb
.in ());
81 obj
= server_impl
._this ();
83 FOO::test_var server
= FOO::test::_narrow (obj
.in ());
85 if (CORBA::is_nil (server
.in ()))
86 ACE_ERROR_RETURN ((LM_ERROR
,
87 "Unable to obtain reference to FOO::test "
91 CORBA::String_var ior
=
92 orb
->object_to_string (server
.in ());
94 ACE_DEBUG ((LM_INFO
, "FOO::test: <%C>\n", ior
.in ()));
96 // If the ior_output_file exists, output the IOR to it.
97 if (ior_output_file
!= 0)
99 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
100 if (output_file
== 0)
101 ACE_ERROR_RETURN ((LM_ERROR
,
102 "Cannot open output file for writing "
106 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
107 ACE_OS::fclose (output_file
);
112 ACE_DEBUG ((LM_INFO
, "Event loop finished.\n"));
114 // The interceptors will be destroyed when we call this
117 catch (const CORBA::Exception
& ex
)
119 ex
._tao_print_exception ("IORInterceptor test (server-side):");