5 #include "ace/Get_Opt.h"
8 #include "server_interceptor.h"
9 #include "orb_initializer.h"
10 #include "tao/ORBInitializer_Registry.h"
12 const ACE_TCHAR
*ior_filename
= ACE_TEXT("server.ior");
15 parse_args (int argc
, ACE_TCHAR
*argv
[])
17 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:m:n:t"));
20 while ((c
= get_opts ()) != -1)
25 ior_filename
= get_opts
.opt_arg ();
29 ACE_ERROR_RETURN ((LM_ERROR
,
37 // Indicates successful parsing of the command line
42 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
46 // Create the ORB initializer.
47 Server_ORBInitializer
*temp_initializer
= 0;
48 ACE_NEW_RETURN (temp_initializer
,
49 Server_ORBInitializer
,
52 PortableInterceptor::ORBInitializer_var initializer
=
55 PortableInterceptor::register_orb_initializer (initializer
.in ());
57 // Now initialize the ORB.
58 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
59 CORBA::Object_var poa_object
=
60 orb
->resolve_initial_references("RootPOA");
62 if (CORBA::is_nil (poa_object
.in ()))
64 ACE_ERROR_RETURN ((LM_ERROR
,
65 " (%P|%t) Unable to initialize the POA.\n"),
69 PortableServer::POA_var root_poa
=
70 PortableServer::POA::_narrow (poa_object
.in ());
72 PortableServer::POAManager_var poa_manager
=
73 root_poa
->the_POAManager ();
75 if (parse_args (argc
, argv
) != 0)
80 // Create the interceptor.
81 ForwardTest_Request_Interceptor
* server_interceptor
=
82 temp_initializer
->server_interceptor();
84 Forward_Test_i
*final_impl
= new Forward_Test_i(orb
.in ());
85 PortableServer::ServantBase_var servant
= final_impl
;
86 Forward::Test_var target
= final_impl
->_this ();
88 server_interceptor
->forward_reference (target
.in());
90 Forward_Test_i
*server_impl
= new Forward_Test_i (orb
.in());
91 servant
= server_impl
;
92 Forward::Test_var server
= server_impl
->_this ();
94 CORBA::String_var iorstr
=
95 orb
->object_to_string (server
.in ());
97 FILE *output_file
= ACE_OS::fopen (ior_filename
, "w");
99 ACE_ERROR_RETURN ((LM_ERROR
,
100 "Cannot open output file for writing IOR: %s\n",
103 ACE_OS::fprintf (output_file
, "%s", iorstr
.in());
104 ACE_OS::fclose (output_file
);
106 poa_manager
->activate ();
110 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
112 catch (const CORBA::Exception
& ex
)
114 ex
._tao_print_exception ("Server: exception caught - ");