Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_Internal Class Reference

This class encapsulates some private behaviors and global data structures used internal to TAO. No application should EVER see this class. More...

#include <TAO_Internal.h>

List of all members.

Static Public Methods

int open_services (int &argc, ACE_TCHAR **argv)
 Extract ACE Service Configurator arguments from the given argument vector, and initialize the ACE Service Configurator. This method should be called before the ORB Core is initialized, and before any ORBInitializers are invoked. More...

int close_services (void)
void default_svc_conf_entries (const char *resource_factory_args, const char *server_strategy_factory_args, const char *client_strategy_factory_args)
 Set default `svc.conf' content. This call has no effect if This function must be called before first ORB initialization. More...


Private Methods

 TAO_Internal (void)
 Private constructor prevents this class from being instantiated. More...


Static Private Methods

int open_services_i (int &argc, char **argv, int ignore_default_svc_conf_file=0, int skip_service_config_open=0)

Static Private Attributes

int service_open_count_ = 0
 Number of times open_services() has been called. Incremented by open_services(), and decremented by close_services(). Access to this is protected via the
Parameters:
ACE_Static_Object_Lock. 
More...


const char * resource_factory_args_ = 0
const char * server_strategy_factory_args_ = 0
const char * client_strategy_factory_args_ = 0


Detailed Description

This class encapsulates some private behaviors and global data structures used internal to TAO. No application should EVER see this class.

Definition at line 34 of file TAO_Internal.h.


Constructor & Destructor Documentation

TAO_Internal::TAO_Internal void    [private]
 

Private constructor prevents this class from being instantiated.

Definition at line 317 of file TAO_Internal.cpp.

00318 {
00319 }


Member Function Documentation

int TAO_Internal::close_services void    [static]
 

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. Return 0 if successful, -1 with errno set if failure.

Definition at line 322 of file TAO_Internal.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_Static_Object_Lock::instance, service_open_count_, and TAO_SYNCH_RECURSIVE_MUTEX.

Referenced by TAO_ORB_Core::fini.

00323 {
00324   ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX, guard,
00325                             *ACE_Static_Object_Lock::instance (), -1));
00326   --service_open_count_;
00327   return 0;
00328 }

void TAO_Internal::default_svc_conf_entries const char *    resource_factory_args,
const char *    server_strategy_factory_args,
const char *    client_strategy_factory_args
[static]
 

Set default `svc.conf' content. This call has no effect if This function must be called before first ORB initialization.

Definition at line 223 of file TAO_Internal.cpp.

References client_strategy_factory_args_, resource_factory_args_, and server_strategy_factory_args_.

00226 {
00227   TAO_Internal::resource_factory_args_ = resource_factory_args;
00228   TAO_Internal::server_strategy_factory_args_ = server_strategy_factory_args;
00229   TAO_Internal::client_strategy_factory_args_ = client_strategy_factory_args;
00230 }

int TAO_Internal::open_services int &    argc,
ACE_TCHAR **    argv
[static]
 

Extract ACE Service Configurator arguments from the given argument vector, and initialize the ACE Service Configurator. This method should be called before the ORB Core is initialized, and before any ORBInitializers are invoked.

Definition at line 70 of file TAO_Internal.cpp.

References ACE_CString, ACE_DEBUG, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_TCHAR, ACE_TEXT, ACE_TEXT_ALWAYS_CHAR, ACE_OS::atoi, ACE_Arg_Shifter::consume_arg, ACE_Arg_Shifter::cur_arg_strncasecmp, ACE::debug, ACE_OS::fclose, ACE_OS::fopen, ACE_Arg_Shifter::get_the_parameter, ACE_OS::getenv, ACE_Arg_Shifter::ignore_arg, ACE_Arg_Shifter::is_anything_left, LM_DEBUG, LM_ERROR, open_services_i, and CORBA::string_dup.

