Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Service_Manager.h

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

Generated on Mon Jun 16 11:21:11 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002