2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
4 #include "tao/RTCORBA/RTCORBA.h"
5 #include "tao/RTPortableServer/RTPortableServer.h"
6 #include "tao/RTCORBA/Network_Priority_Mapping_Manager.h"
7 #include "tao/RTCORBA/Network_Priority_Mapping.h"
8 #include "Custom_Network_Priority_Mapping.h"
11 class Test_i
: public POA_Test
14 Test_i (CORBA::ORB_ptr orb
);
18 //FUZZ: disable check_for_lack_ACE_OS
20 //FUZZ: enable check_for_lack_ACE_OS
26 Test_i::Test_i (CORBA::ORB_ptr orb
)
27 : orb_ (CORBA::ORB::_duplicate (orb
))
32 Test_i::test_method ()
35 "Test_i::test_method\n"));
41 this->orb_
->shutdown (false);
44 static const ACE_TCHAR
*simple_servant_ior_file
= ACE_TEXT("simple_servant.ior");
45 static const ACE_TCHAR
*diffserv_servant_ior_file
= ACE_TEXT("diffserv_servant.ior");
46 static RTCORBA::Priority corba_priority
= RTCORBA::minPriority
;
49 parse_args (int argc
, ACE_TCHAR
*argv
[])
51 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("p:"));
54 while ((c
= get_opts ()) != -1)
58 corba_priority
= ACE_OS::atoi (get_opts
.opt_arg ());
62 ACE_ERROR_RETURN ((LM_ERROR
,
64 "\t-p <corba priority> [defaults to %d]\n"
75 create_object (PortableServer::POA_ptr poa
,
77 PortableServer::Servant servant
,
78 const ACE_TCHAR
*filename
)
81 PortableServer::ObjectId_var id
=
82 poa
->activate_object (servant
);
84 CORBA::Object_var object
=
85 poa
->id_to_reference (id
.in ());
87 CORBA::String_var ior
=
88 orb
->object_to_string (object
.in ());
90 FILE *output_file
= ACE_OS::fopen (filename
, "w");
91 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
92 ACE_OS::fclose (output_file
);
96 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
100 CORBA::Object_var object
;
104 CORBA::ORB_init (argc
, argv
);
107 if (parse_args (argc
, argv
) != 0)
112 orb
->resolve_initial_references ("RootPOA");
114 PortableServer::POA_var root_poa
=
115 PortableServer::POA::_narrow (object
.in ());
118 PortableServer::POAManager_var poa_manager
=
119 root_poa
->the_POAManager ();
122 Test_i
servant (orb
.in ());
124 // Create the first object in Root POA
125 create_object (root_poa
.in (),
128 simple_servant_ior_file
);
131 orb
->resolve_initial_references ("NetworkPriorityMappingManager");
133 RTCORBA::NetworkPriorityMappingManager_var mapping_manager
=
134 RTCORBA::NetworkPriorityMappingManager::_narrow (object
.in ());
136 Custom_Network_Priority_Mapping
*cnpm
= 0;
137 ACE_NEW_RETURN (cnpm
,
138 Custom_Network_Priority_Mapping
,
141 cnpm
->corba_priority (corba_priority
);
143 mapping_manager
->mapping (cnpm
);
147 orb
->resolve_initial_references ("RTORB");
149 RTCORBA::RTORB_var rt_orb
=
150 RTCORBA::RTORB::_narrow (object
.in ());
152 // Set transport protocol properties
153 RTCORBA::TCPProtocolProperties_var tcp_properties
=
154 rt_orb
->create_tcp_protocol_properties (ACE_DEFAULT_MAX_SOCKET_BUFSIZ
,
155 ACE_DEFAULT_MAX_SOCKET_BUFSIZ
,
161 RTCORBA::ProtocolList protocols
;
162 protocols
.length (1);
163 protocols
[0].protocol_type
= 0;
164 protocols
[0].transport_protocol_properties
=
165 RTCORBA::ProtocolProperties::_duplicate (tcp_properties
.in ());
166 protocols
[0].orb_protocol_properties
=
167 RTCORBA::ProtocolProperties::_nil ();
169 CORBA::PolicyList policy_list
;
170 policy_list
.length (1);
173 rt_orb
->create_server_protocol_policy (protocols
);
175 // Create POA with Diffserv enabled
176 PortableServer::POA_var poa_with_diffserv
=
177 root_poa
->create_POA ("POA_WITH_DS",
182 create_object (poa_with_diffserv
.in (),
185 diffserv_servant_ior_file
);
187 // Activate POA manager.
188 poa_manager
->activate ();
190 // Start ORB event loop.
193 ACE_DEBUG ((LM_DEBUG
, "Server ORB event loop finished\n\n"));
195 catch (const CORBA::Exception
& ex
)
197 ex
._tao_print_exception ("Unexpected exception caught:");