00071 {
00072   // Construct an argument vector specific to the Service
00073   // Configurator.
00074   CORBA::StringSeq svc_config_argv;
00075 
00076   // Be certain to copy the program name so that service configurator
00077   // has something to skip!
00078   ACE_CString argv0 = "";
00079 
00080   if (argc > 0 && argv != 0)
00081     argv0 = ACE_TEXT_ALWAYS_CHAR(argv[0]);
00082 
00083   CORBA::ULong len = 0;
00084   svc_config_argv.length (1);
00085   svc_config_argv[0] = argv0.c_str ();
00086 
00087   // Should we skip the <ACE_Service_Config::open> method, e.g., if we
00088   // already being configured by the ACE Service Configurator.
00089   int skip_service_config_open = 0;
00090 
00091 #if defined (TAO_DEBUG) && !defined (ACE_HAS_WINCE)
00092   // Make it a little easier to debug programs using this code.
00093   {
00094     TAO_debug_level = ACE_Env_Value<u_int> ("TAO_ORB_DEBUG", 0);
00095 
00096     char *value = ACE_OS::getenv ("TAO_ORB_DEBUG");
00097 
00098     if (value != 0)
00099       {
00100         TAO_debug_level = ACE_OS::atoi (value);
00101         if (TAO_debug_level <= 0)
00102           TAO_debug_level = 1;
00103         ACE_DEBUG ((LM_DEBUG,
00104                     ACE_TEXT ("TAO_debug_level == %d"), TAO_debug_level));
00105       }
00106   }
00107 #endif  /* TAO_DEBUG && !ACE_HAS_WINCE */
00108 
00109   // Extract the Service Configurator ORB options from the argument
00110   // vector.
00111   ACE_Arg_Shifter arg_shifter (argc, argv);
00112 
00113   while (arg_shifter.is_anything_left ())
00114     {
00115       const ACE_TCHAR *current_arg = 0;
00116 
00117       // Start with the parameterless flags.
00118       if (arg_shifter.cur_arg_strncasecmp
00119           (ACE_LIB_TEXT("-ORBSkipServiceConfigOpen")) == 0)
00120         {
00121           skip_service_config_open = 1;
00122 
00123           arg_shifter.consume_arg ();
00124         }
00125       else if (arg_shifter.cur_arg_strncasecmp (ACE_LIB_TEXT("-ORBDebug")) == 0)
00126         {
00127           // later, replace all of these
00128           // warning this turns on a daemon
00129           ACE::debug (1);
00130           arg_shifter.consume_arg ();
00131         }
00132       else if ((current_arg = arg_shifter.get_the_parameter
00133                 (ACE_LIB_TEXT("-ORBDebugLevel"))))
00134         {
00135           TAO_debug_level =
00136             ACE_OS::atoi (current_arg);
00137 
00138           arg_shifter.consume_arg ();
00139         }
00140       else if (arg_shifter.cur_arg_strncasecmp (ACE_LIB_TEXT("-ORBDaemon")) == 0)
00141         {
00142           // Be a daemon
00143 
00144           len = svc_config_argv.length ();
00145           svc_config_argv.length (len + 1);
00146 
00147           svc_config_argv[len] = CORBA::string_dup ("-b");
00148 
00149           arg_shifter.consume_arg ();
00150         }
00151       // Continue with flags that accept parameters.
00152       else if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-ORBSvcConfDirective"))))
00153         {
00154           len = svc_config_argv.length ();
00155           svc_config_argv.length (len + 2);  // 2 arguments to add
00156 
00157           // This is used to pass arguments to the Service
00158           // Configurator using the "command line" to provide
00159           // configuration information rather than using a svc.conf
00160           // file.  Pass the "-S" to the service configurator.
00161           svc_config_argv[len] = CORBA::string_dup ("-S");
00162           svc_config_argv[len + 1] = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(current_arg));
00163 
00164           arg_shifter.consume_arg ();
00165         }
00166       else if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-ORBSvcConf"))))
00167         {
00168           // Specify the name of the svc.conf file to be used.
00169 
00170           // Proceeds only if the configuration file exists.
00171           FILE *conf_file = ACE_OS::fopen (current_arg, ACE_LIB_TEXT("r"));
00172           if (conf_file == 0)
00173             {
00174               // Assigning EINVAL to errno to make an exception
00175               // thrown.  calling code does not throw an exception if
00176               // the errno is set to ENOENT for some reason.
00177               errno = EINVAL;
00178 
00179               ACE_ERROR_RETURN ((LM_ERROR,
00180                                  ACE_TEXT ("TAO (%P|%t) Service Configurator ")
00181                                  ACE_TEXT ("unable to open file %s\n"),
00182                                            current_arg),
00183                                 -1);
00184 
00185             }
00186           else
00187             ACE_OS::fclose (conf_file);
00188 
00189           len = svc_config_argv.length ();
00190           svc_config_argv.length (len + 2);  // 2 arguments to add
00191 
00192           svc_config_argv[len] = CORBA::string_dup ("-f");
00193           svc_config_argv[len + 1] = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(current_arg));
00194 
00195           arg_shifter.consume_arg();
00196         }
00197       else if ((current_arg = arg_shifter.get_the_parameter (ACE_LIB_TEXT("-ORBServiceConfigLoggerKey"))))
00198         {
00199           len = svc_config_argv.length ();
00200           svc_config_argv.length (len + 2);  // 2 arguments to add
00201 
00202           svc_config_argv[len] = CORBA::string_dup ("-k");
00203           svc_config_argv[len + 1] = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(current_arg));
00204 
00205           arg_shifter.consume_arg ();
00206         }
00207       // Can't interpret this argument.  Move on to the next argument.
00208       else
00209         // Any arguments that don't match are ignored so that the
00210         // caller can still use them.
00211         arg_shifter.ignore_arg ();
00212     }
00213 
00214   int svc_config_argc = svc_config_argv.length ();
00215   return TAO_Internal::open_services_i (svc_config_argc,
00216                                         svc_config_argv.get_buffer (),
00217                                         0,  // @@ What about this argument?
00218                                         skip_service_config_open);
00219 }

