TAO::ORB Namespace Reference


Functions

TAO_BEGIN_VERSIONED_NAMESPACE_DECL
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 > pcfg, 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::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 203 of file TAO_Internal.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_GUARD_RETURN, ACE_TEXT, ACE_ARGV_T< CHAR_TYPE >::add(), ACE_ARGV_T< CHAR_TYPE >::argc(), ACE_ARGV_T< CHAR_TYPE >::argv(), ACE_Service_Config::global(), init(), TAO_Singleton_Manager::instance(), is_ubergestalt_ready, LM_DEBUG, open_private_services_i(), parse_global_args_i(), parse_private_args_i(), parse_svcconf_args_i(), register_additional_services_i(), register_global_services_i(), TAO_debug_level, and TAO_SYNCH_RECURSIVE_MUTEX.

Referenced by CORBA::ORB_init().

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 }

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.

References ACE_DEBUG, ACE_ERROR_RETURN, ACE_GUARD_RETURN, ACE_TEXT, ACE_ARGV_T< CHAR_TYPE >::add(), ACE_ARGV_T< CHAR_TYPE >::argc(), ACE_ARGV_T< CHAR_TYPE >::argv(), ACE_Service_Config::global(), is_ubergestalt_ready, LM_DEBUG, open_private_services_i(), parse_global_args_i(), parse_private_args_i(), parse_svcconf_args_i(), service_open_count, TAO_debug_level, TAO_SYNCH_RECURSIVE_MUTEX, and wait().

Referenced by CORBA::ORB_init().

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 }

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 448 of file TAO_Internal.cpp.

References ACE_GUARD_RETURN, ACE_Service_Config::global(), service_open_count, and TAO_SYNCH_RECURSIVE_MUTEX.

Referenced by TAO_ORB_Core::~TAO_ORB_Core().

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 }

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 463 of file TAO_Internal.cpp.

References client_strategy_factory_args, resource_factory_args, and server_strategy_factory_args.

00466 {
00467   resource_factory_args        = rf_args;
00468   server_strategy_factory_args = ssf_args;
00469   client_strategy_factory_args = csf_args;
00470 }


Generated on Tue Feb 2 17:39:59 2010 for TAO by  doxygen 1.4.7