1 #include "ace/Get_Opt.h"
2 #include "Big_Reply_i.h"
3 #include "ace/OS_NS_stdio.h"
7 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("test.ior");
9 // We can change this value if wanted..
10 const CORBA::ULong data_size
= 4000000;
12 class OrbTask
: public ACE_Task_Base
15 OrbTask(const CORBA::ORB_ptr orb
)
16 : orb_(CORBA::ORB::_duplicate(orb
))
26 catch (const CORBA::Exception
&)
36 static int n_threads
= 1;
39 parse_args (int argc
, ACE_TCHAR
*argv
[])
41 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:s:t:"));
44 while ((c
= get_opts ()) != -1)
48 ior_output_file
= get_opts
.opt_arg ();
51 n_threads
= ACE_OS::atoi(get_opts
.opt_arg());
55 ACE_ERROR_RETURN ((LM_ERROR
,
63 // Indicates successful parsing of the command line
68 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
70 ACE_DEBUG ((LM_DEBUG
, "Starting server\n"));
75 CORBA::ORB_init (argc
, argv
);
77 CORBA::Object_var poa_object
=
78 orb
->resolve_initial_references ("RootPOA");
80 if (CORBA::is_nil (poa_object
.in ()))
81 ACE_ERROR_RETURN ((LM_ERROR
,
82 " (%P|%t) Unable to initialize the POA.\n"),
85 PortableServer::POA_var root_poa
=
86 PortableServer::POA::_narrow (poa_object
.in ());
88 PortableServer::POAManager_var poa_manager
=
89 root_poa
->the_POAManager ();
92 if (parse_args (argc
, argv
) != 0)
95 Big_Reply_i
*big_reply_gen
= 0;
97 ACE_NEW_RETURN (big_reply_gen
,
98 Big_Reply_i (orb
.in (),
103 PortableServer::ServantBase_var
big_reply_owner_transfer(big_reply_gen
);
105 PortableServer::ObjectId_var id
=
106 root_poa
->activate_object (big_reply_gen
);
108 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
110 Test::Big_Reply_var big_reply
=
111 Test::Big_Reply::_narrow (object
.in ());
113 CORBA::String_var ior
=
114 orb
->object_to_string (big_reply
.in ());
116 // If the ior_output_file exists, output the ior to it
117 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
118 if (output_file
== 0)
119 ACE_ERROR_RETURN ((LM_ERROR
,
120 "Cannot open output file for writing IOR: %s\n",
123 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
124 ACE_OS::fclose (output_file
);
126 poa_manager
->activate ();
128 OrbTask
task(orb
.in());
130 if (task
.activate (THR_NEW_LWP
| THR_JOINABLE
,
132 ACE_ERROR_RETURN ((LM_ERROR
,
133 "Cannot activate threads\n"),
137 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
139 root_poa
->destroy (true, true);
141 catch (const CORBA::Exception
& ex
)
143 ex
._tao_print_exception ("Caught exception:");
147 ACE_DEBUG ((LM_DEBUG
, "Ending server\n"));