ACE_Service_Config Class Reference

Supplies common server operations for dynamic and static configuration of services. More...

#include <Service_Config.h>

Collaboration diagram for ACE_Service_Config:

Collaboration graph
[legend]
List of all members.

Public Types

enum  { MAX_SERVICES = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE }

Public Member Functions

 ACE_Service_Config (int ignore_static_svcs=1, size_t size=ACE_Service_Config::MAX_SERVICES, int signum=SIGHUP)
 Initialize the Service Repository.
 ACE_Service_Config (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key=ACE_DEFAULT_LOGGER_KEY)
virtual ~ACE_Service_Config (void)
void dump (void) const
 Dump the state of an object.

Static Public Member Functions

static int open_i (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key=ACE_DEFAULT_LOGGER_KEY, int ignore_default_svc_conf_file=0, int ignore_debug_flag=0)
static int open (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key=ACE_DEFAULT_LOGGER_KEY, int ignore_static_svcs=1, int ignore_default_svc_conf_file=0, int ignore_debug_flag=0)
static int open (int argc, ACE_TCHAR *argv[], const ACE_TCHAR *logger_key=ACE_DEFAULT_LOGGER_KEY, int ignore_static_svcs=1, int ignore_default_svc_conf_file=0, int ignore_debug_flag=0)
static int close (void)
static int fini_svcs (void)
static int close_svcs (void)
static int reconfig_occurred (void)
 True if reconfiguration occurred.
static void reconfig_occurred (int)
 Indicate that reconfiguration occurred.
static void reconfigure (void)
 Perform the reconfiguration process.
static ACE_STATIC_SVCSstatic_svcs (void)
 Returns a pointer to the list of statically linked services.
static int initialize (const ACE_Service_Type *, const ACE_TCHAR *parameters)
static int initialize (const ACE_TCHAR *svc_name, const ACE_TCHAR *parameters)
 Initialize and activate a statically svc_name service.
static int resume (const ACE_TCHAR svc_name[])
static int suspend (const ACE_TCHAR svc_name[])
static int remove (const ACE_TCHAR svc_name[])
static ACE_INLINE void signal_handler (ACE_Sig_Adapter *)
 Set the signal_handler;for internal use by ACE_Object_Manager only.
static int process_file (const ACE_TCHAR file[])
static int process_directive (const ACE_TCHAR directive[])
static int process_directive (const ACE_Static_Svc_Descriptor &ssd, int force_replace=0)
 Process one static service definition.
static int process_directives (void)
static void handle_signal (int sig, siginfo_t *, ucontext_t *)
 Handles signals to trigger reconfigurations.
static int parse_args (int, ACE_TCHAR *argv[])
static ACE_Service_Type_Implcreate_service_type_impl (const ACE_TCHAR *name, int type, void *symbol, u_int flags, ACE_Service_Object_Exterminator gobbler)

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Static Protected Member Functions

static int process_commandline_directives (void)
static int process_directives_i (ACE_Svc_Conf_Param *param)
static int start_daemon (void)
 Become a daemon.
static int load_static_svcs (void)

Static Private Member Functions

static int init_svc_conf_file_queue (void)
 Initialize the <svc_conf_file_queue_> if necessary.

Static Private Attributes

static const ACE_TCHARlogger_key_ = ACE_DEFAULT_LOGGER_KEY
static ACE_STATIC_SVCSstatic_svcs_ = 0
 Singleton repository of statically linked services.
static ACE_SVC_QUEUEsvc_queue_ = 0
 Queue of services specified on the command-line.
static ACE_SVC_QUEUEsvc_conf_file_queue_ = 0
static sig_atomic_t reconfig_occurred_ = 0
 True if reconfiguration occurred.
static int be_a_daemon_ = 0
 Shall we become a daemon process?
static int no_static_svcs_ = 1
 Should we avoid loading the static services?
static int signum_ = SIGHUP
 Number of the signal used to trigger reconfiguration.
static ACE_Sig_Adaptersignal_handler_ = 0
 Handles the reconfiguration signals.
static int is_initialized_ = 0

