Functions

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

{
  ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
                            guard,
                            *ACE_Static_Object_Lock::instance (),
                            -1));
  --service_open_count;

  int result = 0;

  if (pcfg != ACE_Service_Config::global())
    {
      result = pcfg->close ();
    }

  return result;
}

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

{
  resource_factory_args        = rf_args;
  server_strategy_factory_args = ssf_args;
  client_strategy_factory_args = csf_args;
}

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

{
  {
    // Count of the number of (times we did this for all) ORBs.
    static int orb_init_count = 0;

    // Using ACE_Static_Object_Lock::instance() precludes ORB_init()
    // from being called within a static object CTOR.
    ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
            guard,
            *ACE_Static_Object_Lock::instance (),
            -1));

    // Make sure TAO's singleton manager is initialized.
    // We need to initialize before TAO_default_environment() is called
    // since that call instantiates a TAO_TSS_Singleton.
    if (TAO_Singleton_Manager::instance ()->init () == -1)
      return -1;

    // Prevent multiple initializations.
    if (++orb_init_count > 1)
      return 0;
  }

  // Prevent any other thread from going through ORB initialization before the
  // uber-gestalt is initialized.
  ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
          guard,
          TAO_Ubergestalt_Ready_Condition::instance ()->mutex (),
          -1));

  if (TAO_debug_level > 2)
    {
      ACE_DEBUG ((LM_DEBUG,
      ACE_TEXT ("TAO (%P|%t) Initializing the ")
      ACE_TEXT ("process-wide service context\n")));
    }

  ACE_Service_Gestalt* theone = ACE_Service_Config::global ();
  ACE_Service_Config_Guard auto_config_guard (theone);

  // Construct an argument vector specific to the process-wide
  // (global) Service Configurator instance.
  // Be certain to copy the program name so that service configurator
  // has something to skip!
  ACE_ARGV global_svc_config_argv (true); // only this ctor allows
  // subsequent use of add()!
  global_svc_config_argv.add ((argc <= 0 || argv == 0) ?
            ACE_TEXT ("") : argv[0], true);

  // Will expand the environment variables, if any were used.
  // Is this a good thing? I guess it provides greater flexibility
  // for deployment,so let's leave it. Will also quote arguments.
  ACE_ARGV copyargv (argc, argv, true, true);

  // Adjust to proper type
  int tmpargc = argc;
  ACE_Argv_Type_Converter cvtargv (tmpargc, copyargv.argv());

  tmpargc = cvtargv.get_argc ();
  ACE_TCHAR **tmpargv = cvtargv.get_TCHAR_argv ();

  // Collect global SC parameters. True means "immediately
  // apply global setting" like debug flag, etc.
  if (parse_global_args_i (tmpargc,
         tmpargv,
         global_svc_config_argv,
         true) == -1)
    return -1;

  bool skip_service_config_open = false; // by default we shouldn't

  if (using_global_gestalt_i (tmpargc,
                              tmpargv,
                              skip_service_config_open))
    {
      if (parse_svcconf_args_i (tmpargc,
              tmpargv,
              global_svc_config_argv) == -1)
        return -1;
    }

  bool ignore_default_svc_conf_file = false;

  if (parse_private_args_i (tmpargc,
          tmpargv,
          global_svc_config_argv,
          skip_service_config_open,
          ignore_default_svc_conf_file) == -1)
    return -1;

  // register_global_services_i depends on the parsing of at least the
  // -ORBNegotiateCodesets option, and must be invoked after all the
  // parsing methods, but still must preceed the opening of other services.

  register_global_services_i (theone);

  // Perform the open magic (unless SC::open() has been called already)
  int global_svc_config_argc = global_svc_config_argv.argc ();
  int status = open_private_services_i (theone,
                                        global_svc_config_argc,
                                        global_svc_config_argv.argv (),
                                        skip_service_config_open,
                                        ignore_default_svc_conf_file);

  // okay?
  if (status == -1)
    {
      if (errno != ENOENT)
        {
          if (TAO_debug_level > 0)
            {
              ACE_ERROR ((LM_ERROR,
                          ACE_TEXT ("TAO (%P|%t) - Failed to open process-")
                          ACE_TEXT ("wide service configuration context\n")));
            }
          return -1;
        }
      else
        {
          if (TAO_debug_level > 4)
            ACE_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("TAO (%P|%t) - Did not find default ")
                        ACE_TEXT ("svc.conf\n")));
          status = 0;
        }
    }

  if (status > 0)
    {
      // one or more directives failed, but we don't know which
      if (TAO_debug_level > 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO (%P|%t) - process-wide service ")
                      ACE_TEXT ("configuration context had %d failed ")
                      ACE_TEXT ("directives\n"), status));
        }          
    }

  if (TAO_debug_level > 2)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("TAO (%P|%t) - Completed initializing the ")
                ACE_TEXT ("process-wide service context\n")));

  if (TAO_debug_level > 4)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("TAO (%P|%t) - Default ORB services initialization begins\n")));

  // Load more ORB-related services
  register_additional_services_i (theone);

  if (TAO_debug_level > 4)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("TAO (%P|%t) - Default ORB services initialization completed\n")));

  // Notify all other threads that may be waiting, that the global
  // gestalt has been initialized.
  is_ubergestalt_ready = true;
  ACE_MT (if (TAO_Ubergestalt_Ready_Condition::instance ()->
              broadcast () == -1)
            return -1);

  return 0;
}

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

