1 #include "ace/Get_Opt.h"
2 #include "ace/OS_NS_stdio.h"
4 #include "tao/ORBInitializer_Registry.h"
5 #include "Server_ORBInitializer.h"
7 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("test.ior");
10 parse_args (int argc
, ACE_TCHAR
*argv
[])
12 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
15 while ((c
= get_opts ()) != -1)
19 ior_output_file
= get_opts
.opt_arg ();
23 ACE_ERROR_RETURN ((LM_ERROR
,
30 // Indicates successful parsing of the command line
35 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
40 Server_ORBInitializer
* temp_initializer
= 0;
42 ACE_NEW_RETURN (temp_initializer
,
43 Server_ORBInitializer
,
44 -1); // No exceptions yet!
45 PortableInterceptor::ORBInitializer_var initializer
= temp_initializer
;
47 PortableInterceptor::register_orb_initializer (initializer
.in ());
50 CORBA::ORB_init (argc
, argv
);
52 CORBA::Object_var poa_object
=
53 orb
->resolve_initial_references ("RootPOA");
55 if (CORBA::is_nil (poa_object
.in ()))
56 ACE_ERROR_RETURN ((LM_ERROR
,
57 " (%P|%t) Unable to initialize the POA.\n"),
60 PortableServer::POA_var root_poa
=
61 PortableServer::POA::_narrow (poa_object
.in ());
63 PortableServer::POAManager_var poa_manager
=
64 root_poa
->the_POAManager ();
66 poa_manager
->activate ();
68 if (parse_args (argc
, argv
) != 0)
71 Visual_i
server_impl (orb
.in ());
73 PortableServer::ObjectId_var id
=
74 root_poa
->activate_object (&server_impl
);
76 CORBA::Object_var test_obj
=
77 root_poa
->id_to_reference (id
.in ());
79 Test_Interceptors::Visual_var server
=
80 Test_Interceptors::Visual::_narrow (test_obj
.in ());
82 CORBA::String_var ior
=
83 orb
->object_to_string (server
.in ());
86 "Test_Interceptors::Visual: <%C>\n",
89 // If the ior_output_file exists, output the ior to it
90 if (ior_output_file
!= 0)
92 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
94 ACE_ERROR_RETURN ((LM_ERROR
,
95 "Cannot open output file for writing IOR: %s",
98 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
99 ACE_OS::fclose (output_file
);
104 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
106 root_poa
->destroy (1, 1);
110 catch (const CORBA::Exception
& ex
)
112 ex
._tao_print_exception ("Caught exception in server:");