TAO::ORB Namespace Reference

Functions

int open_global_services (int argc, ACE_TCHAR **argv)
 Note that the argument vector will be corrupted upon return.
int open_services (ACE_Intrusive_Auto_Ptr< ACE_Service_Gestalt > cfg, int &argc, ACE_TCHAR **argv)
int close_services (ACE_Intrusive_Auto_Ptr< ACE_Service_Gestalt > pcfg)
void default_svc_conf_entries (char const *rf_args, char const *ssf_args, char const *csf_args)

Function Documentation

int TAO::ORB::close_services ( ACE_Intrusive_Auto_Ptr< ACE_Service_Gestalt pcfg  ) 

The complement to open_services(), this will perform appropriate ACE Service Configurator closure operations. It should be called as many times as open_services(), and will only actually close things down on the last call. It is fully thread-safe.

Returns:
0 if successful, -1 with errno set if failure.

Definition at line 450 of file TAO_Internal.cpp.

00451 {
00452   ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00453                             guard,
00454                             *ACE_Static_Object_Lock::instance (),
00455                             -1));
00456   --service_open_count;
00457 
00458   int result = 0;
00459 
00460   if (pcfg != ACE_Service_Config::global())
00461     {
00462       result = pcfg->close ();
00463     }
00464 
00465   return result;
00466 }

void TAO::ORB::default_svc_conf_entries ( char const *  rf_args,
char const *  ssf_args,
char const *  csf_args 
)

