3 //=============================================================================
5 * @file Service_Manager.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 //=============================================================================
11 #ifndef ACE_SERVICE_MANAGER_H
12 #define ACE_SERVICE_MANAGER_H
13 #include /**/ "ace/pre.h"
15 #include "ace/SOCK_Stream.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/SOCK_Acceptor.h"
22 #include "ace/INET_Addr.h"
23 #include "ace/Service_Object.h"
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 * @class ACE_Service_Manager
30 * @brief Provide a standard ACE service for managing all the services
31 * configured in an ACE_Service_Repository.
33 * This implementation is simple and just handles each client
34 * request one at a time. There are currently 3 types of requests:
35 * - List services: If the string "help" is sent, return a list of all
36 * the services supported by the Service Configurator.
37 * - Reconfigure: If the string "reconfigure" is sent trigger a
38 * reconfiguration, which will re-read the local <svc.conf> file.
39 * - Process directive: If neither "help" nor "reconfigure" is sent,
40 * simply treat the incoming string as a process directive and pass
41 * it along to <ACE_Service_Config::process_directive>. This allows
42 * remote configuration via command-line instructions like
43 * % echo suspend My_Remote_Service | telnet hostname 3911
45 * Each request is associated with a new connection, which is closed
46 * when the request is processed. In addition, you must be using the
47 * singleton <ACE_Reactor::instance> in order to trigger
50 class ACE_Export ACE_Service_Manager
: public ACE_Service_Object
54 ACE_Service_Manager ();
57 virtual ~ACE_Service_Manager ();
59 /// Declare the dynamic allocation hooks.
60 ACE_ALLOC_HOOK_DECLARE
;
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 ();
69 /// Determine all the services offered by this daemon and return the
70 /// information back to the client.
71 virtual int list_services ();
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;
78 // = Scheduling hooks.
79 virtual int suspend ();
80 virtual int resume ();
82 /// Dump the state of an object.
86 int open (const ACE_INET_Addr
&sia
);
88 // = Demultiplexing hooks.
89 virtual ACE_HANDLE
get_handle () const;
90 virtual int handle_input (ACE_HANDLE fd
);
91 virtual int handle_close (ACE_HANDLE fd
, ACE_Reactor_Mask
);
92 virtual int handle_signal (int signum
, siginfo_t
*, ucontext_t
*);
94 /// Handle one request.
95 virtual void process_request (ACE_TCHAR
*request
);
97 /// Connection to the client (we only support one client connection
99 ACE_SOCK_Stream client_stream_
;
101 /// Acceptor instance.
102 ACE_SOCK_Acceptor acceptor_
;
104 /// Keep track whether we debug or not.
107 /// The signal used to trigger reconfiguration.
110 /// Default port for the Acceptor to listen on.
111 static u_short DEFAULT_PORT_
;
114 ACE_END_VERSIONED_NAMESPACE_DECL
116 #include /**/ "ace/post.h"
117 #endif /* _SERVICE_MANAGER_H */