int TAO_Internal::open_services_i int &    argc,
char **    argv,
int    ignore_default_svc_conf_file = 0,
int    skip_service_config_open = 0
[static, private]
 

Initialize the ACE Service Configurator. This is a one-shot method, i.e., it can be called multiple times but it will only do its work once. It does, however, track the number of times it's called (see open_services()). It is fully thread-safe. Return 0 if successful, -1 with errno set if failure. You can provide your program a set of default `svc.conf' entries by setting ignore_default_svc_conf_file to non-zero and use default_svc_conf_entries() before calling open_services(). In addition, you can skip_service_config_open altogether, which is important if the ORB is linked in via the

Parameters:
ACE_Service_Configurator, which  is non-reentrant.

Definition at line 233 of file TAO_Internal.cpp.

References ACE_DEFAULT_LOGGER_KEY, ACE_GUARD_RETURN, ACE_MT, ACE_TEXT_CHAR_TO_TCHAR, client_strategy_factory_args_, ACE_Argv_Type_Converter::get_argc, ACE_Argv_Type_Converter::get_TCHAR_argv, ACE_Shared_Object::init, ACE_Dynamic_Service::instance, ACE_Static_Object_Lock::instance, ACE_Service_Config::open, TAO_ORB_Core::poa_factory_name, ACE_Service_Config::process_directive, resource_factory_args_, server_strategy_factory_args_, service_open_count_, and TAO_SYNCH_RECURSIVE_MUTEX.

Referenced by open_services.