Detailed Description

Supplies common server operations for dynamic and static configuration of services.

The ACE_Service_Config uses the Monostate pattern. Therefore, you can only have one of these instantiated per-process.

Note:
The signal_handler_ static member is allocated by the ACE_Object_Manager. The ACE_Service_Config constructor uses signal_handler_. Therefore, if the program has any static ACE_Service_Config objects, there might be initialization order problems. They can be minimized, but not eliminated, by _not_ defining ACE_HAS_NONSTATIC_OBJECT_MANAGER.


Member Enumeration Documentation

anonymous enum
 

Enumerator:
MAX_SERVICES 


Constructor & Destructor Documentation

ACE_Service_Config::ACE_Service_Config int  ignore_static_svcs = 1,
size_t  size = ACE_Service_Config::MAX_SERVICES,
int  signum = SIGHUP
 

Initialize the Service Repository.

ACE_Service_Config::ACE_Service_Config const ACE_TCHAR  program_name[],
const ACE_TCHAR logger_key = ACE_DEFAULT_LOGGER_KEY
 

Performs an open without parsing command-line arguments. The logger_key indicates where to write the logging output, which is typically either a STREAM pipe or a socket address.

ACE_Service_Config::~ACE_Service_Config void   )  [virtual]
 

Perform user-specified close activities and remove dynamic memory.


Member Function Documentation

int ACE_Service_Config::close void   )  [static]
 

Tidy up and perform last rites when ACE_Service_Config is shut down. This method calls <close_svcs>. Returns 0.

int ACE_Service_Config::close_svcs void   )  [static]
 

Perform user-specified close hooks on all of the configured services in the Service_Repository, then delete the Service_Repository itself. Returns 0.

ACE_Service_Type_Impl * ACE_Service_Config::create_service_type_impl const ACE_TCHAR name,
int  type,
void *  symbol,
u_int  flags,
ACE_Service_Object_Exterminator  gobbler
[static]
 

void ACE_Service_Config::dump void   )  const
 

Dump the state of an object.

int ACE_Service_Config::fini_svcs void   )  [static]
 

Perform user-specified close hooks and possibly delete all of the configured services in the <Service_Repository>.

void ACE_Service_Config::handle_signal int  sig,
siginfo_t ,
ucontext_t
[static]
 

Handles signals to trigger reconfigurations.

int ACE_Service_Config::init_svc_conf_file_queue void   )  [static, private]
 

Initialize the <svc_conf_file_queue_> if necessary.

int ACE_Service_Config::initialize const ACE_TCHAR svc_name,
const ACE_TCHAR parameters
[static]
 

Initialize and activate a statically svc_name service.

int ACE_Service_Config::initialize const ACE_Service_Type ,
const ACE_TCHAR parameters
[static]
 

Dynamically link the shared object file and retrieve a pointer to the designated shared object in this file.

int ACE_Service_Config::load_static_svcs void   )  [static, protected]
 

Add the default statically-linked services to the ACE_Service_Repository.

ACE_INLINE int ACE_Service_Config::open int  argc,
ACE_TCHAR argv[],
const ACE_TCHAR logger_key = ACE_DEFAULT_LOGGER_KEY,
int  ignore_static_svcs = 1,
int  ignore_default_svc_conf_file = 0,
int  ignore_debug_flag = 0
[static]
 

This is the primary entry point into the ACE_Service_Config (the constructor just handles simple initializations). It parses arguments passed in from argc and argv parameters. The arguments that are valid in a call to this method include:

  • '-b' Option to indicate that we should be a daemon. Note that when this option is used, the process will be daemonized before the service configuration file(s) are read. During daemonization, (on POSIX systems) the current directory will be changed to "/" so the caller should either fully specify the file names, or execute a chroot() to the appropriate directory.
    See also:
    ACE::daemonize().
  • '-d' Turn on debugging mode
  • '-f' Specifies a configuration file name other than the default svc.conf. Can be specified multiple times to use multiple files.
  • '-k' Specifies the rendezvous point to use for the ACE distributed logger.
  • '-y' Explicitly enables the use of static services. This flag overrides the ignore_static_svcs parameter value.
  • '-n' Explicitly disables the use of static services. This flag overrides the ignore_static_svcs parameter value.
  • '-s' Specifies a signal number other than SIGHUP to trigger reprocessing of the configuration file(s). Ignored for platforms that do not have POSIX signals, such as Windows.
  • '-S' Specifies a service directive string. Enclose the string in quotes and escape any embedded quotes with a backslash. This option specifies service directives without the need for a configuration file.

