Updated logging to include the class/method so that it is more obvious where these...
[ACE_TAO.git] / TAO / tao / default_server.cpp
blob6e59dd8bb093791cb67afab1e809429bbda02fc4
1 #include "tao/default_server.h"
2 #include "tao/debug.h"
3 #include "ace/OS_NS_strings.h"
4 #include "ace/OS_NS_string.h"
6 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
8 TAO_Default_Server_Strategy_Factory::TAO_Default_Server_Strategy_Factory ()
9 : activate_server_connections_ (0),
10 thread_flags_ (THR_BOUND | THR_DETACHED),
11 thread_per_connection_use_timeout_ (-1)
15 TAO_Default_Server_Strategy_Factory::~TAO_Default_Server_Strategy_Factory ()
17 // Perform appropriate cleanup.
20 int
21 TAO_Default_Server_Strategy_Factory::activate_server_connections ()
23 return this->activate_server_connections_;
26 int
27 TAO_Default_Server_Strategy_Factory::thread_per_connection_timeout (ACE_Time_Value &timeout)
29 timeout = this->thread_per_connection_timeout_;
30 return this->thread_per_connection_use_timeout_;
33 int
34 TAO_Default_Server_Strategy_Factory::server_connection_thread_flags ()
36 return this->thread_flags_;
39 int
40 TAO_Default_Server_Strategy_Factory::server_connection_thread_count ()
42 return 1;
45 // Evil macros b/c I'm lazy!
46 #define TAO_BEGINCHECK if (0)
47 #define TAO_CHECKANDSET(sym) \
48 else if (ACE_OS::strcmp (const_cast <const ACE_TCHAR *> ( flag), ACE_TEXT(#sym)) == 0) \
49 ACE_SET_BITS (this->thread_flags_, sym)
50 #define TAO_ENDCHECK
52 void
53 TAO_Default_Server_Strategy_Factory::tokenize (ACE_TCHAR* flag_string)
55 ACE_TCHAR* lasts = nullptr;
57 for (ACE_TCHAR* flag = ACE_OS::strtok_r (flag_string,
58 ACE_TEXT("|"),
59 &lasts);
60 flag != nullptr;
61 flag = ACE_OS::strtok_r (nullptr,
62 ACE_TEXT("|"),
63 &lasts))
65 TAO_BEGINCHECK;
66 TAO_CHECKANDSET (THR_DETACHED);
67 TAO_CHECKANDSET (THR_BOUND);
68 TAO_CHECKANDSET (THR_NEW_LWP);
69 TAO_CHECKANDSET (THR_SUSPENDED);
70 #if !defined (ACE_WIN32)
71 TAO_CHECKANDSET (THR_DAEMON);
72 #endif /* ACE_WIN32 */
73 TAO_ENDCHECK;
77 int
78 TAO_Default_Server_Strategy_Factory::init (int argc, ACE_TCHAR* argv[])
80 return this->parse_args (argc, argv);
83 int
84 TAO_Default_Server_Strategy_Factory::open (TAO_ORB_Core *)
86 return 0;
89 int
90 TAO_Default_Server_Strategy_Factory::parse_args (int argc, ACE_TCHAR* argv[])
92 ACE_TRACE ("TAO_Default_Server_Strategy_Factory::parse_args");
94 int curarg;
96 for (curarg = 0; curarg < argc && argv[curarg]; ++curarg)
97 if (ACE_OS::strcasecmp (argv[curarg],
98 ACE_TEXT("-ORBConcurrency")) == 0)
100 ++curarg;
101 if (curarg < argc)
103 ACE_TCHAR* name = argv[curarg];
105 if (ACE_OS::strcasecmp (name,
106 ACE_TEXT("reactive")) == 0)
107 this->activate_server_connections_ = 0;
108 else if (ACE_OS::strcasecmp (name,
109 ACE_TEXT("thread-per-connection")) == 0)
110 this->activate_server_connections_ = 1;
111 else
112 this->report_option_value_error (ACE_TEXT("-ORBConcurrency"), name);
116 else if (ACE_OS::strcasecmp (argv[curarg],
117 ACE_TEXT("-ORBThreadPerConnectionTimeout")) == 0)
119 ++curarg;
120 if (curarg < argc)
122 ACE_TCHAR* name = argv[curarg];
124 if (ACE_OS::strcasecmp (name,
125 ACE_TEXT("infinite")) == 0)
127 this->thread_per_connection_use_timeout_ = 0;
129 else
131 this->thread_per_connection_use_timeout_ = 1;
132 int const milliseconds = ACE_OS::atoi (name);
133 this->thread_per_connection_timeout_.set (0,
134 1000 * milliseconds);
139 else if (ACE_OS::strcasecmp (argv[curarg],
140 ACE_TEXT("-ORBTableSize")) == 0
141 || ACE_OS::strcasecmp (argv[curarg],
142 ACE_TEXT("-ORBActiveObjectMapSize")) == 0)
144 ++curarg;
145 if (curarg < argc)
146 this->active_object_map_creation_parameters_.active_object_map_size_ =
147 ACE_OS::strtoul (argv[curarg],
148 nullptr,
149 10);
151 else if (ACE_OS::strcasecmp (argv[curarg],
152 ACE_TEXT("-ORBPOAMapSize")) == 0)
154 ++curarg;
155 if (curarg < argc)
156 this->active_object_map_creation_parameters_.poa_map_size_ =
157 ACE_OS::strtoul (argv[curarg],
158 nullptr,
159 10);
161 else if (ACE_OS::strcasecmp (argv[curarg],
162 ACE_TEXT("-ORBActiveHintInIds")) == 0)
164 ++curarg;
165 if (curarg < argc)
167 ACE_TCHAR* value = argv[curarg];
169 this->active_object_map_creation_parameters_.use_active_hint_in_ids_ =
170 ACE_OS::atoi (value);
173 else if (ACE_OS::strcasecmp (argv[curarg],
174 ACE_TEXT("-ORBActiveHintInPOANames")) == 0)
176 ++curarg;
177 if (curarg < argc)
179 ACE_TCHAR* value = argv[curarg];
181 this->active_object_map_creation_parameters_.use_active_hint_in_poa_names_ =
182 ACE_OS::atoi (value);
185 else if (ACE_OS::strcasecmp (argv[curarg],
186 ACE_TEXT("-ORBAllowReactivationOfSystemids")) == 0)
188 ++curarg;
189 if (curarg < argc)
191 ACE_TCHAR* value = argv[curarg];
193 this->active_object_map_creation_parameters_.allow_reactivation_of_system_ids_ =
194 ACE_OS::atoi (value);
197 else if (ACE_OS::strcasecmp (argv[curarg],
198 ACE_TEXT("-ORBUseridPolicyDemuxStrategy")) == 0)
200 ++curarg;
201 if (curarg < argc)
203 ACE_TCHAR* name = argv[curarg];
205 // Active demux not supported with user id policy.
206 if (ACE_OS::strcasecmp (name,
207 ACE_TEXT("dynamic")) == 0)
208 this->active_object_map_creation_parameters_.object_lookup_strategy_for_user_id_policy_ =
209 TAO_DYNAMIC_HASH;
210 else if (ACE_OS::strcasecmp (name,
211 ACE_TEXT("linear")) == 0)
212 this->active_object_map_creation_parameters_.object_lookup_strategy_for_user_id_policy_ =
213 TAO_LINEAR;
214 else
215 this->report_option_value_error (ACE_TEXT("-ORBUseridPolicyDemuxStrategy"), name);
218 else if (ACE_OS::strcasecmp (argv[curarg],
219 ACE_TEXT("-ORBSystemidPolicyDemuxStrategy")) == 0)
221 ++curarg;
222 if (curarg < argc)
224 ACE_TCHAR* name = argv[curarg];
226 if (ACE_OS::strcasecmp (name,
227 ACE_TEXT("dynamic")) == 0)
228 this->active_object_map_creation_parameters_.object_lookup_strategy_for_system_id_policy_ =
229 TAO_DYNAMIC_HASH;
230 else if (ACE_OS::strcasecmp (name,
231 ACE_TEXT("linear")) == 0)
232 this->active_object_map_creation_parameters_.object_lookup_strategy_for_system_id_policy_ =
233 TAO_LINEAR;
234 else if (ACE_OS::strcasecmp (name,
235 ACE_TEXT("active")) == 0)
236 this->active_object_map_creation_parameters_.object_lookup_strategy_for_system_id_policy_ =
237 TAO_ACTIVE_DEMUX;
238 else
239 this->report_option_value_error (ACE_TEXT("-ORBSystemidPolicyDemuxStrategy"), name);
242 else if (ACE_OS::strcasecmp (argv[curarg],
243 ACE_TEXT("-ORBPersistentidPolicyDemuxStrategy")) == 0)
245 ++curarg;
246 if (curarg < argc)
248 ACE_TCHAR* name = argv[curarg];
250 // Active demux not supported with user id policy.
251 if (ACE_OS::strcasecmp (name,
252 ACE_TEXT("dynamic")) == 0)
253 this->active_object_map_creation_parameters_.poa_lookup_strategy_for_persistent_id_policy_ =
254 TAO_DYNAMIC_HASH;
255 else if (ACE_OS::strcasecmp (name,
256 ACE_TEXT("linear")) == 0)
257 this->active_object_map_creation_parameters_.poa_lookup_strategy_for_persistent_id_policy_ =
258 TAO_LINEAR;
259 else
260 this->report_option_value_error (ACE_TEXT("-ORBPersistentidPolicyDemuxStrategy"), name);
263 else if (ACE_OS::strcasecmp (argv[curarg],
264 ACE_TEXT("-ORBTransientidPolicyDemuxStrategy")) == 0)
266 ++curarg;
267 if (curarg < argc)
269 ACE_TCHAR* name = argv[curarg];
271 if (ACE_OS::strcasecmp (name,
272 ACE_TEXT("dynamic")) == 0)
273 this->active_object_map_creation_parameters_.poa_lookup_strategy_for_transient_id_policy_ =
274 TAO_DYNAMIC_HASH;
275 else if (ACE_OS::strcasecmp (name,
276 ACE_TEXT("linear")) == 0)
277 this->active_object_map_creation_parameters_.poa_lookup_strategy_for_transient_id_policy_ =
278 TAO_LINEAR;
279 else if (ACE_OS::strcasecmp (name,
280 ACE_TEXT("active")) == 0)
281 this->active_object_map_creation_parameters_.poa_lookup_strategy_for_transient_id_policy_ =
282 TAO_ACTIVE_DEMUX;
283 else
284 this->report_option_value_error (ACE_TEXT("-ORBTransientidPolicyDemuxStrategy"), name);
287 else if (ACE_OS::strcasecmp (argv[curarg],
288 ACE_TEXT("-ORBUniqueidPolicyReverseDemuxStrategy")) == 0)
290 ++curarg;
291 if (curarg < argc)
293 ACE_TCHAR* name = argv[curarg];
295 if (ACE_OS::strcasecmp (name,
296 ACE_TEXT("dynamic")) == 0)
297 this->active_object_map_creation_parameters_.reverse_object_lookup_strategy_for_unique_id_policy_ =
298 TAO_DYNAMIC_HASH;
299 else if (ACE_OS::strcasecmp (name,
300 ACE_TEXT("linear")) == 0)
301 this->active_object_map_creation_parameters_.reverse_object_lookup_strategy_for_unique_id_policy_ =
302 TAO_LINEAR;
303 else
304 this->report_option_value_error (ACE_TEXT("-ORBUniqueidPolicyReverseDemuxStrategy"), name);
307 else if (ACE_OS::strcasecmp (argv[curarg],
308 ACE_TEXT("-ORBThreadFlags")) == 0)
310 ++curarg;
312 if (curarg < argc)
313 this->tokenize (argv[curarg]);
316 else if (ACE_OS::strncmp (argv[curarg], ACE_TEXT("-ORB"), 4) == 0)
318 // Can we assume there is an argument after the option?
319 // ++curarg;
320 TAOLIB_ERROR ((LM_ERROR,
321 ACE_TEXT("Server_Strategy_Factory - ")
322 ACE_TEXT("unknown option <%s>\n"),
323 argv[curarg]));
325 else
327 TAOLIB_DEBUG ((LM_DEBUG,
328 ACE_TEXT("Server_Strategy_Factory - ")
329 ACE_TEXT("ignoring option <%s>\n"),
330 argv[curarg]));
333 return 0;
336 void
337 TAO_Default_Server_Strategy_Factory::report_option_value_error (
338 const ACE_TCHAR* option_name,
339 const ACE_TCHAR* option_value)
341 TAOLIB_DEBUG((LM_DEBUG,
342 ACE_TEXT ("Server_Strategy_Factory - unknown argument")
343 ACE_TEXT (" <%s> for <%s>\n"),
344 option_value, option_name));
347 ACE_STATIC_SVC_DEFINE (TAO_Default_Server_Strategy_Factory,
348 ACE_TEXT ("Server_Strategy_Factory"),
349 ACE_SVC_OBJ_T,
350 &ACE_SVC_NAME (TAO_Default_Server_Strategy_Factory),
351 ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
353 ACE_FACTORY_DEFINE (TAO, TAO_Default_Server_Strategy_Factory)
355 TAO_END_VERSIONED_NAMESPACE_DECL