1 #include "Oneway_Buffering.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
5 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("server.ior");
6 const ACE_TCHAR
*ior
= ACE_TEXT("file://admin.ior");
9 parse_args (int argc
, ACE_TCHAR
*argv
[])
11 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:k:"));
14 while ((c
= get_opts ()) != -1)
18 ior_output_file
= get_opts
.opt_arg ();
22 ior
= get_opts
.opt_arg ();
27 ACE_ERROR_RETURN ((LM_ERROR
,
35 // Indicates successful parsing of the command line
40 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
45 CORBA::ORB_init (argc
, argv
);
47 CORBA::Object_var poa_object
=
48 orb
->resolve_initial_references("RootPOA");
50 PortableServer::POA_var root_poa
=
51 PortableServer::POA::_narrow (poa_object
.in ());
53 if (CORBA::is_nil (root_poa
.in ()))
54 ACE_ERROR_RETURN ((LM_ERROR
,
55 " (%P|%t) Panic: nil RootPOA\n"),
58 PortableServer::POAManager_var poa_manager
=
59 root_poa
->the_POAManager ();
61 if (parse_args (argc
, argv
) != 0)
64 CORBA::Object_var tmp
=
65 orb
->string_to_object(ior
);
67 Test::Oneway_Buffering_Admin_var admin
=
68 Test::Oneway_Buffering_Admin::_narrow(tmp
.in ());
70 if (CORBA::is_nil (admin
.in ()))
72 ACE_ERROR_RETURN ((LM_DEBUG
,
73 "Nil Oneway_Buffering_Admin reference <%s>\n",
78 Oneway_Buffering
*oneway_buffering_impl
;
79 ACE_NEW_RETURN (oneway_buffering_impl
,
80 Oneway_Buffering (orb
.in (),
83 PortableServer::ServantBase_var
owner_transfer(oneway_buffering_impl
);
85 PortableServer::ObjectId_var id
=
86 root_poa
->activate_object (oneway_buffering_impl
);
88 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
90 Test::Oneway_Buffering_var oneway_buffering
=
91 Test::Oneway_Buffering::_narrow (object
.in ());
93 CORBA::String_var ior
=
94 orb
->object_to_string (oneway_buffering
.in ());
96 // If the ior_output_file exists, output the ior to it
97 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
99 ACE_ERROR_RETURN ((LM_ERROR
,
100 "Cannot open output file for writing IOR: %s",
103 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
104 ACE_OS::fclose (output_file
);
106 poa_manager
->activate ();
110 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
112 root_poa
->destroy (true, true);
116 catch (const CORBA::Exception
& ex
)
118 ex
._tao_print_exception ("Exception caught in server:");