Parameters:
argc The number of commandline arguments.
argv The array with commandline arguments
logger_key Indicates where to write the logging output, which is typically either a STREAM pipe or a socket address.
ignore_static_svcs If 1 then static services are not loaded, otherwise, they are loaded.
ignore_default_svc_conf_file If non-0 then the svc.conf configuration file will be ignored.
ignore_debug_flag If non-0 then the application is responsible for setting the ACE_Log_Msg::priority_mask appropriately.
Return values:
-1 the configuration file is not found or cannot be opened (errno is set accordingly).
0 Success.
>0 The number of errors encountered while processing the service configuration file(s).

ACE_INLINE int ACE_Service_Config::open const ACE_TCHAR  program_name[],
const ACE_TCHAR logger_key = ACE_DEFAULT_LOGGER_KEY,
int  ignore_static_svcs = 1,
int  ignore_default_svc_conf_file = 0,
int  ignore_debug_flag = 0
[static]
 

Performs an open without parsing command-line arguments. The <logger_key> indicates where to write the logging output, which is typically either a STREAM pipe or a socket address. If <ignore_static_svcs> is 1 then static services are not loaded, otherwise, they are loaded. If <ignore_default_svc_conf_file> is non-0 then the <svc.conf> configuration file will be ignored. Returns zero upon success, -1 if the file is not found or cannot be opened (errno is set accordingly), otherwise returns the number of errors encountered loading the services in the specified svc.conf configuration file. If <ignore_debug_flag> is non-0 then the application is responsible for setting the <ACE_Log_Msg::priority_mask> appropriately.

int ACE_Service_Config::open_i const ACE_TCHAR  program_name[],
const ACE_TCHAR logger_key = ACE_DEFAULT_LOGGER_KEY,
int  ignore_default_svc_conf_file = 0,
int  ignore_debug_flag = 0
[static]
 

Performs an open without parsing command-line arguments. The logger_key indicates where to write the logging output, which is typically either a STREAM pipe or a socket address. If ignore_default_svc_conf_file is non-0 then the "svc.conf" file will be ignored. If ignore_debug_flag is non-0 then the application is responsible for setting the ACE_Log_Msg::priority_mask() appropriately. Returns number of errors that occurred on failure and 0 otherwise.

int ACE_Service_Config::parse_args int  ,
ACE_TCHAR argv[]
[static]
 

Handle the command-line options intended for the <ACE_Service_Config>. Note that <argv[0]> is assumed to be the program name. The arguments that are valid in a call to this method are

  • '-b' Option to indicate that we should be a daemon
  • '-d' Turn on debugging mode
  • '-f' Option to read in the list of svc.conf file names
  • '-k' Option to read a wide string where in the logger output can be written
  • '-y' Turn on the flag for a repository of statically linked services
  • '-n' Need not have a repository of statically linked services
  • '-S' Option to read in the list of services on the command-line Please observe the difference between options '-f' that looks for a list of files and here a list of services.

int ACE_Service_Config::process_commandline_directives void   )  [static, protected]
 

Process service configuration requests that were provided on the command-line. Returns the number of errors that occurred.

int ACE_Service_Config::process_directive const ACE_Static_Svc_Descriptor ssd,
int  force_replace = 0
[static]
 

Process one static service definition.

Load a new static service into the ACE_Service_Repository.

Parameters:
ssd Service descriptor, see the document of ACE_Static_Svc_Descriptor for more details.
force_replace If set the new service descriptor replaces any previous instance in the ACE_Service_Repository.
Returns:
Returns -1 if the service cannot be 'loaded'.

