TAO_Internal.cpp

Go to the documentation of this file.
00001 // $Id: TAO_Internal.cpp 81658 2008-05-09 10:40:45Z johnnyw $
00002 
00003 #include "tao/TAO_Internal.h"
00004 #include "tao/TAO_Singleton.h"
00005 #include "tao/default_server.h"
00006 #include "tao/default_client.h"
00007 #include "tao/default_resource.h"
00008 #include "tao/IIOP_Factory.h"
00009 #include "tao/MCAST_Parser.h"
00010 #include "tao/CORBANAME_Parser.h"
00011 #include "tao/CORBALOC_Parser.h"
00012 #include "tao/FILE_Parser.h"
00013 #include "tao/HTTP_Parser.h"
00014 #include "tao/DLL_Parser.h"
00015 #include "tao/ORB_Core.h"
00016 #include "tao/Adapter_Factory.h"
00017 #include "tao/Default_Stub_Factory.h"
00018 #include "tao/Default_Endpoint_Selector_Factory.h"
00019 #include "tao/Default_Thread_Lane_Resources_Manager.h"
00020 #include "tao/Default_Collocation_Resolver.h"
00021 #include "tao/Codeset_Manager_Factory_Base.h"
00022 #include "tao/Codeset_Manager.h"
00023 #include "tao/debug.h"
00024 
00025 #include "ace/Dynamic_Service.h"
00026 #include "ace/Arg_Shifter.h"
00027 #include "ace/Argv_Type_Converter.h"
00028 #include "ace/ARGV.h"
00029 #include "ace/Env_Value_T.h"
00030 #include "ace/ACE.h"
00031 #include "ace/OS_NS_stdio.h"
00032 #include "ace/Static_Object_Lock.h"
00033 
00034 ACE_RCSID (tao,
00035            TAO_Internal,
00036            "$Id: TAO_Internal.cpp 81658 2008-05-09 10:40:45Z johnnyw $")
00037 
00038 #ifndef TAO_DEFAULT_RESOURCE_FACTORY_ARGS
00039 #  define TAO_DEFAULT_RESOURCE_FACTORY_ARGS 0
00040 #endif  /* !TAO_DEFAULT_RESOURCE_FACTORY_ARGS */
00041 
00042 #ifndef TAO_DEFAULT_SERVER_STRATEGY_FACTORY_ARGS
00043 #  define TAO_DEFAULT_SERVER_STRATEGY_FACTORY_ARGS 0
00044 #endif  /* !TAO_DEFAULT_SERVER_STRATEGY_FACTORY_ARGS */
00045 
00046 #ifndef TAO_DEFAULT_CLIENT_STRATEGY_FACTORY_ARGS
00047 #  define TAO_DEFAULT_CLIENT_STRATEGY_FACTORY_ARGS 0
00048 #endif  /* !TAO_DEFAULT_RESOURCE_FACTORY_ARGS */
00049 
00050 
00051 namespace
00052 {
00053   /**
00054    * Parses the supplied command-line arguments to extract any that
00055    * apply to the process (globally)
00056    *
00057    * @brief Modifies the argc to reflect any arguments it has
00058    * "consumed"
00059    *
00060    * When multiple ORBs are being configured, the global options are
00061    * only processed for the first ORB loaded. However subsequent ORBs
00062    * may be supplied with some of these options, so they need to be
00063    * eliminated as though they were processed. For this reason,
00064    * this function is called for every ORB, but only the first call
00065    * sets apply_values to true
00066    *
00067    */
00068   int
00069   parse_global_args_i (int &argc,
00070                        ACE_TCHAR **argv,
00071                        ACE_ARGV &svc_config_argv,
00072                        bool apply_values);
00073 
00074   /**
00075    * Parses the supplied command-line arguments to extract any that
00076    * specify a Service Configurator file (-ORBSvcConf). This is done
00077    * separately, because depending on the context, the configuration
00078    * file may apply to the process-wide service repository, or to the
00079    * orb-specific (private) one.
00080    *
00081    * @brief Modifies the argc to reflect any arguments it has
00082    * "consumed"
00083    */
00084   int
00085   parse_svcconf_args_i (int &argc,
00086                        ACE_TCHAR **argv,
00087                        ACE_ARGV &svc_config_argv);
00088 
00089   /**
00090    * Initialize the ACE Service Configurator with the process-global
00091    * services (available to any ORB).
00092    *
00093    * @return @c 0 if successful, @c -1 with @c errno set if failure.
00094    *
00095    * @note You can provide your program a set of default `svc.conf'
00096    *       entries by setting @a ignore_default_svc_conf_file to
00097    *       non-zero and use @c default_svc_conf_entries() before
00098    *       calling @c open_global_services().  In addition, you can @a
00099    *       skip_service_config_open altogether, which used to be
00100    *       important when the ORB is linked in via the
00101    *       ACE_Service_Config, since the ACE_Service_Config was
00102    *       non-reentrant.  However, the ACE_Service_Config is now
00103    *       reentrant meaning that it is really no longer necessary to
00104    *       do so.
00105    */
00106   void register_global_services_i (ACE_Service_Gestalt * pcfg);
00107   void register_additional_services_i (ACE_Service_Gestalt * pcfg);
00108 
00109   /**
00110    * Parses the supplied command-line arguments to extract any
00111    * instance-specific ones.
00112    *
00113    * @brief Modifies the argc to reflect any arguments it has
00114    * "consumed"
00115    */
00116   int
00117   parse_private_args_i (int &argc,
00118                         ACE_TCHAR **argv,
00119                         ACE_ARGV & svc_config_argv,
00120                         bool & skip_service_config_open);
00121 
00122   /**
00123    * Initialize ORB-local (private) ACE Service Configurator
00124    * repository.
00125    *
00126    * @return @c 0 if successful, @c -1 with @c errno set if failure.
00127    *
00128    */
00129   int open_private_services_i (ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> pcfg,
00130                                int & argc,
00131                                ACE_TCHAR **argv,
00132                                bool skip_service_config_open = false,
00133                                bool ignore_default_svc_conf_file = false);
00134 
00135   /**
00136    * Number of times open_services() has been called.  Incremented by
00137    * open_global_services_i(), and decremented by close_services().
00138    *
00139    * @note In/decrement operations are atomic.
00140    */
00141   long service_open_count = 0;
00142 
00143   /**
00144    * Part of a condition variable, which helps to ensure non-default
00145    * ORBs can not proceed with their initialization, until the globaly
00146    * required services have been instantiated by the default
00147    * ORB. Usually, the first ORB to be created is designated the
00148    * default ORB (reference the CORBA spec)
00149    */
00150   bool is_ubergestalt_ready = false;
00151 
00152   char const * resource_factory_args =
00153     TAO_DEFAULT_RESOURCE_FACTORY_ARGS;
00154   char const * server_strategy_factory_args =
00155     TAO_DEFAULT_SERVER_STRATEGY_FACTORY_ARGS;
00156   char const * client_strategy_factory_args =
00157     TAO_DEFAULT_CLIENT_STRATEGY_FACTORY_ARGS;
00158 
00159 #if (TAO_NEGOTIATE_CODESETS == 1)
00160   bool negotiate_codesets = true;
00161 #else
00162   bool negotiate_codesets = false;
00163 #endif /* TAO_NEGOTIATE_CODESETS */
00164 } // anonymous namespace
00165 
00166 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00167 
00168 #if defined (ACE_HAS_THREADS)
00169 /// A little helper class to get around the TAO_Singleton::instance ()
00170 /// inability to pass default initialization arguments to the
00171 /// singleton ctor.
00172 
00173 class TAO_Ubergestalt_Ready_Condition
00174   : public ACE_SYNCH_RECURSIVE_CONDITION
00175 {
00176 public:
00177   static TAO_Ubergestalt_Ready_Condition* instance (void)
00178   {
00179     return TAO_Singleton <TAO_Ubergestalt_Ready_Condition,
00180       TAO_SYNCH_RECURSIVE_MUTEX>::instance ();
00181   }
00182 
00183   TAO_Ubergestalt_Ready_Condition (void)
00184     : ACE_SYNCH_RECURSIVE_CONDITION (mutex_)
00185   {
00186   }
00187 
00188 
00189   private:
00190     /// The mutex, associated with the condition. Do not use the ACE
00191     /// global mutex, because it causes deadlocks with other threads that
00192     /// may be in DLL_Manager::open()
00193     ACE_Recursive_Thread_Mutex mutex_;
00194   };
00195   #endif // ACE_HAS_THREADS
00196 
00197 
00198 
00199 
00200   // ****************************************************************
00201   /// Note that the argument vector will be corrupted upon return
00202   int
00203   TAO::ORB::open_global_services (int argc,
00204                                   ACE_TCHAR **argv)
00205   {
00206     {
00207       // Count of the number of (times we did this for all) ORBs.
00208       static int orb_init_count = 0;
00209 
00210       // Using ACE_Static_Object_Lock::instance() precludes ORB_init()
00211       // from being called within a static object CTOR.
00212       ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00213                                 guard,
00214                                 *ACE_Static_Object_Lock::instance (),
00215                                 -1));
00216 
00217       // Make sure TAO's singleton manager is initialized.
00218       // We need to initialize before TAO_default_environment() is called
00219       // since that call instantiates a TAO_TSS_Singleton.
00220       if (TAO_Singleton_Manager::instance ()->init () == -1)
00221         return -1;
00222 
00223       // Prevent multiple initializations.
00224       if (++orb_init_count > 1)
00225         return 0;
00226 
00227     }
00228 
00229     // Prevent any other thread from going through ORB initialization before the
00230     // uber-gestalt is initialized.
00231     ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00232                               guard,
00233                               TAO_Ubergestalt_Ready_Condition::instance ()->mutex (),
00234                               -1));
00235 
00236     if (TAO_debug_level > 2)
00237       {
00238         ACE_DEBUG ((LM_DEBUG,
00239                     ACE_TEXT ("TAO (%P|%t) Initializing the ")
00240                     ACE_TEXT ("process-wide service context\n")));
00241       }
00242 
00243     ACE_Service_Gestalt* theone = ACE_Service_Config::global ();
00244     ACE_Service_Config_Guard auto_config_guard (theone);
00245 
00246     register_global_services_i (theone);
00247 
00248 
00249     // Construct an argument vector specific to the process-wide
00250     // (global) Service Configurator instance.
00251     // Be certain to copy the program name so that service configurator
00252     // has something to skip!
00253     ACE_ARGV global_svc_config_argv (true); // only this ctor allows subsequent use of add()!
00254     global_svc_config_argv.add ((argc <= 0 || argv == 0) ? ACE_TEXT ("") : argv[0]);
00255 
00256     // Will expand the environment variables, if any were used. Is this a good thing?
00257     // I guess it provides greater flexibility for deployment, so let's leave it. Will
00258     // also quote arguments.
00259     ACE_ARGV copyargv (argc, argv, true, true);
00260 
00261     // Adjust to proper type
00262     int tmpargc = argc;
00263     ACE_Argv_Type_Converter cvtargv (tmpargc, copyargv.argv());
00264 
00265     tmpargc = cvtargv.get_argc ();
00266     ACE_TCHAR **tmpargv = cvtargv.get_TCHAR_argv ();
00267 
00268     // Collect global SC parameters. True means "immediately
00269     // apply global setting" like debug flag, etc.
00270     if (parse_global_args_i (tmpargc,
00271                              tmpargv,
00272                              global_svc_config_argv,
00273                              true) == -1)
00274       return -1;
00275 
00276     bool skip_service_config_open = false; // by default we shouldn't
00277 
00278     if (parse_svcconf_args_i (tmpargc,
00279                               tmpargv,
00280                               global_svc_config_argv) == -1)
00281       return -1;
00282 
00283   if (parse_private_args_i (tmpargc,
00284                             tmpargv,
00285                             global_svc_config_argv,
00286                             skip_service_config_open) == -1)
00287     return -1;
00288 
00289   // Perform the open magic (unless SC::open() has been called already)
00290   int global_svc_config_argc = global_svc_config_argv.argc ();
00291   int status = open_private_services_i (theone,
00292                                         global_svc_config_argc,
00293                                         global_svc_config_argv.argv (),
00294                                         skip_service_config_open);
00295 
00296   // okay?
00297   if (status == -1)
00298     {
00299       if (TAO_debug_level > 0)
00300         {
00301           ACE_ERROR ((LM_DEBUG,
00302                       ACE_TEXT ("TAO (%P|%t) Failed to open process-")
00303                       ACE_TEXT ("wide service configuration context\n")));
00304         }
00305 
00306       return -1;
00307     }
00308 
00309   if (TAO_debug_level > 2)
00310     ACE_DEBUG ((LM_DEBUG,
00311                 ACE_TEXT ("TAO (%P|%t) Completed initializing the ")
00312                 ACE_TEXT ("process-wide service context\n")));
00313 
00314   if (TAO_debug_level > 4)
00315     ACE_DEBUG ((LM_DEBUG,
00316                 ACE_TEXT ("TAO (%P|%t) Default ORB services initialization begins\n")));
00317 
00318   // Load more ORB-related services
00319   register_additional_services_i (theone);
00320 
00321   if (TAO_debug_level > 4)
00322     ACE_DEBUG ((LM_DEBUG,
00323                 ACE_TEXT ("TAO (%P|%t) Default ORB services initialization completed\n")));
00324 
00325   // Notify all other threads that may be waiting, that the global
00326   // gestalt has been initialized.
00327   is_ubergestalt_ready = true;
00328   ACE_MT (if (TAO_Ubergestalt_Ready_Condition::instance ()->
00329               broadcast () == -1)
00330             return -1);
00331 
00332   return 0;
00333 }
00334 
00335 
00336 
00337 int
00338 TAO::ORB::open_services (ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> pcfg,
00339                          int &argc,
00340                          ACE_TCHAR **argv)
00341 {
00342   {
00343     ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00344                               guard,
00345                               TAO_Ubergestalt_Ready_Condition::instance ()->mutex (),
00346                               -1));
00347 
00348     // Wait in line, while the default ORB (which isn't us) completes
00349     // initialization of the globaly required service objects
00350     if (service_open_count == 1)
00351       {
00352         if (TAO_debug_level > 4)
00353           ACE_DEBUG ((LM_DEBUG,
00354                       ACE_TEXT ("TAO (%P|%t) Waiting for the default ")
00355                       ACE_TEXT ("ORB to complete the global ")
00356                       ACE_TEXT ("initialization\n")));
00357 
00358         ACE_MT (while (!is_ubergestalt_ready)
00359                 TAO_Ubergestalt_Ready_Condition::instance ()->wait ());
00360 
00361         if (TAO_debug_level > 4)
00362           ACE_DEBUG ((LM_DEBUG,
00363                       ACE_TEXT ("TAO (%P|%t) The default ")
00364                       ACE_TEXT ("ORB must have completed the global ")
00365                       ACE_TEXT ("initialization...\n")));
00366 
00367       }
00368     else
00369       {
00370         if (TAO_debug_level > 4)
00371           ACE_DEBUG ((LM_DEBUG,
00372                       ACE_TEXT ("TAO (%P|%t) We are %sthe default ")
00373                       ACE_TEXT ("ORB ...\n"),
00374                       (service_open_count == 0) ? "" : "not "));
00375       }
00376 
00377     ++service_open_count;
00378   }
00379 
00380   // Construct an argument vector specific to the Service
00381   // Configurator.
00382   // Be certain to copy the program name so that service configurator
00383   // has something to skip!
00384   ACE_ARGV svc_config_argv (true);  // only this ctor allows subsequent use of add()!
00385   svc_config_argv.add ((argc <= 0 || argv == 0) ? ACE_TEXT ("") : argv[0]);
00386 
00387   // Should we skip the ACE_Service_Config::open() method?,
00388   // e.g., because of -ORBSkipServiceConfigOpen
00389   bool skip_service_config_open = false;
00390 
00391   // Extract any ORB options from the argument vector.
00392   if (parse_private_args_i (argc,
00393                             argv,
00394                             svc_config_argv,
00395                             skip_service_config_open) == -1)
00396     {
00397       return -1;
00398     }
00399 
00400   // Construct an argument vector specific to the process-wide
00401   // (global) Service Configurator instance.
00402   ACE_ARGV global_svc_config_argv;
00403 
00404   // Parse any globally applicable arguments, but do not make them effective.
00405   // We are effectively purging the command line from them without affecting
00406   // the global state - after all, it may be a private (local) configuration context.
00407   int status = parse_global_args_i(argc, argv, global_svc_config_argv, false);
00408 
00409   if (status == -1 && TAO_debug_level > 0)
00410         ACE_DEBUG ((LM_DEBUG,
00411                     ACE_TEXT ("TAO (%P|%t) Skipping the process-wide ")
00412                     ACE_TEXT ("service configuration, service_open_count ")
00413                     ACE_TEXT ("= %d, status = %d\n"),
00414                     service_open_count,
00415                     status));
00416 
00417   if (TAO_debug_level > 2)
00418       ACE_DEBUG ((LM_DEBUG,
00419                   ACE_TEXT ("TAO (%P|%t) Initializing the ")
00420                   ACE_TEXT ("orb-specific services\n")));
00421 
00422   if (parse_svcconf_args_i (argc, argv, svc_config_argv) == -1)
00423       return -1;
00424   // 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.
00425   // only open the private context if it is not also the global context
00426   if (pcfg != ACE_Service_Config::global())
00427     {
00428       int svc_config_argc = svc_config_argv.argc ();
00429       status =
00430         open_private_services_i (pcfg,
00431                                  svc_config_argc,
00432                                  svc_config_argv.argv (),
00433                                  skip_service_config_open);
00434     }
00435 
00436   if (status < 0 && TAO_debug_level > 0)
00437     {
00438       ACE_ERROR_RETURN ((LM_DEBUG,
00439                          ACE_TEXT ("TAO (%P|%t) Failed to ")
00440                          ACE_TEXT ("open orb service configuration\n")),
00441                         -1);
00442     }
00443 
00444   return status;
00445 }
00446 
00447 int
00448 TAO::ORB::close_services (ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> pcfg)
00449 {
00450   ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00451                             guard,
00452                             *ACE_Static_Object_Lock::instance (),
00453                             -1));
00454   --service_open_count;
00455 
00456   if (pcfg == ACE_Service_Config::global())
00457     return 0;
00458 
00459   return pcfg->close ();
00460 }
00461 
00462 void
00463 TAO::ORB::default_svc_conf_entries (char const * rf_args,
00464                                     char const * ssf_args,
00465                                     char const * csf_args)
00466 {
00467   resource_factory_args        = rf_args;
00468   server_strategy_factory_args = ssf_args;
00469   client_strategy_factory_args = csf_args;
00470 }
00471 
00472 TAO_END_VERSIONED_NAMESPACE_DECL
00473 
00474 // -----------------------------------------------------
00475 namespace
00476 {
00477   /// Open services, belonging to the gestalt instance.
00478 
00479   int
00480   open_private_services_i (ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> pcfg,
00481                            int & argc,
00482                            ACE_TCHAR ** argv,
00483                            bool skip_service_config_open,
00484                            bool ignore_default_svc_conf_file)
00485   {
00486 
00487     if (skip_service_config_open)
00488       {
00489         return 0;
00490       }
00491 
00492 #if defined (TAO_PLATFORM_SVC_CONF_FILE_NOTSUP)
00493     ignore_default_svc_conf_file = true;
00494 #endif /* TAO_PLATFORM_SVC_CONF_FILE_NOTSUP */
00495 
00496     // Copy command line parameter to allow conversion
00497     ACE_Argv_Type_Converter command_line (argc, argv);
00498 
00499     return pcfg->open (command_line.get_argc (),
00500                        command_line.get_TCHAR_argv (),
00501                        ACE_DEFAULT_LOGGER_KEY,
00502                        0, // Don't ignore static services.
00503                        ignore_default_svc_conf_file);
00504   }
00505 
00506   /// @brief registers all process-wide (global) services, available
00507   /// to all ORBs
00508   void
00509   register_global_services_i (ACE_Service_Gestalt * pcfg)
00510   {
00511     // This has to be done before intializing the resource
00512     // factory. Codesets is a special library since its configuration
00513     // is optional and it may be linked statically.
00514     if (negotiate_codesets)
00515       {
00516         TAO_Codeset_Manager_Factory_Base *factory =
00517           ACE_Dynamic_Service<TAO_Codeset_Manager_Factory_Base>::instance (
00518             "TAO_Codeset");
00519 
00520         if (factory == 0 || factory->is_default ())
00521           {
00522 #if !defined (TAO_AS_STATIC_LIBS) && !(defined (ACE_VXWORKS) && !defined (__RTP__))
00523             // only for dynamic libs, check to see if default factory
00524             // and if so, remove it
00525             ACE_Service_Config::process_directive (
00526               ACE_REMOVE_SERVICE_DIRECTIVE ("TAO_Codeset"));
00527 
00528             ACE_Service_Config::process_directive (
00529               ACE_DYNAMIC_SERVICE_DIRECTIVE (
00530                 "TAO_Codeset",
00531                 "TAO_Codeset",
00532                 "_make_TAO_Codeset_Manager_Factory",
00533                 ""));
00534 
00535             factory =
00536               ACE_Dynamic_Service<
00537                   TAO_Codeset_Manager_Factory_Base
00538                 >::instance ("TAO_Codeset");
00539 #endif
00540           }
00541 
00542         if (factory == 0)
00543           {
00544             if (TAO_debug_level > 0)
00545               {
00546                 ACE_ERROR ((LM_ERROR,
00547                             ACE_TEXT ("(%P|%t) ORB_Core: ")
00548                             ACE_TEXT ("Unable to initialize ")
00549                             ACE_TEXT ("Codeset Manager\n")));
00550               }
00551           }
00552       }
00553 
00554     pcfg->process_directive (
00555       ace_svc_desc_TAO_Default_Resource_Factory);
00556     pcfg->process_directive (
00557       ace_svc_desc_TAO_Default_Client_Strategy_Factory);
00558     pcfg->process_directive (
00559       ace_svc_desc_TAO_Default_Server_Strategy_Factory);
00560 
00561     // Configure the IIOP factory. You do *NOT* need modify this
00562     // code to add your own protocol, instead simply add the
00563     // following to your svc.conf file:
00564     //
00565     // dynamic PN_Factory Service_Object * LIB:_make_PN_Protocol_Factory() ""
00566     // static Resource_Factory "-ORBProtocolFactory PN_Factory"
00567     //
00568     // where PN is the name of your protocol and LIB is the base
00569     // name of the shared library that implements the protocol.
00570 
00571 #if defined (TAO_HAS_IIOP) && (TAO_HAS_IIOP != 0)
00572     pcfg->process_directive (ace_svc_desc_TAO_IIOP_Protocol_Factory);
00573 #endif /* TAO_HAS_IIOP && TAO_HAS_IIOP != 0 */
00574 
00575     // add descriptor to list of static objects.
00576 #if (TAO_HAS_MCAST_PARSER == 1)
00577     pcfg->process_directive (ace_svc_desc_TAO_MCAST_Parser);
00578 #endif /* TAO_HAS_MCAST_PARSER == 1 */
00579 #if (TAO_HAS_CORBANAME_PARSER == 1)
00580     pcfg->process_directive (ace_svc_desc_TAO_CORBANAME_Parser);
00581 #endif /* TAO_HAS_CORBANAME_PARSER == 1 */
00582 #if (TAO_HAS_CORBALOC_PARSER == 1)
00583     pcfg->process_directive (ace_svc_desc_TAO_CORBALOC_Parser);
00584 #endif /* TAO_HAS_CORBALOC_PARSER == 1 */
00585 #if (TAO_HAS_FILE_PARSER == 1)
00586     pcfg->process_directive (ace_svc_desc_TAO_FILE_Parser);
00587 #endif /* TAO_HAS_FILE_PARSER == 1 */
00588 #if (TAO_HAS_DDL_PARSER == 1)
00589     pcfg->process_directive (ace_svc_desc_TAO_DLL_Parser);
00590 #endif /* TAO_HAS_DDL_PARSER == 1 */
00591 #if (TAO_HAS_HTTP_PARSER == 1)
00592     pcfg->process_directive (ace_svc_desc_TAO_HTTP_Parser);
00593 #endif /* TAO_HAS_HTTP_PARSER */
00594     pcfg->process_directive (ace_svc_desc_TAO_Default_Stub_Factory);
00595     pcfg->process_directive (
00596       ace_svc_desc_TAO_Default_Endpoint_Selector_Factory);
00597     pcfg->process_directive (
00598       ace_svc_desc_TAO_Default_Thread_Lane_Resources_Manager_Factory);
00599     pcfg->process_directive (ace_svc_desc_TAO_Default_Collocation_Resolver);
00600 
00601   } /* register_global_services_i */
00602 
00603   void
00604   register_additional_services_i (ACE_Service_Gestalt * pcfg)
00605   {
00606     // @@ What the heck do these things do and do we need to avoid
00607     //    calling them if we're not invoking the svc.conf file?
00608     // @@ They are needed for platforms that have no file system,
00609     //    like VxWorks.
00610 
00611     if (resource_factory_args != 0)
00612       {
00613         pcfg->process_directive(
00614           ACE_TEXT_CHAR_TO_TCHAR (resource_factory_args));
00615       }
00616 
00617     if (client_strategy_factory_args != 0)
00618       {
00619         pcfg->process_directive
00620           (ACE_TEXT_CHAR_TO_TCHAR (client_strategy_factory_args));
00621       }
00622 
00623     if (server_strategy_factory_args != 0)
00624       {
00625         pcfg->process_directive
00626           (ACE_TEXT_CHAR_TO_TCHAR (server_strategy_factory_args));
00627       }
00628 
00629     ACE_Service_Object * const pi_server_loader =
00630       ACE_Dynamic_Service<ACE_Service_Object>::instance (
00631         pcfg,
00632         "PI_Server_Loader");
00633 
00634     if (pi_server_loader != 0)
00635       {
00636         pi_server_loader->init (0, 0);
00637       }
00638 
00639     ACE_Service_Object * const bidir_loader =
00640       ACE_Dynamic_Service<ACE_Service_Object>::instance (
00641         pcfg,
00642         "BiDirGIOP_Loader");
00643 
00644     if (bidir_loader != 0)
00645       {
00646         bidir_loader->init (0, 0);
00647       }
00648 
00649     ACE_Service_Object * const messaging_loader =
00650       ACE_Dynamic_Service<ACE_Service_Object>::instance (
00651         pcfg,
00652         "Messaging_Loader");
00653 
00654     if (messaging_loader != 0)
00655       {
00656         messaging_loader->init (0, 0);
00657       }
00658 
00659     // Handle RTCORBA library special case.  Since RTCORBA needs
00660     // its init method call to register several hooks, call it
00661     // here if it hasn't already been called.
00662     ACE_Service_Object * const rt_loader =
00663       ACE_Dynamic_Service<ACE_Service_Object>::instance (
00664         pcfg,
00665         "RT_ORB_Loader");
00666 
00667     if (rt_loader != 0)
00668       {
00669         rt_loader->init (0, 0);
00670       }
00671 
00672     ACE_Service_Object * const rtscheduler_loader =
00673       ACE_Dynamic_Service<ACE_Service_Object>::instance (
00674         pcfg,
00675         "RTScheduler_Loader");
00676 
00677     if (rtscheduler_loader != 0)
00678       {
00679         rtscheduler_loader->init (0, 0);
00680       }
00681 
00682     ACE_Service_Object * const csd_framework_loader =
00683       ACE_Dynamic_Service<ACE_Service_Object>::instance (
00684         pcfg,
00685         "CSD_Framework_Loader");
00686 
00687     if (csd_framework_loader != 0)
00688       {
00689         csd_framework_loader->init (0, 0);
00690       }
00691 
00692     ACE_Service_Object * const endpoint_policy_loader =
00693       ACE_Dynamic_Service<ACE_Service_Object>::instance (
00694         pcfg,
00695         "EndpointPolicy_Initializer");
00696 
00697     if (endpoint_policy_loader != 0)
00698       {
00699         endpoint_policy_loader->init (0, 0);
00700       }
00701 
00702     ACE_Service_Object * const diffserv_policy_loader =
00703       ACE_Dynamic_Service<ACE_Service_Object>::instance (
00704         pcfg,
00705         "DiffservPolicy_Initializer");
00706 
00707     if (diffserv_policy_loader != 0)
00708       {
00709         diffserv_policy_loader->init (0, 0);
00710       }
00711   } /* register_additional_services_i */
00712 
00713   int
00714   parse_svcconf_args_i (int &argc,
00715                         ACE_TCHAR **argv,
00716                         ACE_ARGV &svc_config_argv)
00717   {
00718     // Extract the Service Configurator ORB options from the argument
00719     // vector.
00720     ACE_Arg_Shifter arg_shifter (argc, argv);
00721 
00722     while (arg_shifter.is_anything_left ())
00723       {
00724         // Can't interpret this argument.  Move on to the next argument.
00725         if (arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-ORBSvcConf")) == 0)
00726           {
00727             const ACE_TCHAR *current_arg =
00728                         arg_shifter.get_the_parameter (ACE_TEXT ("-ORBSvcConf"));
00729             arg_shifter.consume_arg ();
00730 
00731             // Proceeds only if the configuration file exists.
00732             FILE * const conf_file =
00733               ACE_OS::fopen (current_arg, ACE_TEXT ("r"));
00734             if (0 == conf_file)
00735               {
00736                 // Assigning EINVAL to errno to make an exception
00737                 // thrown.  calling code does not throw an exception if
00738                 // the errno is set to ENOENT for some reason.
00739                 errno = EINVAL;
00740 
00741                 ACE_ERROR_RETURN ((LM_ERROR,
00742                                    ACE_TEXT ("TAO (%P|%t) Unable to open file %s")
00743                                    ACE_TEXT (", referenced by -ORBSvcConf option\n"),
00744                                    current_arg),
00745                                   -1);
00746               }
00747             else
00748               {
00749                 ACE_OS::fclose (conf_file);
00750               }
00751 
00752             svc_config_argv.add (ACE_TEXT ("-f"));
00753             svc_config_argv.add (current_arg);
00754           }
00755         else
00756           {
00757             // Any arguments that don't match are ignored so that the
00758             // caller can still use them.
00759             arg_shifter.ignore_arg ();
00760           }
00761       }
00762 
00763     return 0;
00764   } /* parse_svcconf_args_i */
00765 
00766   int
00767   parse_private_args_i (int &argc,
00768                         ACE_TCHAR **argv,
00769                         ACE_ARGV &svc_config_argv,
00770                         bool & skip_service_config_open)
00771   {
00772     // Extract the Service Configurator ORB options from the argument
00773     // vector.
00774     ACE_Arg_Shifter arg_shifter (argc, argv);
00775 
00776     while (arg_shifter.is_anything_left ())
00777       {
00778         const ACE_TCHAR *current_arg = 0;
00779         if (0 == arg_shifter.cur_arg_strncasecmp
00780             (ACE_TEXT ("-ORBSkipServiceConfigOpen")))
00781           {
00782             skip_service_config_open = true;
00783 
00784             arg_shifter.consume_arg ();
00785           }
00786         else if (0 != (current_arg = arg_shifter.get_the_parameter
00787                        (ACE_TEXT ("-ORBSvcConfDirective"))))
00788           {
00789             // This is used to pass arguments to the Service
00790             // Configurator using the "command line" to provide
00791             // configuration information rather than using a svc.conf
00792             // file.  Pass the "-S" to the service configurator.
00793             svc_config_argv.add (ACE_TEXT ("-S"));
00794             svc_config_argv.add (current_arg, true); // quote args!
00795 
00796             arg_shifter.consume_arg ();
00797           }
00798         else if (0 != (current_arg = arg_shifter.get_the_parameter
00799                        (ACE_TEXT ("-ORBServiceConfigLoggerKey"))))
00800           {
00801             svc_config_argv.add (ACE_TEXT ("-k"));
00802             svc_config_argv.add (current_arg, true); // quote args!
00803 
00804             arg_shifter.consume_arg ();
00805           }
00806         else if (0 == arg_shifter.cur_arg_strncasecmp
00807                        (ACE_TEXT ("-ORBNegotiateCodesets")))
00808           {
00809             // Negotiate codesets must be evaluated prior to calling
00810             // register_global_services_i.
00811 
00812             // Don't consume, the ORB_Core::init will use it again.
00813             arg_shifter.ignore_arg();
00814 
00815             if (0 != (current_arg = arg_shifter.get_current()))
00816               negotiate_codesets = (ACE_OS::atoi (current_arg));
00817 
00818             arg_shifter.ignore_arg();
00819           }
00820         else if (0 != (current_arg =
00821                        arg_shifter.get_the_parameter
00822                        (ACE_TEXT ("-ORBDebugLevel"))))
00823           {
00824             // Allowing different ORBs to change the global debug
00825             // level may be unexpected, but since this
00826             TAO_debug_level = ACE_OS::atoi (current_arg);
00827 
00828             arg_shifter.consume_arg ();
00829           }
00830         else
00831           {
00832             // Can't interpret this argument.  Move on to the next
00833             // argument.  Any arguments that don't match are ignored
00834             // so that the caller can still use them.
00835             arg_shifter.ignore_arg ();
00836           }
00837       }
00838 
00839     return 0;
00840   } /* parse_private_args_i */
00841 
00842   int
00843   parse_global_args_i (int &argc,
00844                        ACE_TCHAR **argv,
00845                        ACE_ARGV &svc_config_argv,
00846                        bool apply_values)
00847   {
00848     // NOTE: When adding new global arguments, ensure they are only
00849     // applied when apply_values is true, but that they are always
00850     // consumed, if they need to be consumed.
00851 #if defined (TAO_DEBUG) && !defined (ACE_HAS_WINCE)
00852     // Make it a little easier to debug programs using this code.
00853     if (apply_values)
00854       {
00855         TAO_debug_level = ACE_Env_Value<u_int> ("TAO_ORB_DEBUG", 0);
00856 
00857         char * const value = ACE_OS::getenv ("TAO_ORB_DEBUG");
00858 
00859         if (value != 0)
00860           {
00861             TAO_debug_level = ACE_OS::atoi (value);
00862 
00863             if (TAO_debug_level <= 0)
00864               {
00865                 TAO_debug_level = 1;
00866               }
00867 
00868             ACE_DEBUG ((LM_DEBUG,
00869                         ACE_TEXT ("TAO_debug_level == %d\n"),
00870                         TAO_debug_level));
00871           }
00872       }
00873 #endif  /* TAO_DEBUG && !ACE_HAS_WINCE */
00874 
00875     // Extract the Service Configurator ORB options from the argument
00876     // vector.
00877     ACE_Arg_Shifter arg_shifter (argc, argv);
00878 
00879     while (arg_shifter.is_anything_left ())
00880       {
00881         if (0 == arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-ORBDebug")))
00882           {
00883             if (apply_values)
00884               {
00885                 // Later, replace all of these
00886                 // warning this turns on a daemon.
00887                 ACE::debug (1);
00888               }
00889 
00890             arg_shifter.consume_arg ();
00891           }
00892         else if (0 == arg_shifter.cur_arg_strncasecmp
00893                  (ACE_TEXT ("-ORBDaemon")))
00894           {
00895             // Be a daemon.
00896             if (apply_values)
00897               {
00898                 svc_config_argv.add (ACE_TEXT("-b"));
00899               }
00900 
00901             arg_shifter.consume_arg ();
00902           }
00903         // Can't interpret this argument.
00904         // Move on to the next argument.
00905         else
00906           {
00907             // Any arguments that don't match are ignored so
00908             // that the caller can still use them.
00909             arg_shifter.ignore_arg ();
00910           }
00911       }
00912     return 0;
00913   } /* parse_global_args_i */
00914 } // anonymous namespace.

Generated on Tue Feb 2 17:37:53 2010 for TAO by  doxygen 1.4.7