1 #include "ace/Get_Opt.h"
3 #include "Server_ORBInitializer.h"
4 #include "Server_Request_Interceptor.h"
5 #include "tao/ORBInitializer_Registry.h"
6 #include "ace/OS_NS_stdio.h"
9 const ACE_TCHAR
*ior_file
= 0;
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
17 while ((c
= get_opts ()) != -1)
21 ior_file
= get_opts
.opt_arg ();
24 ACE_ERROR_RETURN ((LM_ERROR
,
35 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
39 #if TAO_HAS_INTERCEPTORS == 1
40 bool destroy_called
= false;
42 Server_ORBInitializer
*temp_initializer
= 0;
43 ACE_NEW_RETURN (temp_initializer
,
44 Server_ORBInitializer (destroy_called
),
45 -1); // No exceptions yet!
46 PortableInterceptor::ORBInitializer_var orb_initializer
=
49 PortableInterceptor::register_orb_initializer (orb_initializer
.in ());
50 #endif /* TAO_HAS_INTERCEPTORS == 1 */
53 CORBA::ORB_init (argc
, argv
, "Server ORB");
55 CORBA::Object_var poa_object
=
56 orb
->resolve_initial_references ("RootPOA");
58 if (CORBA::is_nil (poa_object
.in ()))
59 ACE_ERROR_RETURN ((LM_ERROR
,
60 " (%P|%t) Unable to initialize the POA.\n"),
63 PortableServer::POA_var root_poa
=
64 PortableServer::POA::_narrow (poa_object
.in ());
66 PortableServer::POAManager_var poa_manager
=
67 root_poa
->the_POAManager ();
69 poa_manager
->activate ();
71 if (::parse_args (argc
, argv
) != 0)
74 test_i
servant (orb
.in ());
76 PortableServer::ObjectId_var id
=
77 root_poa
->activate_object (&servant
);
79 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
81 CORBA::Object_var obj
=
82 CORBA::Object::_narrow (object
.in ());
84 CORBA::String_var ior
=
85 orb
->object_to_string (obj
.in ());
88 "test servant: <%C>\n",
91 // Write IOR to a file.
92 FILE *output_file
= ACE_OS::fopen (ior_file
, "w");
94 ACE_ERROR_RETURN ((LM_ERROR
,
95 "Cannot open output file <%s> for writing "
100 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
101 ACE_OS::fclose (output_file
);
103 // Run the ORB event loop.
106 root_poa
->destroy (1, 1);
110 #if TAO_HAS_INTERCEPTORS == 1
111 ACE_TEST_ASSERT (destroy_called
== true);
114 ACE_DEBUG ((LM_DEBUG
, "Event loop finished.\n"));
116 catch (const CORBA::Exception
& ex
)
118 ex
._tao_print_exception ("Caught exception:");