Service_Manager.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Service_Manager.h
00006  *
00007  *  Service_Manager.h,v 4.21 2006/02/13 11:40:08 jwillemsen Exp
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_SERVICE_MANAGER_H
00014 #define ACE_SERVICE_MANAGER_H
00015 #include /**/ "ace/pre.h"
00016 
00017 #include "ace/SOCK_Stream.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #include "ace/SOCK_Acceptor.h"
00024 #include "ace/INET_Addr.h"
00025 #include "ace/Service_Object.h"
00026 
00027 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00028 
00029 /**
00030  * @class ACE_Service_Manager
00031  *
00032  * @brief Provide a standard ACE service for managing all the services
00033  * configured in an ACE_Service_Repository.
00034  *
00035  * This implementation is simple and just handles each client
00036  * request one at a time.  There are currently 3 types of requests:
00037  * + List services: If the string "help" is sent, return a list of all
00038  *   the services supported by the Service Configurator.
00039  * + Reconfigure: If the string "reconfigure" is sent trigger a
00040  *   reconfiguration, which will re-read the local <svc.conf> file.
00041  * + Process directive: If neither "help" nor "reconfigure" is sent,
00042  *   simply treat the incoming string as a process directive and pass
00043  *   it along to <ACE_Service_Config::process_directive>.  This allows
00044  *   remote configuration via command-line instructions like
00045  *   % echo suspend My_Remote_Service | telnet hostname 3911
00046  *
00047  * Each request is associated with a new connection, which is closed
00048  * when the request is processed.  In addition, you must be using the
00049  * singleton <ACE_Reactor::instance> in order to trigger
00050  * reconfigurations.
00051  */
00052 class ACE_Export ACE_Service_Manager : public ACE_Service_Object
00053 {
00054 public:
00055   // = Initialization and termination hooks.
00056   /// Constructor.
00057   ACE_Service_Manager (void);
00058 
00059   /// Destructor.
00060   ~ACE_Service_Manager (void);
00061 
00062 protected:
00063   // = Perform the various meta-services.
00064 
00065   /// Trigger a reconfiguration of the Service Configurator by
00066   /// re-reading its local <svc.conf> file.
00067   virtual int reconfigure_services (void);
00068 
00069   /// Determine all the services offered by this daemon and return the
00070   /// information back to the client.
00071   virtual int list_services (void);
00072 
00073   // = Dynamic linking hooks.
00074   virtual int init (int argc, ACE_TCHAR *argv[]);
00075   virtual int info (ACE_TCHAR **info_string, size_t length) const;
00076   virtual int fini (void);
00077 
00078   // = Scheduling hooks.
00079   virtual int suspend (void);
00080   virtual int resume (void);
00081 
00082   /// Dump the state of an object.
00083   void dump (void) const;
00084 
00085   /// Declare the dynamic allocation hooks.
00086   ACE_ALLOC_HOOK_DECLARE;
00087 
00088 protected:
00089   int open (const ACE_INET_Addr &sia);
00090 
00091   // = Demultiplexing hooks.
00092   virtual ACE_HANDLE get_handle (void) const;
00093   virtual int handle_input (ACE_HANDLE fd);
00094   virtual int handle_close (ACE_HANDLE fd, ACE_Reactor_Mask);
00095   virtual int handle_signal (int signum, siginfo_t *, ucontext_t *);
00096 
00097   /// Handle one request.
00098   virtual void process_request (ACE_TCHAR *request);
00099 
00100   /// Connection to the client (we only support one client connection
00101   /// at a time).
00102   ACE_SOCK_Stream client_stream_;
00103 
00104   /// Acceptor instance.
00105   ACE_SOCK_Acceptor acceptor_;
00106 
00107   /// Keep track of the debugging level.
00108   int debug_;
00109 
00110   /// The signal used to trigger reconfiguration.
00111   int signum_;
00112 
00113   /// Default port for the Acceptor to listen on.
00114   static u_short DEFAULT_PORT_;
00115 };
00116 
00117 ACE_END_VERSIONED_NAMESPACE_DECL
00118 
00119 #include /**/ "ace/post.h"
00120 #endif /* _SERVICE_MANAGER_H */

Generated on Thu Nov 9 09:42:03 2006 for ACE by doxygen 1.3.6