ACE_Service_Config Class Reference

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

#include <Service_Config.h>

Inheritance diagram for ACE_Service_Config:

Inheritance graph
[legend]
Collaboration diagram for ACE_Service_Config:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Service_Config (int ignore_static_svcs=1, size_t size=ACE_Service_Gestalt::MAX_SERVICES, int signum=SIGHUP)
 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 ACE_Service_Gestaltglobal (void)
static ACE_Service_Gestaltcurrent (void)
static ACE_Service_Gestaltinstance (void)
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_Service_Gestaltstatic_svcs (void)
static int insert (ACE_Static_Svc_Descriptor *svc)
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.

Protected Member Functions

virtual int open_i (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key, bool ignore_static_svcs, bool ignore_default_svc_conf_file, bool ignore_debug_flag)
virtual int parse_args_i (int argc, ACE_TCHAR *argv[])

Static Protected Member Functions

static ACE_Service_Gestaltcurrent (ACE_Service_Gestalt *)
 A mutator to set the "current" (TSS) gestalt instance.
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)

Private Member Functions

typedef ACE_TSS_TYPE (ACE_Service_Config::TSS_Resources) TSS_Service_Gestalt_Ptr

Static Private Member Functions

static ACE_Service_Gestaltcurrent_i (ACE_Service_Gestalt *newcurrent)
 = Static interfaces
static TSS_Service_Gestalt_Ptr *& impl_ (void)

Static Private Attributes

static sig_atomic_t reconfig_occurred_ = 0
 True if reconfiguration occurred.
static int be_a_daemon_ = 0
 Shall we become a daemon process?
static ACE_TCHARpid_file_name_ = 0
 Pathname of file to write process id.
static int signum_ = SIGHUP
 Number of the signal used to trigger reconfiguration.
static ACE_Sig_Adaptersignal_handler_ = 0
 Handles the reconfiguration signals.

Friends

class ACE_Service_Config_Guard

Classes

struct  TSS_Resources
 A Wrapper for the TSS-stored pointer. More...

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. It represents the process-wide collection of services, which is typicaly shared among all other configurable entities. The only ACE_Service_Config instance is registered with and owned by the ACE_Object_Manager.

By contrast, the ACE_Service_Gestalt represents the collection of services, pertaining to a configurable entity. Typicaly, a "configurable entity" is an instance, which owns an instance of ACE_Service_Gestalt in order to ensure full controll over the services it needs.

Another facet of ACE_Service_Config is that for a given thread, it provides access to its current, process-global ACE_Service_Gestalt instance through its curent() method.

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.


Constructor & Destructor Documentation

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

Initialize the Service Repository. Note that initialising signum to a negative number will prevent a signal handler being registered when the repository is opened.

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

typedef ACE_Service_Config::ACE_TSS_TYPE ( ACE_Service_Config::TSS_Resources   )  [private]

A type for the TSS-stored resources. The typedef helps to abstract from the particularities of single-threaded vs multi-threaded environments.

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.

Reimplemented from ACE_Service_Gestalt.

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]

ACE_Service_Gestalt * ACE_Service_Config::current ( void   )  [static]

Accessor for the "current" service repository through a pointer held in TSS.

ACE_Service_Gestalt * ACE_Service_Config::current ( ACE_Service_Gestalt  )  [static, protected]

A mutator to set the "current" (TSS) gestalt instance.

Mutator to set the (TSS) global instance. Intended for use by helper classes, like ACE_Service_Config_Guard which when instantiated on the stack, can temporarily change which gestalt instance is viewed as global from the point of view of the static initializers in DLLs.

ACE_Service_Gestalt * ACE_Service_Config::current_i ( ACE_Service_Gestalt newcurrent  )  [static, private]

= Static interfaces

A private, non-locking mutator to set the "current" (TSS) gestalt instance. Make sure to call with the proper locks held!

void ACE_Service_Config::dump ( void   )  const

Dump the state of an object.

Reimplemented from ACE_Service_Gestalt.

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>.

ACE_Service_Gestalt * ACE_Service_Config::global ( void   )  [static]

If not yet initialized, creates a process-wide instance global instance, which is registered with the ACE_Object_Manager, via ACE_Singleton. Note that this is allways the same instance, in contrast with current (), which may be different instance at different times, dependent on the context.

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

Handles signals to trigger reconfigurations.