00237 {
00238   ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
00239                             guard, *ACE_Static_Object_Lock::instance (),
00240                             -1));
00241 
00242 #if defined (TAO_PLATFORM_SVC_CONF_FILE_NOTSUP)
00243   ignore_default_svc_conf_file = 1;
00244 #endif /* TAO_PLATFORM_SVC_CONF_FILE_NOTSUP */
00245 
00246   if (TAO_Internal::service_open_count_++ == 0)
00247     {
00248       ACE_Service_Config::process_directive (ace_svc_desc_TAO_Default_Resource_Factory);
00249       ACE_Service_Config::process_directive (ace_svc_desc_TAO_Default_Client_Strategy_Factory);
00250       ACE_Service_Config::process_directive (ace_svc_desc_TAO_Default_Server_Strategy_Factory);
00251 
00252       // Configure the IIOP factory. You do *NOT*
00253       // need modify this code to add your own protocol, instead
00254       // simply add the following to your svc.conf file:
00255       //
00256       // dynamic PN_Factory Service_Object * LIB:_make_PN_Protocol_Factory() ""
00257       // static Resource_Factory "-ORBProtocolFactory PN_Factory"
00258       //
00259       // where PN is the name of your protocol and LIB is the base
00260       // name of the shared library that implements the protocol.
00261       ACE_Service_Config::process_directive (ace_svc_desc_TAO_IIOP_Protocol_Factory);
00262 
00263       // add descriptor to list of static objects.
00264       ACE_Service_Config::process_directive (ace_svc_desc_TAO_MCAST_Parser);
00265       ACE_Service_Config::process_directive (ace_svc_desc_TAO_CORBANAME_Parser);
00266       ACE_Service_Config::process_directive (ace_svc_desc_TAO_CORBALOC_Parser);
00267       ACE_Service_Config::process_directive (ace_svc_desc_TAO_FILE_Parser);
00268       ACE_Service_Config::process_directive (ace_svc_desc_TAO_DLL_Parser);
00269       ACE_Service_Config::process_directive (ace_svc_desc_TAO_Default_Stub_Factory);
00270       ACE_Service_Config::process_directive (ace_svc_desc_TAO_Default_Endpoint_Selector_Factory);
00271       ACE_Service_Config::process_directive (ace_svc_desc_TAO_Default_Protocols_Hooks);
00272       ACE_Service_Config::process_directive (ace_svc_desc_TAO_Default_Thread_Lane_Resources_Manager_Factory);
00273       ACE_Service_Config::process_directive (ace_svc_desc_TAO_Default_Collocation_Resolver);
00274 
00275       int result = 0;
00276 
00277       if (skip_service_config_open == 0)
00278         {
00279             // Copy command line parameter not to use original.
00280             ACE_Argv_Type_Converter command_line(argc, argv);
00281 
00282             result = ACE_Service_Config::open (command_line.get_argc(),
00283                                                command_line.get_TCHAR_argv(),
00284                                                ACE_DEFAULT_LOGGER_KEY,
00285                                                0, // Don't ignore static services.
00286                                                ignore_default_svc_conf_file);
00287         }
00288 
00289       // If available, allow the Adapter Factory to setup.
00290       ACE_Service_Object *adapter_factory =
00291         ACE_Dynamic_Service<TAO_Adapter_Factory>::instance (TAO_ORB_Core::poa_factory_name ().c_str());
00292       if (adapter_factory != 0)
00293         adapter_factory->init (0, 0);
00294 
00295       // Handle RTCORBA library special case.  Since RTCORBA needs
00296       // its init method call to register several hooks, call it here
00297       // if it hasn't already been called.
00298       ACE_Service_Object *rt_loader =
00299         ACE_Dynamic_Service<ACE_Service_Object>::instance ("RT_ORB_Loader");
00300       if (rt_loader != 0)
00301           rt_loader->init (0, 0);
00302 
00303       // @@ What the heck do these things do and do we need to avoid
00304       // calling them if we're not invoking the svc.conf file?
00305       if (TAO_Internal::resource_factory_args_ != 0)
00306         ACE_Service_Config::process_directive (ACE_TEXT_CHAR_TO_TCHAR(TAO_Internal::resource_factory_args_));
00307       if (TAO_Internal::client_strategy_factory_args_ != 0)
00308         ACE_Service_Config::process_directive (ACE_TEXT_CHAR_TO_TCHAR(TAO_Internal::client_strategy_factory_args_));
00309       if (TAO_Internal::server_strategy_factory_args_ != 0)
00310         ACE_Service_Config::process_directive (ACE_TEXT_CHAR_TO_TCHAR(TAO_Internal::server_strategy_factory_args_));
00311       return result;
00312     }
00313   else
00314     return 0;
00315 }


Member Data Documentation

const char * TAO_Internal::client_strategy_factory_args_ = 0 [static, private]
 

Definition at line 63 of file TAO_Internal.cpp.

Referenced by default_svc_conf_entries, and open_services_i.

const char * TAO_Internal::resource_factory_args_ = 0 [static, private]
 

Definition at line 45 of file TAO_Internal.cpp.

Referenced by default_svc_conf_entries, and open_services_i.

const char * TAO_Internal::server_strategy_factory_args_ = 0 [static, private]
 

Definition at line 54 of file TAO_Internal.cpp.

Referenced by default_svc_conf_entries, and open_services_i.

int TAO_Internal::service_open_count_ = 0 [static, private]
 

Number of times open_services() has been called. Incremented by open_services(), and decremented by close_services(). Access to this is protected via the

Parameters:
ACE_Static_Object_Lock. 

Definition at line 67 of file TAO_Internal.cpp.

Referenced by close_services, and open_services_i.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:22:17 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002