1 #include "tao/default_server.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.
21 TAO_Default_Server_Strategy_Factory::activate_server_connections ()
23 return this->activate_server_connections_
;
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_
;
34 TAO_Default_Server_Strategy_Factory::server_connection_thread_flags ()
36 return this->thread_flags_
;
40 TAO_Default_Server_Strategy_Factory::server_connection_thread_count ()
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)
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
,
61 flag
= ACE_OS::strtok_r (nullptr,
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 */
78 TAO_Default_Server_Strategy_Factory::init (int argc
, ACE_TCHAR
* argv
[])
80 return this->parse_args (argc
, argv
);
84 TAO_Default_Server_Strategy_Factory::open (TAO_ORB_Core
*)
90 TAO_Default_Server_Strategy_Factory::parse_args (int argc
, ACE_TCHAR
* argv
[])
92 ACE_TRACE ("TAO_Default_Server_Strategy_Factory::parse_args");
96 for (curarg
= 0; curarg
< argc
&& argv
[curarg
]; ++curarg
)
97 if (ACE_OS::strcasecmp (argv
[curarg
],
98 ACE_TEXT("-ORBConcurrency")) == 0)
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;
112 this->report_option_value_error (ACE_TEXT("-ORBConcurrency"), name
);
116 else if (ACE_OS::strcasecmp (argv
[curarg
],
117 ACE_TEXT("-ORBThreadPerConnectionTimeout")) == 0)
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;
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)
146 this->active_object_map_creation_parameters_
.active_object_map_size_
=
147 ACE_OS::strtoul (argv
[curarg
],
151 else if (ACE_OS::strcasecmp (argv
[curarg
],
152 ACE_TEXT("-ORBPOAMapSize")) == 0)
156 this->active_object_map_creation_parameters_
.poa_map_size_
=
157 ACE_OS::strtoul (argv
[curarg
],
161 else if (ACE_OS::strcasecmp (argv
[curarg
],
162 ACE_TEXT("-ORBActiveHintInIds")) == 0)
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)
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)
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)
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_
=
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_
=
215 this->report_option_value_error (ACE_TEXT("-ORBUseridPolicyDemuxStrategy"), name
);
218 else if (ACE_OS::strcasecmp (argv
[curarg
],
219 ACE_TEXT("-ORBSystemidPolicyDemuxStrategy")) == 0)
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_
=
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_
=
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_
=
239 this->report_option_value_error (ACE_TEXT("-ORBSystemidPolicyDemuxStrategy"), name
);
242 else if (ACE_OS::strcasecmp (argv
[curarg
],
243 ACE_TEXT("-ORBPersistentidPolicyDemuxStrategy")) == 0)
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_
=
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_
=
260 this->report_option_value_error (ACE_TEXT("-ORBPersistentidPolicyDemuxStrategy"), name
);
263 else if (ACE_OS::strcasecmp (argv
[curarg
],
264 ACE_TEXT("-ORBTransientidPolicyDemuxStrategy")) == 0)
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_
=
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_
=
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_
=
284 this->report_option_value_error (ACE_TEXT("-ORBTransientidPolicyDemuxStrategy"), name
);
287 else if (ACE_OS::strcasecmp (argv
[curarg
],
288 ACE_TEXT("-ORBUniqueidPolicyReverseDemuxStrategy")) == 0)
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_
=
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_
=
304 this->report_option_value_error (ACE_TEXT("-ORBUniqueidPolicyReverseDemuxStrategy"), name
);
307 else if (ACE_OS::strcasecmp (argv
[curarg
],
308 ACE_TEXT("-ORBThreadFlags")) == 0)
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?
320 TAOLIB_ERROR ((LM_ERROR
,
321 ACE_TEXT("Server_Strategy_Factory - ")
322 ACE_TEXT("unknown option <%s>\n"),
327 TAOLIB_DEBUG ((LM_DEBUG
,
328 ACE_TEXT("Server_Strategy_Factory - ")
329 ACE_TEXT("ignoring option <%s>\n"),
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"),
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