1 #include "tao/params.h"
2 #include "tao/orbconf.h"
3 #include "tao/Version.h"
5 #if !defined (__ACE_INLINE__)
6 # include "tao/params.inl"
7 #endif /* __ACE_INLINE__ */
9 #include "ace/OS_NS_Thread.h"
10 #include "ace/Service_Config.h"
11 #include "tao/Invocation_Utils.h"
13 #if !defined (TAO_ALLOW_ZIOP_NO_SERVER_POLICIES_DEFAULT)
14 # define TAO_ALLOW_ZIOP_NO_SERVER_POLICIES_DEFAULT false
15 #endif /* !TAO_ALLOW_ZIOP_NO_SERVER_POLICIES_DEFAULT */
17 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
19 TAO_ORB_Parameters::TAO_ORB_Parameters ()
21 , mcast_discovery_endpoint_ ()
22 , default_init_ref_ (TAO_DEFAULT_INIT_REFERENCE_INITIALIZER
)
23 , sock_rcvbuf_size_ (ACE_DEFAULT_MAX_SOCKET_BUFSIZ
)
24 , sock_sndbuf_size_ (ACE_DEFAULT_MAX_SOCKET_BUFSIZ
)
29 , ip_multicastloop_ (true)
30 , iiop_client_port_base_ (0)
31 , iiop_client_port_span_ (0)
32 , cdr_memcpy_tradeoff_ (ACE_DEFAULT_CDR_MEMCPY_TRADEOFF
)
33 , max_message_size_ (0) // Disable outgoing GIOP fragments by default
34 , use_dotted_decimal_addresses_ (0)
35 , cache_incoming_by_dotted_decimal_address_ (0)
37 , accept_error_delay_ (0)
38 , std_profile_components_ (1)
39 , ace_sched_policy_ (ACE_SCHED_OTHER
)
40 , sched_policy_ (THR_SCHED_DEFAULT
)
41 , scope_policy_ (THR_SCOPE_PROCESS
)
42 , single_read_optimization_ (1)
44 , use_parallel_connects_ (false)
45 , parallel_connect_delay_ (0)
47 , disable_rt_collocation_resolver_ (false)
48 , enforce_preferred_interfaces_ (false)
49 #if defined (ACE_HAS_IPV6)
50 , prefer_ipv6_interfaces_ (false)
51 , connect_ipv6_only_ (false)
52 , use_ipv6_link_local_ (false)
53 #endif /* ACE_HAS_IPV6 */
54 , negotiate_codesets_ (true)
55 , ami_collication_ (true)
56 , protocols_hooks_name_ ("Protocols_Hooks")
57 , stub_factory_name_ ("Default_Stub_Factory")
58 , endpoint_selector_factory_name_ ("Default_Endpoint_Selector_Factory")
59 , thread_lane_resources_manager_factory_name_ ("Default_Thread_Lane_Resources_Manager_Factory")
60 , dynamic_thread_pool_config_name_ ()
61 , poa_factory_name_ ("TAO_Object_Adapter_Factory")
62 , poa_factory_directive_
63 (ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE("TAO_Object_Adapter_Factory",
66 "_make_TAO_Object_Adapter_Factory",
68 , forward_invocation_on_object_not_exist_ (false)
69 , forward_once_exception_ (0)
70 , collocation_resolver_name_ ("Default_Collocation_Resolver")
71 , allow_ziop_no_server_policies_ (!!TAO_ALLOW_ZIOP_NO_SERVER_POLICIES_DEFAULT
)
73 for (int i
= 0; i
!= TAO_NO_OF_MCAST_SERVICES
; ++i
)
75 this->service_port_
[i
] = 0;
80 TAO_ORB_Parameters::get_endpoint_set (const ACE_CString
&lane
,
81 TAO_EndpointSet
&endpoint_set
)
83 // Look for the lane in the endpoints map.
84 endpoints_map_type::iterator
const endpoints
=
85 this->endpoints_map_
.find (lane
);
87 // If lane is not in the map, endpoint_set remains empty
88 if (endpoints
== this->endpoints_map_
.end ())
91 // At this point, the parsing should not fail since they have been
92 // parsed successfully before.
94 this->parse_and_add_endpoints ((*endpoints
).second
, endpoint_set
);
96 ACE_ASSERT (result
== 0);
97 ACE_UNUSED_ARG (result
);
101 TAO_ORB_Parameters::add_endpoints (const ACE_CString
&lane
,
102 const ACE_CString
&additional_endpoints
)
104 TAO_EndpointSet endpoint_set
;
106 // Parse the additional endpoints.
108 this->parse_and_add_endpoints (additional_endpoints
, endpoint_set
);
114 // Look for the lane in the endpoints map.
116 // Return reference to endpoints string corresponding to lane
117 // string. If none, a default constructed string is inserted into
118 // the map and returned.
119 ACE_CString
& existing_endpoints
= this->endpoints_map_
[lane
];
121 // Create the resulting endpoints string.
122 if (existing_endpoints
.length () != 0)
124 existing_endpoints
+= ";";
127 existing_endpoints
+= additional_endpoints
;
133 TAO_ORB_Parameters::parse_and_add_endpoints (const ACE_CString
&endpoints
,
134 TAO_EndpointSet
&endpoint_set
)
136 // Parse the string into separate endpoints, where `endpoints' is of
139 // protocol1://V,v@addr1,...,addrN;protocol2://addr1,...,W.w@addrN;...
141 // A single endpoint, instead of several, can be added just as well.
143 static char const endpoints_delimiter
= ';';
145 size_t const length
= endpoints
.length ();
147 if (endpoints
[0] == endpoints_delimiter
||
148 endpoints
[length
- 1] == endpoints_delimiter
)
151 // Failure: endpoints string has an empty endpoint at the
152 // beginning or the end of the string
153 // (e.g. ";uiop://foo;iiop://1.3@bar")
157 // Return code: 0 = success, -1 = failure
161 int endpoints_count
= 1;
163 for (size_t j
= 0; j
!= length
; ++j
)
165 if (endpoints
[j
] == endpoints_delimiter
)
172 ssize_t end
= endpoints
.find (endpoints_delimiter
);
174 for (int i
= 0; i
< endpoints_count
; ++i
)
178 // Handle case where two consecutive endpoints `;;'
179 // delimiters are found within the endpoints set.
181 // Is it enough to just skip over it or should we return an
186 ACE_CString
const endpt
=
187 endpoints
.substring (begin
, end
- begin
);
188 // The substring call will work even if `end' is equal to
189 // ACE_CString::npos since that will just extract the substring
190 // from the offset `begin' to the end of the string.
192 // Check for a valid URL style endpoint set
193 ACE_CString::size_type
const check_offset
= endpt
.find ("://");
195 if (check_offset
> 0 &&
196 check_offset
!= endpt
.npos
)
198 endpoint_set
.enqueue_tail (endpt
);
199 // Insert endpoint into list
203 status
= -1; // Error: invalid URL style endpoint set
207 end
= endpoints
.find (endpoints_delimiter
, begin
);
213 // Failure: Empty string
220 TAO_ORB_Parameters::check_preferred_interfaces_string (const char *s
)
222 // Validates that s contains one or more comma separated
223 // interfaces each consisting of a string with a single
224 // assignment separator ('=' or ':')
225 // Any other char is legal, although '*' and '?' will be
226 // treated as wildcards.
227 bool expect_assign
= false;
228 bool expect_comma
= false;
229 bool expect_wild
= true;
230 bool found_remote
= false;
232 for (const char *p
= s
; *p
; ++p
) switch (*p
)
234 #if !defined (ACE_HAS_IPV6)
235 // Can't use this as assignment operator when IPv6 decimal
236 // addresses may be involved.
238 #endif /* ACE_HAS_IPV6 */
243 expect_assign
= false;
244 expect_comma
= false;
251 found_remote
= false;
252 expect_assign
= false;
253 expect_comma
= false;
261 expect_assign
= !found_remote
;
262 expect_comma
= found_remote
;
267 expect_assign
= !found_remote
;
268 expect_comma
= found_remote
;
273 return expect_comma
&& !expect_assign
;
277 TAO_ORB_Parameters::preferred_interfaces (const char *s
)
279 const bool valid
= check_preferred_interfaces_string (s
);
282 // Append any valid string to those already specified
283 // (by other -ORBPreferredInterfaces options that have been
285 if (this->pref_network_
.length ())
286 this->pref_network_
+= ',';
287 this->pref_network_
+= s
;
294 TAO_ORB_Parameters::preferred_interfaces () const
296 return this->pref_network_
.c_str ();
300 TAO_ORB_Parameters::enforce_pref_interfaces (bool p
)
302 this->enforce_preferred_interfaces_
= p
;
306 TAO_ORB_Parameters::enforce_pref_interfaces () const
308 return this->enforce_preferred_interfaces_
;
311 #if defined (ACE_HAS_IPV6)
313 TAO_ORB_Parameters::prefer_ipv6_interfaces (bool p
)
315 this->prefer_ipv6_interfaces_
= p
;
319 TAO_ORB_Parameters::prefer_ipv6_interfaces () const
321 return this->prefer_ipv6_interfaces_
;
325 TAO_ORB_Parameters::connect_ipv6_only (bool p
)
327 this->connect_ipv6_only_
= p
;
331 TAO_ORB_Parameters::connect_ipv6_only () const
333 return this->connect_ipv6_only_
;
337 TAO_ORB_Parameters::use_ipv6_link_local (bool p
)
339 this->use_ipv6_link_local_
= p
;
343 TAO_ORB_Parameters::use_ipv6_link_local () const
345 return this->use_ipv6_link_local_
;
347 #endif /* ACE_HAS_IPV6 */
350 TAO_ORB_Parameters::protocols_hooks_name (const char *s
)
352 this->protocols_hooks_name_
= s
;
356 TAO_ORB_Parameters::protocols_hooks_name () const
358 return this->protocols_hooks_name_
.c_str ();
362 TAO_ORB_Parameters::thread_lane_resources_manager_factory_name (const char *s
)
364 this->thread_lane_resources_manager_factory_name_
= s
;
368 TAO_ORB_Parameters::thread_lane_resources_manager_factory_name () const
370 return this->thread_lane_resources_manager_factory_name_
.c_str ();
374 TAO_ORB_Parameters::dynamic_thread_pool_config_name (const char *s
)
376 this->dynamic_thread_pool_config_name_
= s
;
380 TAO_ORB_Parameters::dynamic_thread_pool_config_name () const
382 return this->dynamic_thread_pool_config_name_
.c_str ();
386 TAO_ORB_Parameters::stub_factory_name (const char *s
)
388 this->stub_factory_name_
= s
;
392 TAO_ORB_Parameters::stub_factory_name () const
394 return this->stub_factory_name_
.c_str ();
398 TAO_ORB_Parameters::poa_factory_name (const char *s
)
400 this->poa_factory_name_
= s
;
404 TAO_ORB_Parameters::poa_factory_name () const
406 return this->poa_factory_name_
.c_str ();
410 TAO_ORB_Parameters::poa_factory_directive (const ACE_TCHAR
*s
)
412 this->poa_factory_directive_
= s
;
416 TAO_ORB_Parameters::poa_factory_directive () const
418 return this->poa_factory_directive_
.c_str ();
422 TAO_ORB_Parameters::endpoint_selector_factory_name (const char *s
)
424 this->endpoint_selector_factory_name_
= s
;
428 TAO_ORB_Parameters::endpoint_selector_factory_name () const
430 return this->endpoint_selector_factory_name_
.c_str ();
433 const TAO::Invocation_Retry_Params
&
434 TAO_ORB_Parameters::invocation_retry_params () const
436 return this->invocation_retry_params_
;
439 TAO::Invocation_Retry_Params
&
440 TAO_ORB_Parameters::invocation_retry_params ()
442 return this->invocation_retry_params_
;
446 TAO_ORB_Parameters::forward_on_exception_limit (const int ef
, const int limit
)
448 this->invocation_retry_params_
.forward_on_exception_limit_
[ef
] = limit
;
452 TAO_ORB_Parameters::forward_on_exception_delay (const ACE_Time_Value
&delay
)
454 this->invocation_retry_params_
.init_retry_delay_
= delay
;
457 TAO_END_VERSIONED_NAMESPACE_DECL