3 #include "tao/Messaging/Messaging.h"
4 #include "tao/Strategies/advanced_resource.h"
5 #include "tao/AnyTypeCode/Any.h"
6 #include "ace/Get_Opt.h"
7 #include "ace/Sched_Params.h"
8 #include "ace/OS_NS_errno.h"
10 const ACE_TCHAR
*ior_file_name
= ACE_TEXT("test.ior");
12 /// Parse the arguments.
13 static int parse_args (int argc
, ACE_TCHAR
*argv
[]);
16 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
19 (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO
)
20 + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO
)) / 2;
21 priority
= ACE_Sched_Params::next_priority (ACE_SCHED_FIFO
, priority
);
22 // Enable FIFO scheduling
23 if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO
,
25 ACE_SCOPE_PROCESS
)) != 0)
27 if (ACE_OS::last_error () == EPERM
)
30 "server (%P|%t): user is not superuser, "
31 "test runs in time-shared class\n"));
35 "server (%P|%t): sched_params failed\n"));
41 CORBA::ORB_init (argc
, argv
);
43 CORBA::Object_var manager_object
=
44 orb
->resolve_initial_references ("ORBPolicyManager");
46 CORBA::PolicyManager_var policy_manager
=
47 CORBA::PolicyManager::_narrow (manager_object
.in ());
49 CORBA::Any sync_scope
;
50 sync_scope
<<= Messaging::SYNC_WITH_TARGET
;
52 CORBA::PolicyList
policy_list (1);
53 policy_list
.length (1);
55 orb
->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE
,
57 policy_manager
->set_policy_overrides (policy_list
,
60 CORBA::Object_var poa_object
=
61 orb
->resolve_initial_references("RootPOA");
63 if (CORBA::is_nil (poa_object
.in ()))
64 ACE_ERROR_RETURN ((LM_ERROR
,
65 " (%P|%t) Unable to initialize the POA.\n"),
68 PortableServer::POA_var root_poa
=
69 PortableServer::POA::_narrow (poa_object
.in ());
71 PortableServer::POAManager_var poa_manager
=
72 root_poa
->the_POAManager ();
74 poa_manager
->activate ();
76 if (parse_args (argc
, argv
) != 0)
81 Test::Server_var server
= server_i
._this ();
83 CORBA::String_var str
=
84 orb
->object_to_string (server
.in ());
86 if (ior_file_name
!= 0)
88 FILE *output_file
= ACE_OS::fopen (ior_file_name
, "w");
90 ACE_ERROR_RETURN ((LM_ERROR
,
91 "Cannot open output file for writing IOR: %s",
94 ACE_OS::fprintf (output_file
, "%s", str
.in ());
95 ACE_OS::fclose (output_file
);
98 while (!server_i
.done ())
100 ACE_Time_Value
tv (1, 0);
104 PortableServer::ObjectId_var id
=
105 root_poa
->servant_to_id (&server_i
);
106 root_poa
->deactivate_object (id
.in ());
110 catch (const CORBA::Exception
& ex
)
112 ex
._tao_print_exception (argv
[0]);
117 // ****************************************************************
120 parse_args (int argc
, ACE_TCHAR
*argv
[])
122 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
125 while ((c
= get_opts ()) != -1)
129 ior_file_name
= get_opts
.opt_arg ();
134 ACE_ERROR_RETURN ((LM_ERROR
,
141 // Indicates successful parsing of the command line