Supplies common server operations for dynamic and static configuration of services.
More...
Classes |
struct | Processed_Static_Svc |
Public Types |
enum | { MAX_SERVICES = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE
} |
enum | { DEFAULT_SIZE = ACE_DEFAULT_SERVICE_GESTALT_SIZE
} |
Public Member Functions |
| ACE_Service_Gestalt (size_t size=DEFAULT_SIZE, bool svc_repo_is_owned=true, bool no_static_svcs=true) |
| ~ACE_Service_Gestalt (void) |
void | dump (void) const |
| Dump the state of an object.
|
int | open (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key=0, bool ignore_static_svcs=true, bool ignore_default_svc_conf_file=false, bool ignore_debug_flag=false) |
int | open (int argc, ACE_TCHAR *argv[], const ACE_TCHAR *logger_key=0, bool ignore_static_svcs=true, bool ignore_default_svc_conf_file=false, bool ignore_debug_flag=false) |
int | is_opened (void) |
int | process_directive (const ACE_TCHAR directive[]) |
int | process_directive (const ACE_Static_Svc_Descriptor &ssd, bool force_replace=false) |
| Process one static service definition.
|
int | process_file (const ACE_TCHAR file[]) |
int | find (const ACE_TCHAR name[], const ACE_Service_Type **srp=0, bool ignore_suspended=true) const |
| Searches for a service object declaration in the local repo, only.
|
int | parse_args (int argc, ACE_TCHAR *argv[]) |
int | process_directives (bool defunct_option=false) |
int | close (void) |
int | insert (ACE_Static_Svc_Descriptor *stsd) |
| Registers a service descriptor for a static service object.
|
int | initialize (const ACE_Service_Type *, const ACE_TCHAR *parameters) |
int | initialize (const ACE_TCHAR *svc_name, const ACE_TCHAR *parameters) |
| Initialize and activate a statically svc_name service.
|
int | resume (const ACE_TCHAR svc_name[]) |
int | suspend (const ACE_TCHAR svc_name[]) |
int | remove (const ACE_TCHAR svc_name[]) |
int | find_static_svc_descriptor (const ACE_TCHAR *name, ACE_Static_Svc_Descriptor **ssd=0) const |
| Find a static service descriptor by name.
|
ACE_Service_Repository * | current_service_repository (void) |
| Get the current ACE_Service_Repository held by this object.
|
Static Public Member Functions |
static void | intrusive_add_ref (ACE_Service_Gestalt *) |
static void | intrusive_remove_ref (ACE_Service_Gestalt *) |
Public Attributes |
| ACE_ALLOC_HOOK_DECLARE |
| Declare the dynamic allocation hooks.
|
Protected Types |
typedef ACE_Unbounded_Queue
< ACE_TString > | ACE_SVC_QUEUE |
typedef
ACE_Unbounded_Queue_Iterator
< ACE_TString > | ACE_SVC_QUEUE_ITERATOR |
typedef ACE_Unbounded_Set
< ACE_Static_Svc_Descriptor * > | ACE_STATIC_SVCS |
| Maintain a set of the statically linked service descriptors.
|
typedef
ACE_Unbounded_Set_Iterator
< ACE_Static_Svc_Descriptor * > | ACE_STATIC_SVCS_ITERATOR |
typedef ACE_Unbounded_Set
< Processed_Static_Svc * > | ACE_PROCESSED_STATIC_SVCS |
typedef
ACE_Unbounded_Set_Iterator
< Processed_Static_Svc * > | ACE_PROCESSED_STATIC_SVCS_ITERATOR |
Protected Member Functions |
int | parse_args_i (int, ACE_TCHAR *argv[], bool &ignore_default_svc_conf_file) |
int | open_i (const ACE_TCHAR program_name[], const ACE_TCHAR *logger_key=0, bool ignore_static_svcs=true, bool ignore_default_svc_conf_file=false, bool ignore_debug_flag=false) |
int | init_svc_conf_file_queue (void) |
| Initialize the svc_conf_file_queue_ if necessary.
|
int | load_static_svcs (void) |
int | process_commandline_directives (void) |
int | process_directive_i (const ACE_Static_Svc_Descriptor &ssd, bool force_replace=false) |
ACE_XML_Svc_Conf * | get_xml_svc_conf (ACE_DLL &d) |
int | initialize_i (const ACE_Service_Type *sr, const ACE_TCHAR *parameters) |
const ACE_Static_Svc_Descriptor * | find_processed_static_svc (const ACE_TCHAR *) |
void | add_processed_static_svc (const ACE_Static_Svc_Descriptor *) |
| Captures a list of the direcives processed (explicitely) for this Gestalt so that services can be replicated in other repositories upon their first initialization.
|
int | init_i (void) |
Protected Attributes |
bool | svc_repo_is_owned_ |
size_t | svc_repo_size_ |
int | is_opened_ |
const ACE_TCHAR * | logger_key_ |
bool | no_static_svcs_ |
| Should we avoid loading the static services?
|
ACE_SVC_QUEUE * | svc_queue_ |
| Queue of services specified on the command-line.
|
ACE_SVC_QUEUE * | svc_conf_file_queue_ |
ACE_Service_Repository * | repo_ |
| The service repository to hold the services.
|
ACE_STATIC_SVCS * | static_svcs_ |
| Repository of statically linked services.
|
ACE_PROCESSED_STATIC_SVCS * | processed_static_svcs_ |
ACE_Atomic_Op< ACE_SYNCH_MUTEX,
long > | refcnt_ |
| Support for intrusive reference counting.
|
Friends |
class | ACE_Dynamic_Service_Base |
class | ACE_Service_Object |
class | ACE_Service_Config |
class | ACE_Service_Config_Guard |
Supplies common server operations for dynamic and static configuration of services.
The Gestalt embodies the concept of configuration context. On one hand, it is a flat namespace, where names correspond to a Service Object instance. A Gestalt owns the Service Repository instance, which in turn owns the Service Object instances.
Another aspect of a Gestalt is its responsibility for record-keeping and accounting for the meta-data, necessary for locating, removing or instantiating a service.
A repository underlies an instance of a gestalt and its lifetime may or may not be bounded by the lifetime of the gestalt, that owns it. This feature is important for the derived classes and the Service Config in particular.
Captures a list of the direcives processed (explicitely) for this Gestalt so that services can be replicated in other repositories upon their first initialization.
This is part of the mechanism ensuring distinct local instances for static service objects, loaded in another repository.
When process_directive(Static_Svc_Descriptor&) is called, it associates a service object with the Gestalt and makes the resource (a Service Object) local to the repository. This is but the first step in using such SO. The next is the "initialization" step. It is typicaly done through a "static" service configuration directive.
In contrast a "dynamic" directive, when processed through the overloaded process_directives(string) both creates the SO locally and initializes it, where the statics directive must first locate the SO and then calls the init() method. This means that durig the "static" initialization there's no specific information about the hosting repository and the gestalt must employ some lookup strategy to find it elsewhere.
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. If any configuration file is provided with this option then the default svc.conf will be ignored.
- '-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.
- '-p' Specifies a pathname which is used to store the process id.
- '-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. Can be specified multiple times.
Note: Options '-f' and '-S' complement each other. Directives from files and from '-S' option are processed together in the following order. First, the default file "./svc.conf" is evaluated if not ignored, then all files are processed in the order they are specified in '-f' argv parameter. Finally, all '-S' directive strings are executed in the order the directives appear in argv parameter.
If no files or directives are added via the '-f' and '-S' arguments, and the default file is not ignored, it will be evaluated whether it exists or not, possibly causing a failure return. If any other directives are added then the default file will be evaluated only if it exists.
- 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 true then static services are not loaded, otherwise, they are loaded. |
ignore_default_svc_conf_file | If false then the ./svc.conf configuration file will be ignored. |
ignore_debug_flag | If false then the application is responsible for setting the ACE_Log_Msg::priority_mask appropriately. |
- Return values:
-
-1 | A configuration file is not found or cannot be opened (errno is set accordingly). |
0 | Success. |
>0 | The number of directive errors encountered while processing the service configuration file(s). |