{
  {
    ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
                              guard,
                              TAO_Ubergestalt_Ready_Condition::instance ()->mutex (),
                              -1));

    // Wait in line, while the default ORB (which isn't us) completes
    // initialization of the globaly required service objects
    if (service_open_count == 1)
      {
        if (TAO_debug_level > 4)
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO (%P|%t) - Waiting for the default ")
                      ACE_TEXT ("ORB to complete the global ")
                      ACE_TEXT ("initialization\n")));

      ACE_MT (while (!is_ubergestalt_ready)
      TAO_Ubergestalt_Ready_Condition::instance ()->wait ());

        if (TAO_debug_level > 4)
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO (%P|%t) - The default ")
                      ACE_TEXT ("ORB must have completed the global ")
                      ACE_TEXT ("initialization...\n")));

      }
    else
      {
        if (TAO_debug_level > 4)
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO (%P|%t) - We are%Cthe default ")
                      ACE_TEXT ("ORB ...\n"),
                      (service_open_count == 0) ? " " : " not "));
      }

    ++service_open_count;
  }

  // Construct an argument vector specific to the Service Configurator.
  // Be certain to copy the program name so that service configurator
  // has something to skip!
  ACE_ARGV svc_config_argv (true);  // only this ctor allows subsequent
                                    // use of add()!
  svc_config_argv.add ((argc <= 0 || argv == 0) ? ACE_TEXT ("") : argv[0],
                       true);

  // Should we skip the ACE_Service_Config::open() method?,
  // e.g., because of -ORBSkipServiceConfigOpen
  bool skip_service_config_open = false;
  bool ignore_default_svc_conf_file = false;

  // Extract any ORB options from the argument vector.
  if (parse_private_args_i (argc,
                            argv,
                            svc_config_argv,
                            skip_service_config_open,
                            ignore_default_svc_conf_file) == -1)
    {
      return -1;
    }

  // Construct an argument vector specific to the process-wide
  // (global) Service Configurator instance.
  ACE_ARGV global_svc_config_argv;

  // Parse any globally applicable arguments, but do not make them effective.
  // We are effectively purging the command line from them without affecting
  // the global state - after all, it may be a private (local) configuration
  // context.
  int status = parse_global_args_i(argc, argv, global_svc_config_argv, false);

  if (status == -1 && TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG,
    ACE_TEXT ("TAO (%P|%t) - Skipping the process-wide ")
    ACE_TEXT ("service configuration, service_open_count ")
    ACE_TEXT ("= %d, status = %d\n"),
    service_open_count,
    status));

  if (TAO_debug_level > 2)
    ACE_DEBUG ((LM_DEBUG,
    ACE_TEXT ("TAO (%P|%t) - Initializing the ")
    ACE_TEXT ("orb-specific services\n")));

  if (parse_svcconf_args_i (argc, argv, svc_config_argv) == -1)
    return -1;
  // 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.
  // only open the private context if it is not also the global context
  if (pcfg != ACE_Service_Config::global())
    {
      int svc_config_argc = svc_config_argv.argc ();
      status =
        open_private_services_i (pcfg,
                                 svc_config_argc,
                                 svc_config_argv.argv (),
                                 skip_service_config_open,
                                 ignore_default_svc_conf_file);
    }

  if (status == -1)
    {
      if (errno != ENOENT)
        {
          if (TAO_debug_level > 0)
            ACE_ERROR ((LM_ERROR,
                        ACE_TEXT ("TAO (%P|%t) - Failed to open ORB-specific ")
                        ACE_TEXT ("service configuration\n")));
          return -1;
        }
      else
        {
          if (TAO_debug_level > 4)
            ACE_DEBUG ((LM_DEBUG,
                        ACE_TEXT ("TAO (%P|%t) - Did not find default ")
                        ACE_TEXT ("svc.conf\n")));
          status = 0;
        }
    }

  if (status > 0)
    {
      // one or more directives failed, but we don't know which
      if (TAO_debug_level > 0)
        {
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("TAO (%P|%t) - ORB-specific service ")
                      ACE_TEXT ("configuration context had %d failed ")
                      ACE_TEXT ("directives\n"), status));
        }          
    }


  return status;
}

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines