3 //=============================================================================
5 * @file Service_Manager.h
7 * $Id: Service_Manager.h 81388 2008-04-23 14:02:05Z johnnyw $
9 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
11 //=============================================================================
13 #ifndef ACE_SERVICE_MANAGER_H
14 #define ACE_SERVICE_MANAGER_H
15 #include /**/ "ace/pre.h"
17 #include "ace/SOCK_Stream.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/SOCK_Acceptor.h"
24 #include "ace/INET_Addr.h"
25 #include "ace/Service_Object.h"
27 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 * @class ACE_Service_Manager
32 * @brief Provide a standard ACE service for managing all the services
33 * configured in an ACE_Service_Repository.
35 * This implementation is simple and just handles each client
36 * request one at a time. There are currently 3 types of requests:
37 * - List services: If the string "help" is sent, return a list of all
38 * the services supported by the Service Configurator.
39 * - Reconfigure: If the string "reconfigure" is sent trigger a
40 * reconfiguration, which will re-read the local <svc.conf> file.
41 * - Process directive: If neither "help" nor "reconfigure" is sent,
42 * simply treat the incoming string as a process directive and pass
43 * it along to <ACE_Service_Config::process_directive>. This allows
44 * remote configuration via command-line instructions like
45 * % echo suspend My_Remote_Service | telnet hostname 3911
47 * Each request is associated with a new connection, which is closed
48 * when the request is processed. In addition, you must be using the
49 * singleton <ACE_Reactor::instance> in order to trigger
52 class ACE_Export ACE_Service_Manager
: public ACE_Service_Object
55 // = Initialization and termination hooks.
57 ACE_Service_Manager (void);
60 virtual ~ACE_Service_Manager (void);
63 // = Perform the various meta-services.
65 /// Trigger a reconfiguration of the Service Configurator by
66 /// re-reading its local <svc.conf> file.
67 virtual int reconfigure_services (void);
69 /// Determine all the services offered by this daemon and return the
70 /// information back to the client.
71 virtual int list_services (void);
73 // = Dynamic linking hooks.
74 virtual int init (int argc
, ACE_TCHAR
*argv
[]);
75 virtual int info (ACE_TCHAR
**info_string
, size_t length
) const;
76 virtual int fini (void);
78 // = Scheduling hooks.
79 virtual int suspend (void);
80 virtual int resume (void);
82 /// Dump the state of an object.
83 void dump (void) const;
85 /// Declare the dynamic allocation hooks.
86 ACE_ALLOC_HOOK_DECLARE
;
89 int open (const ACE_INET_Addr
&sia
);
91 // = Demultiplexing hooks.
92 virtual ACE_HANDLE
get_handle (void) const;
93 virtual int handle_input (ACE_HANDLE fd
);
94 virtual int handle_close (ACE_HANDLE fd
, ACE_Reactor_Mask
);
95 virtual int handle_signal (int signum
, siginfo_t
*, ucontext_t
*);
97 /// Handle one request.
98 virtual void process_request (ACE_TCHAR
*request
);
100 /// Connection to the client (we only support one client connection
102 ACE_SOCK_Stream client_stream_
;
104 /// Acceptor instance.
105 ACE_SOCK_Acceptor acceptor_
;
107 /// Keep track whether we debug or not.
110 /// The signal used to trigger reconfiguration.
113 /// Default port for the Acceptor to listen on.
114 static u_short DEFAULT_PORT_
;
117 ACE_END_VERSIONED_NAMESPACE_DECL
119 #include /**/ "ace/post.h"
120 #endif /* _SERVICE_MANAGER_H */