1 #include "Supports_Test_impl.h"
2 #include "tao/Strategies/advanced_resource.h"
3 #include "ace/Get_Opt.h"
5 const ACE_TCHAR
*ior_output_file
= ACE_TEXT ("test.ior");
8 parse_args (int argc
, ACE_TCHAR
*argv
[])
10 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
13 while ((c
= get_opts ()) != -1)
17 ior_output_file
= get_opts
.opt_arg ();
22 ACE_ERROR_RETURN ((LM_ERROR
,
29 // Indicates successful parsing of the command line
34 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
38 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
40 if (parse_args (argc
, argv
) != 0)
43 CORBA::Object_var poa_object
= orb
->resolve_initial_references ("RootPOA");
45 PortableServer::POA_var root_poa
= PortableServer::POA::_narrow (poa_object
.in ());
47 if (CORBA::is_nil (root_poa
.in ()))
48 ACE_ERROR_RETURN ((LM_ERROR
,
49 " (%P|%t) Nil RootPOA\n"),
52 PortableServer::POAManager_var poa_manager
= root_poa
->the_POAManager ();
54 /* Create, register factories */
56 Supports_Test::Node_init
* node_factory
= 0;
58 ACE_NEW_RETURN (node_factory
, node_init_impl
, 1);
60 CORBA::ValueFactory returned_factory
= orb
->register_value_factory (
61 node_factory
->tao_repository_id (),
64 ACE_ASSERT (returned_factory
== 0);
66 node_factory
->_remove_ref ();
68 Supports_Test::vt_graph_init
* vt_graph_factory
= 0;
70 ACE_NEW_RETURN (vt_graph_factory
, vt_graph_init_impl
, 1);
72 returned_factory
= orb
->register_value_factory (
73 vt_graph_factory
->tao_repository_id (),
76 ACE_ASSERT (returned_factory
== 0);
78 vt_graph_factory
->_remove_ref ();
80 /* create and activate test servant */
82 test_impl
* a_test_impl
;
84 ACE_NEW_RETURN (a_test_impl
, test_impl (orb
.in ()), 1);
86 PortableServer::ServantBase_var owner_transfer
= a_test_impl
;
88 PortableServer::ObjectId_var id
=
89 root_poa
->activate_object (a_test_impl
);
91 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
93 Supports_Test::test_var a_test
= Supports_Test::test::_narrow (object
.in ());
95 CORBA::String_var ior
= orb
->object_to_string (a_test
.in ());
97 FILE * output_file
= ACE_OS::fopen (ACE_TEXT_ALWAYS_CHAR(ior_output_file
), "w");
100 ACE_ERROR_RETURN ((LM_ERROR
, "Cannot open output file for writing IOR: %s", ior_output_file
), 1);
102 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
104 ACE_OS::fclose (output_file
);
106 poa_manager
->activate ();
110 root_poa
->destroy (0, 0);
114 ACE_DEBUG ((LM_DEBUG
, "Server (%P.%t) completed test successfully\n"));
116 catch (const CORBA::Exception
& ex
)
118 ex
._tao_print_exception ("Exception caught:");