Set default `svc.conf' content. This function must be called before first ORB initialization.

Definition at line 469 of file TAO_Internal.cpp.

00472 {
00473   resource_factory_args        = rf_args;
00474   server_strategy_factory_args = ssf_args;
00475   client_strategy_factory_args = csf_args;
00476 }

int TAO::ORB::open_global_services ( int  argc,
ACE_TCHAR **  argv 
)

Note that the argument vector will be corrupted upon return.

If never done it before, extract ACE Service Configurator arguments from the given argument vector, and initialize the _global_ configuration gestalt. Return value 0 means OK, -1 spells major trouble ...

Definition at line 201 of file TAO_Internal.cpp.

00202 {
00203   {
00204     // Count of the number of (times we did this for all) ORBs.
00205     static int orb_init_count = 0;
00206 
00207     // Using ACE_Static_Object_Lock::instance() precludes ORB_init()
00208     // from being called within a static object CTOR.
00209     ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00210             guard,
00211             *ACE_Static_Object_Lock::instance (),
00212             -1));
00213 
00214     // Make sure TAO's singleton manager is initialized.
00215     // We need to initialize before TAO_default_environment() is called
00216     // since that call instantiates a TAO_TSS_Singleton.
00217     if (TAO_Singleton_Manager::instance ()->init () == -1)
00218       return -1;
00219 
00220     // Prevent multiple initializations.
00221     if (++orb_init_count > 1)
00222       return 0;
00223   }
00224 
00225   // Prevent any other thread from going through ORB initialization before the
00226   // uber-gestalt is initialized.
00227   ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00228           guard,
00229           TAO_Ubergestalt_Ready_Condition::instance ()->mutex (),
00230           -1));
00231 
00232   if (TAO_debug_level > 2)
00233     {
00234       ACE_DEBUG ((LM_DEBUG,
00235       ACE_TEXT ("TAO (%P|%t) Initializing the ")
00236       ACE_TEXT ("process-wide service context\n")));
00237     }
00238 
00239   ACE_Service_Gestalt* theone = ACE_Service_Config::global ();
00240   ACE_Service_Config_Guard auto_config_guard (theone);
00241 
00242   // Construct an argument vector specific to the process-wide
00243   // (global) Service Configurator instance.
00244   // Be certain to copy the program name so that service configurator
00245   // has something to skip!
00246   ACE_ARGV global_svc_config_argv (true); // only this ctor allows
00247   // subsequent use of add()!
00248   global_svc_config_argv.add ((argc <= 0 || argv == 0) ?
00249             ACE_TEXT ("") : argv[0], true);
00250 
00251   // Will expand the environment variables, if any were used.
00252   // Is this a good thing? I guess it provides greater flexibility
00253   // for deployment,so let's leave it. Will also quote arguments.
00254 
00255   ACE_ARGV copyargv (argc, argv, true, true);
00256 
00257   // Adjust to proper type
00258   int tmpargc = argc;
00259   ACE_Argv_Type_Converter cvtargv (tmpargc, copyargv.argv());
00260 
00261   tmpargc = cvtargv.get_argc ();
00262   ACE_TCHAR **tmpargv = cvtargv.get_TCHAR_argv ();
00263 
00264   // Collect global SC parameters. True means "immediately
00265   // apply global setting" like debug flag, etc.
00266   if (parse_global_args_i (tmpargc,
00267          tmpargv,
00268          global_svc_config_argv,
00269          true) == -1)
00270     return -1;
00271 
00272   bool skip_service_config_open = false; // by default we shouldn't
00273 
00274   if (parse_svcconf_args_i (tmpargc,
00275           tmpargv,
00276           global_svc_config_argv) == -1)
00277     return -1;
00278 
00279   if (parse_private_args_i (tmpargc,
00280           tmpargv,
00281           global_svc_config_argv,
00282           skip_service_config_open) == -1)
00283     return -1;
00284 
00285   // register_global_services_i depends on the parsing of at least the
00286   // -ORBNegotiateCodesets option, and must be invoked after all the
00287   // parsing methods, but still must preceed the opening of other services.
00288 
00289   register_global_services_i (theone);
00290 
00291   // Perform the open magic (unless SC::open() has been called already)
00292   int global_svc_config_argc = global_svc_config_argv.argc ();
00293   int status = open_private_services_i (theone,
00294                                         global_svc_config_argc,
00295                                         global_svc_config_argv.argv (),
00296                                         skip_service_config_open);
00297 
00298   // okay?
00299   if (status == -1)
00300     {
00301       if (TAO_debug_level > 0)
00302         {
00303           ACE_ERROR ((LM_ERROR,
00304                       ACE_TEXT ("TAO (%P|%t) - Failed to open process-")
00305                       ACE_TEXT ("wide service configuration context\n")));
00306         }
00307 
00308       return -1;
00309     }
00310 
00311   if (TAO_debug_level > 2)
00312     ACE_DEBUG ((LM_DEBUG,
00313                 ACE_TEXT ("TAO (%P|%t) - Completed initializing the ")
00314                 ACE_TEXT ("process-wide service context\n")));
00315 
00316   if (TAO_debug_level > 4)
00317     ACE_DEBUG ((LM_DEBUG,
00318                 ACE_TEXT ("TAO (%P|%t) - Default ORB services initialization begins\n")));
00319 
00320   // Load more ORB-related services
00321   register_additional_services_i (theone);
00322 
00323   if (TAO_debug_level > 4)
00324     ACE_DEBUG ((LM_DEBUG,
00325                 ACE_TEXT ("TAO (%P|%t) - Default ORB services initialization completed\n")));
00326 
00327   // Notify all other threads that may be waiting, that the global
00328   // gestalt has been initialized.
00329   is_ubergestalt_ready = true;
00330   ACE_MT (if (TAO_Ubergestalt_Ready_Condition::instance ()->
00331               broadcast () == -1)
00332             return -1);
00333 
00334   return 0;
00335 }

int TAO::ORB::open_services ( ACE_Intrusive_Auto_Ptr< ACE_Service_Gestalt cfg,
int &  argc,
ACE_TCHAR **  argv 
)

Extract ACE Service Configurator arguments from the given argument vector, and initialize the ACE Service Configurator.

Note:
This method should be called before the ORB Core is initialized, and before any ORBInitializers are invoked.

Definition at line 338 of file TAO_Internal.cpp.

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%Cthe 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 Configurator.
00381   // Be certain to copy the program name so that service configurator
00382   // has something to skip!
00383   ACE_ARGV svc_config_argv (true);  // only this ctor allows subsequent
00384                                     // use of add()!
00385   svc_config_argv.add ((argc <= 0 || argv == 0) ? ACE_TEXT ("") : argv[0],
00386                        true);
00387 
00388   // Should we skip the ACE_Service_Config::open() method?,
00389   // e.g., because of -ORBSkipServiceConfigOpen
00390   bool skip_service_config_open = false;
00391 
00392   // Extract any ORB options from the argument vector.
00393   if (parse_private_args_i (argc,
00394                             argv,
00395                             svc_config_argv,
00396                             skip_service_config_open) == -1)
00397     {
00398       return -1;
00399     }
00400 
00401   // Construct an argument vector specific to the process-wide
00402   // (global) Service Configurator instance.
00403   ACE_ARGV global_svc_config_argv;
00404 
00405   // Parse any globally applicable arguments, but do not make them effective.
00406   // We are effectively purging the command line from them without affecting
00407   // the global state - after all, it may be a private (local) configuration
00408   // context.
00409   int status = parse_global_args_i(argc, argv, global_svc_config_argv, false);
00410 
00411   if (status == -1 && TAO_debug_level > 0)
00412     ACE_DEBUG ((LM_DEBUG,
00413     ACE_TEXT ("TAO (%P|%t) - Skipping the process-wide ")
00414     ACE_TEXT ("service configuration, service_open_count ")
00415     ACE_TEXT ("= %d, status = %d\n"),
00416     service_open_count,
00417     status));
00418 
00419   if (TAO_debug_level > 2)
00420     ACE_DEBUG ((LM_DEBUG,
00421     ACE_TEXT ("TAO (%P|%t) - Initializing the ")
00422     ACE_TEXT ("orb-specific services\n")));
00423 
00424   if (parse_svcconf_args_i (argc, argv, svc_config_argv) == -1)
00425     return -1;
00426   // 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.
00427   // only open the private context if it is not also the global context
00428   if (pcfg != ACE_Service_Config::global())
00429     {
00430       int svc_config_argc = svc_config_argv.argc ();
00431       status =
00432         open_private_services_i (pcfg,
00433                                  svc_config_argc,
00434                                  svc_config_argv.argv (),
00435                                  skip_service_config_open);
00436     }
00437 
00438   if (status < 0 && TAO_debug_level > 0)
00439     {
00440       ACE_ERROR_RETURN ((LM_ERROR,
00441                          ACE_TEXT ("TAO (%P|%t) - Failed to ")
00442                          ACE_TEXT ("open orb service configuration\n")),
00443                         -1);
00444     }
00445 
00446   return status;
00447 }

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Sat Nov 21 23:31:33 2009 for TAO by  doxygen 1.6.1