00001
00002
00003 #include "tao/params.h"
00004 #include "tao/orbconf.h"
00005
00006 #if !defined (__ACE_INLINE__)
00007 # include "tao/params.inl"
00008 #endif
00009
00010 #include "ace/OS_NS_Thread.h"
00011 #include "ace/Service_Config.h"
00012 #include "tao/Invocation_Utils.h"
00013
00014 ACE_RCSID (tao,
00015 params,
00016 "$Id: params.cpp 86232 2009-07-24 21:52:20Z dai_y $")
00017
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019
00020 TAO_ORB_Parameters::TAO_ORB_Parameters (void)
00021 : endpoints_map_ (10)
00022 , mcast_discovery_endpoint_ ()
00023 , default_init_ref_ (TAO_DEFAULT_INIT_REFERENCE_INITIALIZER)
00024 , sock_rcvbuf_size_ (ACE_DEFAULT_MAX_SOCKET_BUFSIZ)
00025 , sock_sndbuf_size_ (ACE_DEFAULT_MAX_SOCKET_BUFSIZ)
00026 , nodelay_ (1)
00027 , sock_keepalive_ (0)
00028 , sock_dontroute_ (0)
00029 , ip_hoplimit_ (-1)
00030 , ip_multicastloop_ (true)
00031 , cdr_memcpy_tradeoff_ (ACE_DEFAULT_CDR_MEMCPY_TRADEOFF)
00032 , max_message_size_ (0)
00033 , use_dotted_decimal_addresses_ (0)
00034 , cache_incoming_by_dotted_decimal_address_ (0)
00035 , linger_ (-1)
00036 , accept_error_delay_ (0)
00037 , std_profile_components_ (1)
00038 , ace_sched_policy_ (ACE_SCHED_OTHER)
00039 , sched_policy_ (THR_SCHED_DEFAULT)
00040 , scope_policy_ (THR_SCOPE_PROCESS)
00041 , single_read_optimization_ (1)
00042 , shared_profile_ (0)
00043 , use_parallel_connects_ (false)
00044 , parallel_connect_delay_ (0)
00045 , pref_network_ ()
00046 , disable_rt_collocation_resolver_ (false)
00047 , enforce_preferred_interfaces_ (false)
00048 #if defined (ACE_HAS_IPV6)
00049 , prefer_ipv6_interfaces_ (false)
00050 , connect_ipv6_only_ (false)
00051 , use_ipv6_link_local_ (false)
00052 #endif
00053 , negotiate_codesets_ (true)
00054 , ami_collication_ (true)
00055 , protocols_hooks_name_ ("Protocols_Hooks")
00056 , stub_factory_name_ ("Default_Stub_Factory")
00057 , endpoint_selector_factory_name_ ("Default_Endpoint_Selector_Factory")
00058 , thread_lane_resources_manager_factory_name_ ("Default_Thread_Lane_Resources_Manager_Factory")
00059 , poa_factory_name_ ("TAO_Object_Adapter_Factory")
00060 , poa_factory_directive_
00061 (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Object_Adapter_Factory",
00062 "TAO_PortableServer",
00063 "_make_TAO_Object_Adapter_Factory",
00064 ""))
00065 , forward_invocation_on_object_not_exist_ (false)
00066 , forward_once_exception_ (TAO::FOE_NON)
00067 , collocation_resolver_name_ ("Default_Collocation_Resolver")
00068 {
00069 for (int i = 0; i != TAO_NO_OF_MCAST_SERVICES; ++i)
00070 {
00071 this->service_port_[i] = 0;
00072 }
00073 }
00074
00075 void
00076 TAO_ORB_Parameters::get_endpoint_set (const ACE_CString &lane,
00077 TAO_EndpointSet &endpoint_set)
00078 {
00079
00080 endpoints_map_type::iterator const endpoints =
00081 this->endpoints_map_.find (lane);
00082
00083
00084 if (endpoints == this->endpoints_map_.end ())
00085 return;
00086
00087
00088
00089 int const result =
00090 this->parse_and_add_endpoints ((*endpoints).second, endpoint_set);
00091
00092 ACE_ASSERT (result == 0);
00093 ACE_UNUSED_ARG (result);
00094 }
00095
00096 int
00097 TAO_ORB_Parameters::add_endpoints (const ACE_CString &lane,
00098 const ACE_CString &additional_endpoints)
00099 {
00100 TAO_EndpointSet endpoint_set;
00101
00102
00103 int const result =
00104 this->parse_and_add_endpoints (additional_endpoints, endpoint_set);
00105
00106
00107 if (result != 0)
00108 return result;
00109
00110
00111
00112
00113
00114
00115 ACE_CString & existing_endpoints = this->endpoints_map_[lane];
00116
00117
00118 if (existing_endpoints.length () != 0)
00119 {
00120 existing_endpoints += ";";
00121 }
00122
00123 existing_endpoints += additional_endpoints;
00124
00125 return 0;
00126 }
00127
00128 int
00129 TAO_ORB_Parameters::parse_and_add_endpoints (const ACE_CString &endpoints,
00130 TAO_EndpointSet &endpoint_set)
00131 {
00132
00133
00134
00135
00136
00137
00138
00139 static char const endpoints_delimiter = ';';
00140
00141 size_t const length = endpoints.length ();
00142
00143 if (endpoints[0] == endpoints_delimiter ||
00144 endpoints[length - 1] == endpoints_delimiter)
00145 {
00146 return -1;
00147
00148
00149
00150 }
00151
00152 int status = 0;
00153
00154
00155 if (length > 0)
00156 {
00157 int endpoints_count = 1;
00158
00159 for (size_t j = 0; j != length; ++j)
00160 {
00161 if (endpoints[j] == endpoints_delimiter)
00162 {
00163 ++endpoints_count;
00164 }
00165 }
00166
00167 ssize_t begin = 0;
00168 ssize_t end = endpoints.find (endpoints_delimiter);
00169
00170 for (int i = 0; i < endpoints_count; ++i)
00171 {
00172 if (end == 0)
00173 {
00174
00175
00176
00177
00178
00179 continue;
00180 }
00181
00182 ACE_CString const endpt =
00183 endpoints.substring (begin, end - begin);
00184
00185
00186
00187
00188
00189 ACE_CString::size_type const check_offset = endpt.find ("://");
00190
00191 if (check_offset > 0 &&
00192 check_offset != endpt.npos)
00193 {
00194 endpoint_set.enqueue_tail (endpt);
00195
00196 }
00197 else
00198 {
00199 status = -1;
00200 }
00201
00202 begin = end + 1;
00203 end = endpoints.find (endpoints_delimiter, begin);
00204 }
00205 }
00206 else
00207 {
00208 status = -1;
00209
00210 }
00211
00212 return status;
00213 }
00214
00215 bool
00216 TAO_ORB_Parameters::preferred_interfaces (const char *s)
00217 {
00218
00219
00220
00221
00222
00223 const char* p = s;
00224 bool expect_assign = false;
00225 bool expect_comma = false;
00226 bool expect_char = true;
00227 bool expect_wild = true;
00228 bool found_remote = false;
00229 while (*p != 0)
00230 {
00231 switch (*p)
00232 {
00233 #if !defined (ACE_HAS_IPV6)
00234
00235
00236 case ':':
00237 #endif
00238 case '=':
00239 if (! expect_assign)
00240 return false;
00241 found_remote = true;
00242 expect_assign = false;
00243 expect_char = true;
00244 expect_comma = false;
00245 expect_wild = true;
00246 break;
00247 case ',':
00248 if (! expect_comma)
00249 return false;
00250 found_remote = false;
00251 expect_assign = false;
00252 expect_char = true;
00253 expect_comma = false;
00254 expect_wild = true;
00255 break;
00256 case '*':
00257 case '?':
00258 if (! expect_wild)
00259 return false;
00260 expect_assign = ! found_remote;
00261 expect_char = true;
00262 expect_comma = found_remote;
00263 expect_wild = false;
00264 break;
00265 default:
00266 if (! expect_char)
00267 return false;
00268 expect_assign = ! found_remote;
00269 expect_char = true;
00270 expect_comma = found_remote;
00271 expect_wild = true;
00272 break;
00273 }
00274 ++p;
00275 }
00276 if (!expect_comma || expect_assign)
00277 return false;
00278
00279 this->pref_network_ = s;
00280
00281 return true;
00282 }
00283
00284 const char *
00285 TAO_ORB_Parameters::preferred_interfaces (void) const
00286 {
00287 return this->pref_network_.c_str ();
00288 }
00289
00290 void
00291 TAO_ORB_Parameters::enforce_pref_interfaces (bool p)
00292 {
00293 this->enforce_preferred_interfaces_ = p;
00294 }
00295
00296 bool
00297 TAO_ORB_Parameters::enforce_pref_interfaces (void) const
00298 {
00299 return this->enforce_preferred_interfaces_;
00300 }
00301
00302 #if defined (ACE_HAS_IPV6)
00303 void
00304 TAO_ORB_Parameters::prefer_ipv6_interfaces (bool p)
00305 {
00306 this->prefer_ipv6_interfaces_ = p;
00307 }
00308
00309 bool
00310 TAO_ORB_Parameters::prefer_ipv6_interfaces (void) const
00311 {
00312 return this->prefer_ipv6_interfaces_;
00313 }
00314
00315 void
00316 TAO_ORB_Parameters::connect_ipv6_only (bool p)
00317 {
00318 this->connect_ipv6_only_ = p;
00319 }
00320
00321 bool
00322 TAO_ORB_Parameters::connect_ipv6_only (void) const
00323 {
00324 return this->connect_ipv6_only_;
00325 }
00326
00327 void
00328 TAO_ORB_Parameters::use_ipv6_link_local (bool p)
00329 {
00330 this->use_ipv6_link_local_ = p;
00331 }
00332
00333 bool
00334 TAO_ORB_Parameters::use_ipv6_link_local (void) const
00335 {
00336 return this->use_ipv6_link_local_;
00337 }
00338 #endif
00339
00340 void
00341 TAO_ORB_Parameters::protocols_hooks_name (const char *s)
00342 {
00343 this->protocols_hooks_name_ = s;
00344 }
00345
00346 const char *
00347 TAO_ORB_Parameters::protocols_hooks_name (void) const
00348 {
00349 return this->protocols_hooks_name_.c_str ();
00350 }
00351
00352 void
00353 TAO_ORB_Parameters::thread_lane_resources_manager_factory_name (const char *s)
00354 {
00355 this->thread_lane_resources_manager_factory_name_ = s;
00356 }
00357
00358 const char *
00359 TAO_ORB_Parameters::thread_lane_resources_manager_factory_name (void) const
00360 {
00361 return this->thread_lane_resources_manager_factory_name_.c_str ();
00362 }
00363
00364 void
00365 TAO_ORB_Parameters::stub_factory_name (const char *s)
00366 {
00367 this->stub_factory_name_ = s;
00368 }
00369
00370 const char *
00371 TAO_ORB_Parameters::stub_factory_name (void) const
00372 {
00373 return this->stub_factory_name_.c_str ();
00374 }
00375
00376 void
00377 TAO_ORB_Parameters::poa_factory_name (const char *s)
00378 {
00379 this->poa_factory_name_ = s;
00380 }
00381
00382 const char *
00383 TAO_ORB_Parameters::poa_factory_name (void) const
00384 {
00385 return this->poa_factory_name_.c_str ();
00386 }
00387
00388 void
00389 TAO_ORB_Parameters::poa_factory_directive (const ACE_TCHAR *s)
00390 {
00391 this->poa_factory_directive_ = s;
00392 }
00393
00394 const ACE_TCHAR *
00395 TAO_ORB_Parameters::poa_factory_directive (void) const
00396 {
00397 return this->poa_factory_directive_.c_str ();
00398 }
00399
00400 void
00401 TAO_ORB_Parameters::endpoint_selector_factory_name (const char *s)
00402 {
00403 this->endpoint_selector_factory_name_ = s;
00404 }
00405
00406 const char *
00407 TAO_ORB_Parameters::endpoint_selector_factory_name (void) const
00408 {
00409 return this->endpoint_selector_factory_name_.c_str ();
00410 }
00411
00412 TAO_END_VERSIONED_NAMESPACE_DECL