int ACE_Service_Config::process_directive const ACE_TCHAR  directive[]  )  [static]
 

Process one service configuration directive, which is passed as a string. Returns the number of errors that occurred.

int ACE_Service_Config::process_directives void   )  [static]
 

Process (or re-process) service configuration requests that are provided in the svc.conf file(s). Returns the number of errors that occurred.

int ACE_Service_Config::process_directives_i ACE_Svc_Conf_Param param  )  [static, protected]
 

This is the implementation function that process_directives() and process_directive() both call. Returns the number of errors that occurred.

int ACE_Service_Config::process_file const ACE_TCHAR  file[]  )  [static]
 

Process a file containing a list of service configuration directives.

void ACE_Service_Config::reconfig_occurred int   )  [static]
 

Indicate that reconfiguration occurred.

int ACE_Service_Config::reconfig_occurred void   )  [static]
 

True if reconfiguration occurred.

void ACE_Service_Config::reconfigure void   )  [static]
 

Perform the reconfiguration process.

int ACE_Service_Config::remove const ACE_TCHAR  svc_name[]  )  [static]
 

Totally remove svc_name from the daemon by removing it from the ACE_Reactor, and unlinking it if necessary.

int ACE_Service_Config::resume const ACE_TCHAR  svc_name[]  )  [static]
 

Resume a svc_name that was previously suspended or has not yet been resumed (e.g., a static service).

ACE_INLINE void ACE_Service_Config::signal_handler ACE_Sig_Adapter  )  [static]
 

Set the signal_handler;for internal use by ACE_Object_Manager only.

int ACE_Service_Config::start_daemon void   )  [static, protected]
 

Become a daemon.

ACE_STATIC_SVCS * ACE_Service_Config::static_svcs void   )  [static]
 

Returns a pointer to the list of statically linked services.

int ACE_Service_Config::suspend const ACE_TCHAR  svc_name[]  )  [static]
 

Suspend svc_name. Note that this will not unlink the service from the daemon if it was dynamically linked, it will mark it as being suspended in the Service Repository and call the <suspend> member function on the appropriate <ACE_Service_Object>. A service can be resumed later on by calling the <RESUME> member function...


Member Data Documentation

ACE_Service_Config::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

int ACE_Service_Config::be_a_daemon_ = 0 [static, private]
 

Shall we become a daemon process?

int ACE_Service_Config::is_initialized_ = 0 [static, private]
 

Keep track of whether the <ACE_Service_Config> is already initialized. If so, we can't allow <yyparse> to be called since it's not reentrant. This variable is incremented by the <ACE_Service_Config::open> method and decremented by the <ACE_Service_Config::close> method.

const ACE_TCHAR * ACE_Service_Config::logger_key_ = ACE_DEFAULT_LOGGER_KEY [static, private]
 

Indicates where to write the logging output. This is typically either a STREAM pipe or a socket address.

int ACE_Service_Config::no_static_svcs_ = 1 [static, private]
 

Should we avoid loading the static services?

sig_atomic_t ACE_Service_Config::reconfig_occurred_ = 0 [static, private]
 

True if reconfiguration occurred.

ACE_Sig_Adapter * ACE_Service_Config::signal_handler_ = 0 [static, private]
 

Handles the reconfiguration signals.

int ACE_Service_Config::signum_ = SIGHUP [static, private]
 

Number of the signal used to trigger reconfiguration.

ACE_STATIC_SVCS * ACE_Service_Config::static_svcs_ = 0 [static, private]
 

Singleton repository of statically linked services.

ACE_SVC_QUEUE * ACE_Service_Config::svc_conf_file_queue_ = 0 [static, private]
 

Queue of svc.conf files specified on the command-line. @ This should probably be made to handle unicode filenames...

ACE_SVC_QUEUE * ACE_Service_Config::svc_queue_ = 0 [static, private]
 

Queue of services specified on the command-line.


The documentation for this class was generated from the following files:
Generated on Wed Nov 23 15:50:23 2005 for ACE by  doxygen 1.4.5