NAME

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

SYNOPSIS

#include <ace/Service_Config.h>

class ACE_Service_Config { public: enum {MAX_SERVICES = ACE_DEFAULT_SELECT_REACTOR_SIZE}; ACE_Service_Config ( int ignore_static_svcs = 0, size_t size = ACE_Service_Config::MAX_SERVICES, int signum = SIGHUP ); ACE_Service_Config ( const ASYS_TCHAR program_name[], LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY ); static int open ( const ASYS_TCHAR program_name[], LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY ); static int open ( int argc, ASYS_TCHAR *argv[], LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY ); virtual ~ACE_Service_Config (void); static int close (void); static int close_svcs (void); static int close_singletons (void); static int run_reactor_event_loop (void); static int run_reactor_event_loop (ACE_Time_Value &tv); static int end_reactor_event_loop (void); static int reactor_event_loop_done (void); static int reconfig_occurred (void); static void reconfig_occurred (int); static void reconfigure (void); static ACE_STATIC_SVCS *static_svcs (void); static ACE_Reactor *reactor (void); static ACE_Reactor *reactor (ACE_Reactor *); static ACE_Service_Repository *svc_rep (void); static ACE_Service_Repository *svc_rep (ACE_Service_Repository *); static ACE_Thread_Manager *thr_mgr (void); static ACE_Thread_Manager *thr_mgr (ACE_Thread_Manager *); static ACE_Allocator *alloc (void); static ACE_Allocator *alloc (ACE_Allocator *); static int initialize ( const ACE_Service_Type *, ASYS_TCHAR parameters[] ); static int initialize ( const ASYS_TCHAR svc_name[], ASYS_TCHAR parameters[] ); static int resume (const ASYS_TCHAR svc_name[]); static int suspend (const ASYS_TCHAR svc_name[]); static int remove (const ASYS_TCHAR svc_name[]); static int initialize ( const ACE_Service_Type *, char parameters[] ); static int initialize (const char svc_name[], char parameters[]); static int resume (const char svc_name[]); static int suspend (const char svc_name[]); static int remove (const char svc_name[]); void dump (void) const; static ACE_INLINE void signal_handler (ACE_Sig_Adapter *); ACE_ALLOC_HOOK_DECLARE; static void handle_signal (int sig, siginfo_t *, ucontext_t *); protected: static int process_directives (void); static void parse_args (int, ASYS_TCHAR *argv[]); static int start_daemon (void); static int load_static_svcs (void); private: static const ASYS_TCHAR *service_config_file_; static LPCTSTR logger_key_; static ACE_STATIC_SVCS *static_svcs_; static sig_atomic_t reconfig_occurred_; static char debug_; static char be_a_daemon_; static char no_static_svcs_; static int signum_; static ACE_Sig_Adapter *signal_handler_; };

DESCRIPTION

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.

Initialization and termination methods.

ACE_Service_Config (
    int ignore_static_svcs = 0,
    size_t size = ACE_Service_Config::MAX_SERVICES,
    int signum = SIGHUP
    );

ACE_Service_Config (
    const ASYS_TCHAR program_name[],
    LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY
    );

static int open (
    const ASYS_TCHAR program_name[],
    LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY
    );

static int open (
    int argc,
    ASYS_TCHAR *argv[],
    LPCTSTR logger_key = ACE_DEFAULT_LOGGER_KEY
    );

virtual ~ACE_Service_Config (void);

static int close (void);

static int close_svcs (void);

static int close_singletons (void);

Reactor event loop management methods.

static int run_reactor_event_loop (void);

static int run_reactor_event_loop (ACE_Time_Value &tv);

static int end_reactor_event_loop (void);

static int reactor_event_loop_done (void);

static int reconfig_occurred (void);

static void reconfig_occurred (int);

static void reconfigure (void);

The following methods are static in order to enforce Singleton

semantics for the Reactor, Service_Repository, Thread_Manager, and Acceptor/Connector Strategy factory. Other portions of the system may need to access them at some point or another...

Accessors and mutators for process-wide Singletons.

static ACE_STATIC_SVCS *static_svcs (void);

static ACE_Reactor *reactor (void);

static ACE_Reactor *reactor (ACE_Reactor *);

static ACE_Service_Repository *svc_rep (void);

static ACE_Service_Repository *svc_rep (ACE_Service_Repository *);

static ACE_Thread_Manager *thr_mgr (void);

static ACE_Thread_Manager *thr_mgr (ACE_Thread_Manager *);

static ACE_Allocator *alloc (void);

static ACE_Allocator *alloc (ACE_Allocator *);

Member functions used by various other parts

of the Service Configurator class category.
static int initialize (
    const ACE_Service_Type *,
    ASYS_TCHAR parameters[]
    );

static int initialize (
    const ASYS_TCHAR svc_name[],
    ASYS_TCHAR parameters[]
    );

static int resume (const ASYS_TCHAR svc_name[]);

static int suspend (const ASYS_TCHAR svc_name[]);

static int remove (const ASYS_TCHAR svc_name[]);

We must provide these function to bridge Svc_Conf parser with ACE.

static int initialize (const ACE_Service_Type *, char parameters[]);

static int initialize (const char svc_name[], char parameters[]);

static int resume (const char svc_name[]);

static int suspend (const char svc_name[]);

static int remove (const char svc_name[]);

void dump (void) const;

static ACE_INLINE void signal_handler (ACE_Sig_Adapter *);

ACE_ALLOC_HOOK_DECLARE;

Set by command-line options.

static char debug_;

static char be_a_daemon_;

static char no_static_svcs_;

static int signum_;

static ACE_Sig_Adapter *signal_handler_;

AUTHOR

Doug Schmidt

Maintain a set of the statically linked service descriptor.

LIBRARY

ace