1 #include "ace/Get_Opt.h"
3 #include "Server_ORBInitializer.h"
5 #include "tao/ORBInitializer_Registry.h"
6 #include "ace/OS_NS_stdio.h"
8 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("test.ior");
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
16 while ((c
= get_opts ()) != -1)
20 ior_output_file
= get_opts
.opt_arg ();
24 ACE_ERROR_RETURN ((LM_ERROR
,
31 // Indicates successful parsing of the command line
36 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
40 PortableInterceptor::ORBInitializer_ptr temp_initializer
;
42 ACE_NEW_RETURN (temp_initializer
,
43 Server_ORBInitializer
,
44 -1); // No exceptions yet!
45 PortableInterceptor::ORBInitializer_var initializer
=
48 PortableInterceptor::register_orb_initializer (initializer
.in ());
50 // Now we can create the ORB
52 CORBA::ORB_init (argc
, argv
);
54 CORBA::Object_var poa_object
=
55 orb
->resolve_initial_references ("RootPOA");
57 if (CORBA::is_nil (poa_object
.in ()))
58 ACE_ERROR_RETURN ((LM_ERROR
,
59 " (%P|%t) Unable to initialize the POA.\n"),
62 PortableServer::POA_var root_poa
=
63 PortableServer::POA::_narrow (poa_object
.in ());
65 PortableServer::POAManager_var poa_manager
=
66 root_poa
->the_POAManager ();
68 poa_manager
->activate ();
70 if (parse_args (argc
, argv
) != 0)
73 Visual_i
server_impl (orb
.in ());
75 PortableServer::ObjectId_var id
=
76 root_poa
->activate_object (&server_impl
);
78 CORBA::Object_var test_obj
=
79 root_poa
->id_to_reference (id
.in ());
81 Test_Interceptors::Visual_var server
=
82 Test_Interceptors::Visual::_narrow (test_obj
.in ());
84 CORBA::String_var ior
=
85 orb
->object_to_string (server
.in ());
88 "Test_Interceptors::Visual: <%C>\n",
91 // If the ior_output_file exists, output the ior to it
92 if (ior_output_file
!= 0)
94 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
96 ACE_ERROR_RETURN ((LM_ERROR
,
97 "Cannot open output file for writing IOR: %s",
100 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
101 ACE_OS::fclose (output_file
);
106 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
108 root_poa
->destroy (1, 1);
112 catch (const CORBA::Exception
& ex
)
114 ex
._tao_print_exception ("Caught exception in server:");