Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tao / TAO_Internal.cpp
blob9c6c32cfbc76a1f7cc12236792ae87b40a3063f1
1 // -*- C++ -*-
2 #include "tao/TAO_Internal.h"
3 #include "tao/TAO_Singleton.h"
4 #include "tao/default_server.h"
5 #include "tao/default_client.h"
6 #include "tao/default_resource.h"
7 #include "tao/IIOP_Factory.h"
8 #include "tao/MCAST_Parser.h"
9 #include "tao/CORBANAME_Parser.h"
10 #include "tao/CORBALOC_Parser.h"
11 #include "tao/FILE_Parser.h"
12 #include "tao/HTTP_Parser.h"
13 #include "tao/DLL_Parser.h"
14 #include "tao/ORB_Core.h"
15 #include "tao/Adapter_Factory.h"
16 #include "tao/Default_Stub_Factory.h"
17 #include "tao/Default_Endpoint_Selector_Factory.h"
18 #include "tao/Default_Thread_Lane_Resources_Manager.h"
19 #include "tao/Default_Collocation_Resolver.h"
20 #include "tao/Codeset_Manager_Factory_Base.h"
21 #include "tao/Codeset_Manager.h"
22 #include "tao/Time_Policy_Manager.h"
23 #include "tao/System_Time_Policy_Strategy.h"
24 #include "tao/HR_Time_Policy_Strategy.h"
25 #include "tao/debug.h"
27 #include "ace/Dynamic_Service.h"
28 #include "ace/Arg_Shifter.h"
29 #include "ace/Argv_Type_Converter.h"
30 #include "ace/ARGV.h"
31 #include "ace/Env_Value_T.h"
32 #include "ace/ACE.h"
33 #include "ace/OS_NS_stdio.h"
34 #include "ace/Static_Object_Lock.h"
35 #include "ace/OS_NS_sys_stat.h"
37 #ifndef TAO_DEFAULT_RESOURCE_FACTORY_ARGS
38 # define TAO_DEFAULT_RESOURCE_FACTORY_ARGS 0
39 #endif /* !TAO_DEFAULT_RESOURCE_FACTORY_ARGS */
41 #ifndef TAO_DEFAULT_SERVER_STRATEGY_FACTORY_ARGS
42 # define TAO_DEFAULT_SERVER_STRATEGY_FACTORY_ARGS 0
43 #endif /* !TAO_DEFAULT_SERVER_STRATEGY_FACTORY_ARGS */
45 #ifndef TAO_DEFAULT_CLIENT_STRATEGY_FACTORY_ARGS
46 # define TAO_DEFAULT_CLIENT_STRATEGY_FACTORY_ARGS 0
47 #endif /* !TAO_DEFAULT_RESOURCE_FACTORY_ARGS */
49 namespace
51 /**
52 * Parses the supplied command-line arguments to extract any that
53 * apply to the process (globally)
55 * @brief Modifies the argc to reflect any arguments it has
56 * "consumed"
58 * When multiple ORBs are being configured, the global options are
59 * only processed for the first ORB loaded. However subsequent ORBs
60 * may be supplied with some of these options, so they need to be
61 * eliminated as though they were processed. For this reason,
62 * this function is called for every ORB, but only the first call
63 * sets apply_values to true
66 int
67 parse_global_args_i (int &argc,
68 ACE_TCHAR **argv,
69 ACE_ARGV &svc_config_argv,
70 bool apply_values);
72 /**
73 * Parses the supplied command-line arguments to extract any that
74 * specify a Service Configurator file (-ORBSvcConf). This is done
75 * separately, because depending on the context, the configuration
76 * file may apply to the process-wide service repository, or to the
77 * orb-specific (private) one.
79 * @brief Modifies the argc to reflect any arguments it has
80 * "consumed"
82 int
83 parse_svcconf_args_i (int &argc,
84 ACE_TCHAR **argv,
85 ACE_ARGV &svc_config_argv);
87 /**
88 * Checks if there is -ORBGestalt option with non-GLOBAL value.
90 * @brief Modifies the argc to reflect any arguments it has
91 * "consumed"
93 * If the first ORB has some special configuration and uses non
94 * GLOBAL gestalt then it's expected the this configuration will
95 * not become default for other ORBs created after it. This function
96 * allows to avoid the above situation.
98 bool
99 using_global_gestalt_i (int &argc,
100 ACE_TCHAR **argv,
101 bool &skip_service_config_open);
104 * Initialize the ACE Service Configurator with the process-global
105 * services (available to any ORB).
107 * @return @c 0 if successful, @c -1 with @c errno set if failure.
109 * @note You can provide your program a set of default `svc.conf'
110 * entries by setting @a ignore_default_svc_conf_file to
111 * non-zero and use @c default_svc_conf_entries() before
112 * calling @c open_global_services(). In addition, you can @a
113 * skip_service_config_open altogether, which used to be
114 * important when the ORB is linked in via the
115 * ACE_Service_Config, since the ACE_Service_Config was
116 * non-reentrant. However, the ACE_Service_Config is now
117 * reentrant meaning that it is really no longer necessary to
118 * do so.
120 void
121 register_global_services_i (ACE_Service_Gestalt * pcfg);
122 void
123 register_additional_services_i (ACE_Service_Gestalt * pcfg);
126 * Parses the supplied command-line arguments to extract any
127 * instance-specific ones.
129 * @brief Modifies the argc to reflect any arguments it has
130 * "consumed"
133 parse_private_args_i (int &argc,
134 ACE_TCHAR **argv,
135 ACE_ARGV & svc_config_argv,
136 bool & skip_service_config_open,
137 bool & ignore_default_svc_conf_file);
140 * Initialize ORB-local (private) ACE Service Configurator
141 * repository.
143 * @return @c 0 if successful, @c -1 with @c errno set if failure.
147 open_private_services_i (ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> pcfg,
148 int & argc,
149 ACE_TCHAR **argv,
150 bool skip_service_config_open = false,
151 bool ignore_default_svc_conf_file = false);
154 * Number of times open_services() has been called. Incremented by
155 * open_global_services_i(), and decremented by close_services().
157 * @note In/decrement operations are atomic.
159 long service_open_count = 0;
162 * Part of a condition variable, which helps to ensure non-default
163 * ORBs can not proceed with their initialization, until the globaly
164 * required services have been instantiated by the default
165 * ORB. Usually, the first ORB to be created is designated the
166 * default ORB (reference the CORBA spec)
168 bool is_ubergestalt_ready = false;
170 char const * resource_factory_args =
171 TAO_DEFAULT_RESOURCE_FACTORY_ARGS;
172 char const * server_strategy_factory_args =
173 TAO_DEFAULT_SERVER_STRATEGY_FACTORY_ARGS;
174 char const * client_strategy_factory_args =
175 TAO_DEFAULT_CLIENT_STRATEGY_FACTORY_ARGS;
177 #if (TAO_NEGOTIATE_CODESETS == 1)
178 bool negotiate_codesets = true;
179 #else
180 bool negotiate_codesets = false;
181 #endif /* TAO_NEGOTIATE_CODESETS */
182 } // anonymous namespace
184 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
186 #if defined (ACE_HAS_THREADS)
187 /// A little helper class to get around the TAO_Singleton::instance ()
188 /// inability to pass default initialization arguments to the
189 /// singleton ctor.
190 class TAO_Ubergestalt_Ready_Condition
191 : public ACE_SYNCH_RECURSIVE_CONDITION
193 public:
194 static TAO_Ubergestalt_Ready_Condition* instance ()
196 return TAO_Singleton <TAO_Ubergestalt_Ready_Condition,
197 TAO_SYNCH_RECURSIVE_MUTEX>::instance ();
200 TAO_Ubergestalt_Ready_Condition ()
201 : ACE_SYNCH_RECURSIVE_CONDITION (mutex_)
205 private:
206 /// The mutex, associated with the condition. Do not use the ACE
207 /// global mutex, because it causes deadlocks with other threads that
208 /// may be in DLL_Manager::open()
209 ACE_Recursive_Thread_Mutex mutex_;
211 #endif // ACE_HAS_THREADS
213 // ****************************************************************
214 /// Note that the argument vector will be corrupted upon return
216 TAO::ORB::open_global_services (int argc, ACE_TCHAR **argv)
219 // Count of the number of (times we did this for all) ORBs.
220 static int orb_init_count = 0;
222 // Using ACE_Static_Object_Lock::instance() precludes ORB_init()
223 // from being called within a static object CTOR.
224 ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
225 guard,
226 *ACE_Static_Object_Lock::instance (),
227 -1));
229 // Make sure TAO's singleton manager is initialized.
230 // We need to initialize before TAO_default_environment() is called
231 // since that call instantiates a TAO_TSS_Singleton.
232 if (TAO_Singleton_Manager::instance ()->init () == -1)
233 return -1;
235 // Prevent multiple initializations.
236 if (++orb_init_count > 1)
237 return 0;
240 // Prevent any other thread from going through ORB initialization before the
241 // uber-gestalt is initialized.
242 ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
243 guard,
244 TAO_Ubergestalt_Ready_Condition::instance ()->mutex (),
245 -1));
247 if (TAO_debug_level > 2)
249 TAOLIB_DEBUG ((LM_DEBUG,
250 ACE_TEXT ("TAO (%P|%t) Initializing the ")
251 ACE_TEXT ("process-wide service context\n")));
254 ACE_Service_Gestalt* theone = ACE_Service_Config::global ();
255 ACE_Service_Config_Guard auto_config_guard (theone);
257 // Construct an argument vector specific to the process-wide
258 // (global) Service Configurator instance.
259 // Be certain to copy the program name so that service configurator
260 // has something to skip!
261 ACE_ARGV global_svc_config_argv (true); // only this ctor allows
262 // subsequent use of add()!
263 global_svc_config_argv.add ((argc <= 0 || argv == nullptr) ?
264 ACE_TEXT ("") : argv[0], true);
266 // Will expand the environment variables, if any were used.
267 // Is this a good thing? I guess it provides greater flexibility
268 // for deployment,so let's leave it. Will also quote arguments.
269 ACE_ARGV copyargv (argc, argv, true, true);
271 // Adjust to proper type
272 int tmpargc = copyargv.argc (); // use copied count, not original
273 ACE_Argv_Type_Converter cvtargv (tmpargc, copyargv.argv());
275 tmpargc = cvtargv.get_argc ();
276 ACE_TCHAR **tmpargv = cvtargv.get_TCHAR_argv ();
278 // Collect global SC parameters. True means "immediately
279 // apply global setting" like debug flag, etc.
280 if (parse_global_args_i (tmpargc,
281 tmpargv,
282 global_svc_config_argv,
283 true) == -1)
284 return -1;
286 bool skip_service_config_open = false; // by default we shouldn't
288 if (using_global_gestalt_i (tmpargc,
289 tmpargv,
290 skip_service_config_open))
292 if (parse_svcconf_args_i (tmpargc,
293 tmpargv,
294 global_svc_config_argv) == -1)
295 return -1;
298 bool ignore_default_svc_conf_file = false;
300 if (parse_private_args_i (tmpargc,
301 tmpargv,
302 global_svc_config_argv,
303 skip_service_config_open,
304 ignore_default_svc_conf_file) == -1)
305 return -1;
307 // register_global_services_i depends on the parsing of at least the
308 // -ORBNegotiateCodesets option, and must be invoked after all the
309 // parsing methods, but still must preceed the opening of other services.
311 register_global_services_i (theone);
313 // Perform the open magic (unless SC::open() has been called already)
314 int global_svc_config_argc = global_svc_config_argv.argc ();
315 int status = open_private_services_i (theone,
316 global_svc_config_argc,
317 global_svc_config_argv.argv (),
318 skip_service_config_open,
319 ignore_default_svc_conf_file);
321 // okay?
322 if (status == -1)
324 if (errno != ENOENT)
326 if (TAO_debug_level > 0)
328 TAOLIB_ERROR ((LM_ERROR,
329 ACE_TEXT ("TAO (%P|%t) - Failed to open process-")
330 ACE_TEXT ("wide service configuration context\n")));
332 return -1;
334 else
336 if (TAO_debug_level > 4)
337 TAOLIB_DEBUG ((LM_DEBUG,
338 ACE_TEXT ("TAO (%P|%t) - Did not find default ")
339 ACE_TEXT ("svc.conf\n")));
340 status = 0;
344 if (status > 0)
346 // one or more directives failed, but we don't know which
347 if (TAO_debug_level > 0)
349 TAOLIB_DEBUG ((LM_DEBUG,
350 ACE_TEXT ("TAO (%P|%t) - process-wide service ")
351 ACE_TEXT ("configuration context had %d failed ")
352 ACE_TEXT ("directives\n"), status));
356 if (TAO_debug_level > 2)
357 TAOLIB_DEBUG ((LM_DEBUG,
358 ACE_TEXT ("TAO (%P|%t) - Completed initializing the ")
359 ACE_TEXT ("process-wide service context\n")));
361 if (TAO_debug_level > 4)
362 TAOLIB_DEBUG ((LM_DEBUG,
363 ACE_TEXT ("TAO (%P|%t) - Default ORB services initialization begins\n")));
365 // Load more ORB-related services
366 register_additional_services_i (theone);
368 if (TAO_debug_level > 4)
369 TAOLIB_DEBUG ((LM_DEBUG,
370 ACE_TEXT ("TAO (%P|%t) - Default ORB services initialization completed\n")));
372 // Notify all other threads that may be waiting, that the global
373 // gestalt has been initialized.
374 is_ubergestalt_ready = true;
375 ACE_MT (if (TAO_Ubergestalt_Ready_Condition::instance ()->
376 broadcast () == -1)
377 return -1);
379 return 0;
383 TAO::ORB::open_services (ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> pcfg,
384 int &argc,
385 ACE_TCHAR **argv)
388 ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
389 guard,
390 TAO_Ubergestalt_Ready_Condition::instance ()->mutex (),
391 -1));
393 // Wait in line, while the default ORB (which isn't us) completes
394 // initialization of the globaly required service objects
395 if (service_open_count == 1)
397 if (TAO_debug_level > 4)
398 TAOLIB_DEBUG ((LM_DEBUG,
399 ACE_TEXT ("TAO (%P|%t) - Waiting for the default ")
400 ACE_TEXT ("ORB to complete the global ")
401 ACE_TEXT ("initialization\n")));
403 ACE_MT (while (!is_ubergestalt_ready)
404 TAO_Ubergestalt_Ready_Condition::instance ()->wait ());
406 if (TAO_debug_level > 4)
407 TAOLIB_DEBUG ((LM_DEBUG,
408 ACE_TEXT ("TAO (%P|%t) - The default ")
409 ACE_TEXT ("ORB must have completed the global ")
410 ACE_TEXT ("initialization...\n")));
412 else
414 if (TAO_debug_level > 4)
415 TAOLIB_DEBUG ((LM_DEBUG,
416 ACE_TEXT ("TAO (%P|%t) - We are%Cthe default ")
417 ACE_TEXT ("%C ORB ...\n"),
418 (service_open_count == 0) ? " " : " not ",
419 TAO_VERSION));
422 ++service_open_count;
425 // Construct an argument vector specific to the Service Configurator.
426 // Be certain to copy the program name so that service configurator
427 // has something to skip!
428 ACE_ARGV svc_config_argv (true); // only this ctor allows subsequent
429 // use of add()!
430 svc_config_argv.add ((argc <= 0 || argv == nullptr) ? ACE_TEXT ("") : argv[0],
431 true);
433 // Should we skip the ACE_Service_Config::open() method?,
434 // e.g., because of -ORBSkipServiceConfigOpen
435 bool skip_service_config_open = false;
436 bool ignore_default_svc_conf_file = false;
438 // Extract any ORB options from the argument vector.
439 if (parse_private_args_i (argc,
440 argv,
441 svc_config_argv,
442 skip_service_config_open,
443 ignore_default_svc_conf_file) == -1)
445 return -1;
448 // Construct an argument vector specific to the process-wide
449 // (global) Service Configurator instance.
450 ACE_ARGV global_svc_config_argv;
452 // Parse any globally applicable arguments, but do not make them effective.
453 // We are effectively purging the command line from them without affecting
454 // the global state - after all, it may be a private (local) configuration
455 // context.
456 int status = parse_global_args_i(argc, argv, global_svc_config_argv, false);
458 if (status == -1 && TAO_debug_level > 0)
459 TAOLIB_DEBUG ((LM_DEBUG,
460 ACE_TEXT ("TAO (%P|%t) - Skipping the process-wide ")
461 ACE_TEXT ("service configuration, service_open_count ")
462 ACE_TEXT ("= %d, status = %d\n"),
463 service_open_count,
464 status));
466 if (TAO_debug_level > 2)
467 TAOLIB_DEBUG ((LM_DEBUG,
468 ACE_TEXT ("TAO (%P|%t) - Initializing the ")
469 ACE_TEXT ("orb-specific services\n")));
471 if (parse_svcconf_args_i (argc, argv, svc_config_argv) == -1)
472 return -1;
473 // Not a big deal to call open_private_services_i() again (if it was the global one). The SG::open() would not run if it has already been executed.
474 // only open the private context if it is not also the global context
475 if (pcfg != ACE_Service_Config::global())
477 int svc_config_argc = svc_config_argv.argc ();
478 status =
479 open_private_services_i (pcfg,
480 svc_config_argc,
481 svc_config_argv.argv (),
482 skip_service_config_open,
483 ignore_default_svc_conf_file);
486 if (status == -1)
488 if (errno != ENOENT)
490 if (TAO_debug_level > 0)
491 TAOLIB_ERROR ((LM_ERROR,
492 ACE_TEXT ("TAO (%P|%t) - Failed to open ORB-specific ")
493 ACE_TEXT ("service configuration\n")));
494 return -1;
496 else
498 if (TAO_debug_level > 4)
499 TAOLIB_DEBUG ((LM_DEBUG,
500 ACE_TEXT ("TAO (%P|%t) - Did not find default ")
501 ACE_TEXT ("svc.conf\n")));
502 status = 0;
506 if (status > 0)
508 // one or more directives failed, but we don't know which
509 if (TAO_debug_level > 0)
511 TAOLIB_DEBUG ((LM_DEBUG,
512 ACE_TEXT ("TAO (%P|%t) - ORB-specific service ")
513 ACE_TEXT ("configuration context had %d failed ")
514 ACE_TEXT ("directives\n"), status));
519 return status;
523 TAO::ORB::close_services (ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> pcfg)
525 ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
526 guard,
527 *ACE_Static_Object_Lock::instance (),
528 -1));
529 --service_open_count;
531 int result = 0;
533 if (pcfg != ACE_Service_Config::global())
535 result = pcfg->close ();
538 return result;
541 void
542 TAO::ORB::default_svc_conf_entries (char const * rf_args,
543 char const * ssf_args,
544 char const * csf_args)
546 if (rf_args)
548 resource_factory_args = rf_args;
550 if (ssf_args)
552 server_strategy_factory_args = ssf_args;
554 if (csf_args)
556 client_strategy_factory_args = csf_args;
560 TAO_END_VERSIONED_NAMESPACE_DECL
562 // -----------------------------------------------------
563 namespace
565 /// Open services, belonging to the gestalt instance.
568 open_private_services_i (ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> pcfg,
569 int & argc,
570 ACE_TCHAR ** argv,
571 bool skip_service_config_open,
572 bool ignore_default_svc_conf_file)
574 if (skip_service_config_open)
576 return 0;
579 #if defined (TAO_PLATFORM_SVC_CONF_FILE_NOTSUP)
580 ignore_default_svc_conf_file = true;
581 #endif /* TAO_PLATFORM_SVC_CONF_FILE_NOTSUP */
583 // Copy command line parameter to allow conversion
584 ACE_Argv_Type_Converter command_line (argc, argv);
586 return pcfg->open (command_line.get_argc (),
587 command_line.get_TCHAR_argv (),
588 nullptr,
589 false, // Don't ignore static services.
590 ignore_default_svc_conf_file);
593 /// @brief registers all process-wide (global) services, available
594 /// to all ORBs
595 void
596 register_global_services_i (ACE_Service_Gestalt * pcfg)
598 // This has to be done before intializing the resource
599 // factory. Codesets is a special library since its configuration
600 // is optional and it may be linked statically.
601 if (negotiate_codesets)
603 TAO_Codeset_Manager_Factory_Base *factory =
604 ACE_Dynamic_Service<TAO_Codeset_Manager_Factory_Base>::instance (
605 "TAO_Codeset");
607 if (factory == nullptr || factory->is_default ())
609 #if !defined (TAO_AS_STATIC_LIBS) && !(defined (ACE_VXWORKS) && !defined (__RTP__))
610 // only for dynamic libs, check to see if default factory
611 // and if so, remove it
612 ACE_Service_Config::process_directive (
613 ACE_REMOVE_SERVICE_DIRECTIVE ("TAO_Codeset"));
615 ACE_Service_Config::process_directive (
616 ACE_DYNAMIC_VERSIONED_SERVICE_DIRECTIVE (
617 "TAO_Codeset",
618 "TAO_Codeset",
619 TAO_VERSION,
620 "_make_TAO_Codeset_Manager_Factory",
621 ""));
623 factory =
624 ACE_Dynamic_Service<
625 TAO_Codeset_Manager_Factory_Base
626 >::instance ("TAO_Codeset");
627 #endif /* !TAO_AS_STATIC_LIBS && !(ACE_VXWORKS && !__RTP__) */
630 if (factory == nullptr)
632 if (TAO_debug_level > 0)
634 TAOLIB_ERROR ((LM_ERROR,
635 ACE_TEXT ("TAO (%P|%t) - ORB_Core: ")
636 ACE_TEXT ("Unable to initialize ")
637 ACE_TEXT ("Codeset Manager\n")));
642 pcfg->process_directive (
643 ace_svc_desc_TAO_Default_Resource_Factory);
644 pcfg->process_directive (
645 ace_svc_desc_TAO_Default_Client_Strategy_Factory);
646 pcfg->process_directive (
647 ace_svc_desc_TAO_Default_Server_Strategy_Factory);
649 // Configure the IIOP factory. You do *NOT* need modify this
650 // code to add your own protocol, instead simply add the
651 // following to your svc.conf file:
653 // dynamic PN_Factory Service_Object * LIB:_make_PN_Protocol_Factory() ""
654 // static Resource_Factory "-ORBProtocolFactory PN_Factory"
656 // where PN is the name of your protocol and LIB is the base
657 // name of the shared library that implements the protocol.
659 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
660 pcfg->process_directive (ace_svc_desc_TAO_IIOP_Protocol_Factory);
661 #endif /* TAO_HAS_IIOP && TAO_HAS_IIOP != 0 */
663 // add descriptor to list of static objects.
664 #if (TAO_HAS_MCAST_PARSER == 1)
665 pcfg->process_directive (ace_svc_desc_TAO_MCAST_Parser);
666 #endif /* TAO_HAS_MCAST_PARSER == 1 */
667 #if (TAO_HAS_CORBANAME_PARSER == 1)
668 pcfg->process_directive (ace_svc_desc_TAO_CORBANAME_Parser);
669 #endif /* TAO_HAS_CORBANAME_PARSER == 1 */
670 #if (TAO_HAS_CORBALOC_PARSER == 1)
671 pcfg->process_directive (ace_svc_desc_TAO_CORBALOC_Parser);
672 #endif /* TAO_HAS_CORBALOC_PARSER == 1 */
673 #if (TAO_HAS_FILE_PARSER == 1)
674 pcfg->process_directive (ace_svc_desc_TAO_FILE_Parser);
675 #endif /* TAO_HAS_FILE_PARSER == 1 */
676 #if (TAO_HAS_DDL_PARSER == 1)
677 pcfg->process_directive (ace_svc_desc_TAO_DLL_Parser);
678 #endif /* TAO_HAS_DDL_PARSER == 1 */
679 #if (TAO_HAS_HTTP_PARSER == 1)
680 pcfg->process_directive (ace_svc_desc_TAO_HTTP_Parser);
681 #endif /* TAO_HAS_HTTP_PARSER */
682 pcfg->process_directive (ace_svc_desc_TAO_Default_Stub_Factory);
683 pcfg->process_directive (
684 ace_svc_desc_TAO_Default_Endpoint_Selector_Factory);
685 pcfg->process_directive (
686 ace_svc_desc_TAO_Default_Thread_Lane_Resources_Manager_Factory);
687 pcfg->process_directive (ace_svc_desc_TAO_Default_Collocation_Resolver);
688 #if (TAO_HAS_TIME_POLICY == 1)
689 pcfg->process_directive (ace_svc_desc_TAO_Time_Policy_Manager);
690 pcfg->process_directive (ace_svc_desc_TAO_System_Time_Policy_Strategy);
691 pcfg->process_directive (ace_svc_desc_TAO_HR_Time_Policy_Strategy);
692 #endif
694 } /* register_global_services_i */
696 void
697 register_additional_services_i (ACE_Service_Gestalt * pcfg)
699 // @@ What the heck do these things do and do we need to avoid
700 // calling them if we're not invoking the svc.conf file?
701 // @@ They are needed for platforms that have no file system,
702 // like VxWorks.
704 if (resource_factory_args != nullptr)
706 pcfg->process_directive(
707 ACE_TEXT_CHAR_TO_TCHAR (resource_factory_args));
710 if (client_strategy_factory_args != nullptr)
712 pcfg->process_directive
713 (ACE_TEXT_CHAR_TO_TCHAR (client_strategy_factory_args));
716 if (server_strategy_factory_args != nullptr)
718 pcfg->process_directive
719 (ACE_TEXT_CHAR_TO_TCHAR (server_strategy_factory_args));
722 ACE_Service_Object * const pi_server_loader =
723 ACE_Dynamic_Service<ACE_Service_Object>::instance (
724 pcfg,
725 "PI_Server_Loader");
727 if (pi_server_loader != nullptr)
729 pi_server_loader->init (0, nullptr);
732 ACE_Service_Object * const bidir_loader =
733 ACE_Dynamic_Service<ACE_Service_Object>::instance (
734 pcfg,
735 "BiDirGIOP_Loader");
737 if (bidir_loader != nullptr)
739 bidir_loader->init (0, nullptr);
742 #if defined (TAO_HAS_ZIOP) && TAO_HAS_ZIOP == 1
743 ACE_Service_Object * const ziop_loader =
744 ACE_Dynamic_Service<ACE_Service_Object>::instance (
745 pcfg,
746 "ZIOP_Loader");
748 if (ziop_loader != nullptr)
750 ziop_loader->init (0, nullptr);
752 #endif
754 ACE_Service_Object * const messaging_loader =
755 ACE_Dynamic_Service<ACE_Service_Object>::instance (
756 pcfg,
757 "Messaging_Loader");
759 if (messaging_loader != nullptr)
761 messaging_loader->init (0, nullptr);
764 // Handle RTCORBA library special case. Since RTCORBA needs
765 // its init method call to register several hooks, call it
766 // here if it hasn't already been called.
767 ACE_Service_Object * const rt_loader =
768 ACE_Dynamic_Service<ACE_Service_Object>::instance (
769 pcfg,
770 "RT_ORB_Loader");
772 if (rt_loader != nullptr)
774 rt_loader->init (0, nullptr);
777 ACE_Service_Object * const rtscheduler_loader =
778 ACE_Dynamic_Service<ACE_Service_Object>::instance (
779 pcfg,
780 "RTScheduler_Loader");
782 if (rtscheduler_loader != nullptr)
784 rtscheduler_loader->init (0, nullptr);
787 ACE_Service_Object * const csd_framework_loader =
788 ACE_Dynamic_Service<ACE_Service_Object>::instance (
789 pcfg,
790 "CSD_Framework_Loader");
792 if (csd_framework_loader != nullptr)
794 csd_framework_loader->init (0, nullptr);
797 ACE_Service_Object * const endpoint_policy_loader =
798 ACE_Dynamic_Service<ACE_Service_Object>::instance (
799 pcfg,
800 "EndpointPolicy_Initializer");
802 if (endpoint_policy_loader != nullptr)
804 endpoint_policy_loader->init (0, nullptr);
807 ACE_Service_Object * const diffserv_policy_loader =
808 ACE_Dynamic_Service<ACE_Service_Object>::instance (
809 pcfg,
810 "DiffservPolicy_Initializer");
812 if (diffserv_policy_loader != nullptr)
814 diffserv_policy_loader->init (0, nullptr);
816 } /* register_additional_services_i */
819 parse_svcconf_args_i (int &argc,
820 ACE_TCHAR **argv,
821 ACE_ARGV &svc_config_argv)
823 // Extract the Service Configurator ORB options from the argument
824 // vector.
825 ACE_Arg_Shifter arg_shifter (argc, argv);
827 while (arg_shifter.is_anything_left ())
829 // Can't interpret this argument. Move on to the next argument.
830 if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-ORBSvcConf")) == 0)
832 const ACE_TCHAR *current_arg =
833 arg_shifter.get_the_parameter (ACE_TEXT ("-ORBSvcConf"));
834 arg_shifter.consume_arg ();
836 // Proceeds only if the configuration file exists.
837 FILE * const conf_file =
838 ACE_OS::fopen (current_arg, ACE_TEXT ("r"));
839 if (nullptr == conf_file)
841 // Assigning EINVAL to errno to make an exception
842 // thrown. calling code does not throw an exception if
843 // the errno is set to ENOENT for some reason.
844 errno = EINVAL;
846 TAOLIB_ERROR_RETURN ((LM_ERROR,
847 ACE_TEXT ("TAO (%P|%t) - Error, unable to open file <%s>")
848 ACE_TEXT (", referenced by -ORBSvcConf option\n"),
849 current_arg),
850 -1);
852 else
854 ACE_OS::fclose (conf_file);
857 svc_config_argv.add (ACE_TEXT ("-f"));
858 svc_config_argv.add (current_arg, true);
860 else if (arg_shifter.cur_arg_strncasecmp
861 (ACE_TEXT ("-ORBSvcConfDirective")) == 0)
863 const ACE_TCHAR *current_arg =
864 arg_shifter.get_the_parameter (ACE_TEXT ("-ORBSvcConfDirective"));
866 // This is used to pass arguments to the Service
867 // Configurator using the "command line" to provide
868 // configuration information rather than using a svc.conf
869 // file. Pass the "-S" to the service configurator.
870 svc_config_argv.add (ACE_TEXT ("-S"));
871 svc_config_argv.add (current_arg, true); // quote args!
873 arg_shifter.consume_arg ();
875 else
877 // Any arguments that don't match are ignored so that the
878 // caller can still use them.
879 arg_shifter.ignore_arg ();
883 return 0;
884 } /* parse_svcconf_args_i */
887 parse_private_args_i (int &argc,
888 ACE_TCHAR **argv,
889 ACE_ARGV &svc_config_argv,
890 bool & skip_service_config_open,
891 bool & ignore_default_svc_conf_file)
893 // Extract the Service Configurator ORB options from the argument
894 // vector.
895 ACE_Arg_Shifter arg_shifter (argc, argv);
897 while (arg_shifter.is_anything_left ())
899 const ACE_TCHAR *current_arg = nullptr;
900 if (0 == arg_shifter.cur_arg_strncasecmp
901 (ACE_TEXT ("-ORBSkipServiceConfigOpen")))
903 skip_service_config_open = true;
905 arg_shifter.consume_arg ();
907 if (0 == arg_shifter.cur_arg_strncasecmp
908 (ACE_TEXT ("-ORBIgnoreDefaultSvcConfFile")))
910 ignore_default_svc_conf_file = true;
912 arg_shifter.consume_arg ();
914 else if (nullptr != (current_arg = arg_shifter.get_the_parameter
915 (ACE_TEXT ("-ORBServiceConfigLoggerKey"))))
917 svc_config_argv.add (ACE_TEXT ("-k"));
918 svc_config_argv.add (current_arg, true); // quote args!
920 arg_shifter.consume_arg ();
922 else if (0 == arg_shifter.cur_arg_strncasecmp
923 (ACE_TEXT ("-ORBNegotiateCodesets")))
925 // Negotiate codesets must be evaluated prior to calling
926 // register_global_services_i.
928 // Don't consume, the ORB_Core::init will use it again.
929 arg_shifter.ignore_arg();
931 if (nullptr != (current_arg = arg_shifter.get_current()))
932 negotiate_codesets = (ACE_OS::atoi (current_arg));
934 arg_shifter.ignore_arg();
936 else if (nullptr != (current_arg =
937 arg_shifter.get_the_parameter
938 (ACE_TEXT ("-ORBDebugLevel"))))
940 // Allowing different ORBs to change the global debug
941 // level may be unexpected, but since this
942 TAO_debug_level = ACE_OS::atoi (current_arg);
944 arg_shifter.consume_arg ();
946 else
948 // Can't interpret this argument. Move on to the next
949 // argument. Any arguments that don't match are ignored
950 // so that the caller can still use them.
951 arg_shifter.ignore_arg ();
955 return 0;
956 } /* parse_private_args_i */
959 parse_global_args_i (int &argc,
960 ACE_TCHAR **argv,
961 ACE_ARGV &svc_config_argv,
962 bool apply_values)
964 // NOTE: When adding new global arguments, ensure they are only
965 // applied when apply_values is true, but that they are always
966 // consumed, if they need to be consumed.
967 #if defined (TAO_DEBUG)
968 // Make it a little easier to debug programs using this code.
969 if (apply_values)
971 TAO_debug_level = ACE_Env_Value<u_int> ("TAO_ORB_DEBUG", 0);
973 if (TAO_debug_level != 0)
975 if (TAO_debug_level <= 0)
977 TAO_debug_level = 1;
980 TAOLIB_DEBUG ((LM_DEBUG,
981 ACE_TEXT ("TAO_debug_level == %d\n"),
982 TAO_debug_level));
985 #endif /* TAO_DEBUG */
987 // Extract the Service Configurator ORB options from the argument
988 // vector.
989 ACE_Arg_Shifter arg_shifter (argc, argv);
991 while (arg_shifter.is_anything_left ())
993 if (0 == arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-ORBDebug")))
995 if (apply_values)
997 // Later, replace all of these
998 // warning this turns on a daemon.
999 ACE::debug (1);
1002 arg_shifter.consume_arg ();
1004 else if (0 == arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-ORBDaemon")))
1006 // Be a daemon.
1007 if (apply_values)
1009 svc_config_argv.add (ACE_TEXT("-b"));
1012 arg_shifter.consume_arg ();
1014 // Can't interpret this argument.
1015 // Move on to the next argument.
1016 else
1018 // Any arguments that don't match are ignored so
1019 // that the caller can still use them.
1020 arg_shifter.ignore_arg ();
1023 return 0;
1024 } /* parse_global_args_i */
1026 bool
1027 using_global_gestalt_i (int &argc,
1028 ACE_TCHAR **argv,
1029 bool &skip_service_config_open)
1031 bool with_global_gestalt = true;
1033 ACE_Arg_Shifter arg_shifter (argc, argv);
1035 while (arg_shifter.is_anything_left ())
1037 if (0 == arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-ORBGestalt")))
1039 // Skip -ORBGestalt. This option is necessary in later stages.
1040 arg_shifter.ignore_arg ();
1042 // This should set current_arg to the value of ORBGestalt option.
1043 const ACE_TCHAR *current_arg = arg_shifter.get_current ();
1045 if (nullptr != current_arg &&
1046 ACE_OS::strcasecmp (current_arg, ACE_TEXT("GLOBAL")) != 0)
1048 with_global_gestalt = false;
1050 ACE_stat exists;
1051 if (ACE_OS::stat (ACE_DEFAULT_SVC_CONF, &exists) == 0)
1053 // In case svc.conf exists and we are asked for a local
1054 // gestalt then no matter whether -ORBSvcConf or
1055 // -ORBSvcConfDirective are provided or not we ignore them
1056 // while setting up a global gestalt. They will be
1057 // processed later in a local gestalt.
1058 skip_service_config_open = true;
1062 // Skip anything that goes after -ORBGestalt.
1063 arg_shifter.ignore_arg ();
1065 // Can't interpret this argument.
1066 // Move on to the next argument.
1067 else
1069 // Any arguments that don't match are ignored so
1070 // that the caller can still use them.
1071 arg_shifter.ignore_arg ();
1074 return with_global_gestalt;
1075 } /* using_global_gestalt_i */
1076 } // anonymous namespace.