ACE_Service_Config::TSS_Service_Gestalt_Ptr *& ACE_Service_Config::impl_ ( void   )  [static, private]

Provides access to the static ptr, containing the TSS accessor. Ensures the desired order of initialization, even when other static initializers need the value.

A "straight" static ptr does not work in static builds, because some static initializer may call current() method and assign value to instance_ *before* the startup code has had a chance to initialize it . This results in instance_ being "zeroed" out after it was assigned the correct value. Having a method scoped static guarantees that the first time the method is invoked, the instance_ will be initialized before returning.

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

Initialize and activate a statically svc_name service.

Reimplemented from ACE_Service_Gestalt.

ACE_INLINE 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.

Reimplemented from ACE_Service_Gestalt.

int ACE_Service_Config::insert ( ACE_Static_Svc_Descriptor svc  )  [static]

Insert a static service descriptor for processing on open_i(). The corresponding ACE_STATIC_SVC_* macros were chaged to use this method instead of obtaining a ptr to a container. See the note on static_svcs(). Added to prevent exposing the internal storage representation of the services repository and provide a better way of debugging service loading and registration problems.

Reimplemented from ACE_Service_Gestalt.

ACE_Service_Gestalt * ACE_Service_Config::instance ( void   )  [static]

This is what the static service initializators are hard-wired to use, so in order to keep interface changes to a minimum this method merely forwards to current(). Thus it is possible to temporarily replace what those initializers think is the global service repository, for instance when dynamically loading a service from a DLL, which in turn, contains its own static services.

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

Add the default statically-linked services to the ACE_Service_Repository.

Reimplemented from ACE_Service_Gestalt.

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:

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).

Reimplemented from ACE_Service_Gestalt.

ACE_BEGIN_VERSIONED_NAMESPACE_DECL 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.

Reimplemented from ACE_Service_Gestalt.

int ACE_Service_Config::open_i ( const ACE_TCHAR  program_name[],
const ACE_TCHAR logger_key,
bool  ignore_static_svcs,
bool  ignore_default_svc_conf_file,
bool  ignore_debug_flag 
) [protected, virtual]

Performs an open without parsing command-line arguments. Implements whats different in the opening sequence for this class, as opposed to the base class.

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.

Reimplemented from ACE_Service_Gestalt.

ACE_INLINE 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

Reimplemented from ACE_Service_Gestalt.

int ACE_Service_Config::parse_args_i ( int  argc,
ACE_TCHAR argv[] 
) [protected, virtual]

Implements whats different in the command line parameter processing for this class, as opposed to the base class.

Reimplemented from ACE_Service_Gestalt.

static 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.

Reimplemented from ACE_Service_Gestalt.

ACE_INLINE 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'.

Reimplemented from ACE_Service_Gestalt.

ACE_INLINE 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.

Reimplemented from ACE_Service_Gestalt.

ACE_INLINE 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.

Reimplemented from ACE_Service_Gestalt.

static 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.

Reimplemented from ACE_Service_Gestalt.

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

Process a file containing a list of service configuration directives.

Reimplemented from ACE_Service_Gestalt.

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.

Reimplemented from ACE_Service_Gestalt.

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).

Reimplemented from ACE_Service_Gestalt.

ACE_INLINE void ACE_Service_Config::signal_handler ( ACE_Sig_Adapter  )  [static]

Set the signal_handler;for internal use by ACE_Object_Manager only.

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

Become a daemon.

ACE_Service_Gestalt * ACE_Service_Config::static_svcs ( void   )  [static]

Returns a pointer to the list of statically linked services.

Deprecated:
  • Same as instance(), but still useful in legacy code, (notably, one that can not be easily modified) which uses the following idiom for registering static services:
ACE_Service_Config::static_svcs ()->insert (...);

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...

Reimplemented from ACE_Service_Gestalt.


Friends And Related Function Documentation

friend class ACE_Service_Config_Guard [friend]

This class needs the intimate access to be able to swap the current TSS pointer for the global Gestalt.

Reimplemented from ACE_Service_Gestalt.


Member Data Documentation

ACE_Service_Config::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

Reimplemented from ACE_Service_Gestalt.

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

Shall we become a daemon process?

ACE_TCHAR * ACE_Service_Config::pid_file_name_ = 0 [static, private]

Pathname of file to write process id.

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.


The documentation for this class was generated from the following files:
Generated on Sun Jul 9 09:25:25 2006 for ACE by  doxygen 1.4.7-1