LiveSupport::Scheduler::XmlRpcDaemon Class Reference

#include <XmlRpcDaemon.h>

Inheritance diagram for LiveSupport::Scheduler::XmlRpcDaemon:

[legend]
Collaboration diagram for LiveSupport::Scheduler::XmlRpcDaemon:

[legend]
List of all members.

Detailed Description

A generic XML-RPC daemon, that has to be sublclassed to provide real functionality.

To use this class, subclass it, and override the configure() and registerXmlRpcFunctions() functions.

The typical usage of the XmlRpcDaemon is as follows. To start the daemon:

  1. create an instance of a subclass of XmlRpcDaemon
  2. call the configure() method with a proper XML element
  3. optionally call setBackground()
  4. call start() to start the daemon
Stopping the daemon is similar:
  1. create an instance of a subclass of XmlRpcDaemon
  2. call the configure() method with a proper XML element if it has not yet been configured
  3. call stop() to stop the daemon

The structure of the XML configuration element used to configure the XML-RPC daemon is as follows:


  <xmlRpcDaemon xmlrpchost="hostname" 
="" xmlrpcport="portnumber" 
="" pidfilename="pidfilename" 
="" background="true" 
="">
  

The DTD for the above is:


  <!ELEMENT xmlRpcDaemon EMPTY >
  <!ATTLIST xmlRpcDaemon xmlRpcHost   CDATA          REQUIRED >
  <!ATTLIST xmlRpcDaemon xmlRpcPort   NMTOKEN        REQUIRED >
  <!ATTLIST xmlRpcDaemon pidFileName  CDATA          REQUIRED >
  <!ATTLIST xmlRpcDaemon background   (true|false)   "true"    >
  

Author:
Author
fgerlits
Version:
Revision
2329

Definition at line 124 of file XmlRpcDaemon.h.

Public Member Functions

const bool isConfigured (void) const throw ()
 Tell if the daemon has already been configured.
void setBackground (const bool background) throw ()
 Set if the XML-RPC server should fork into background.
const bool getBackground (void) const throw ()
 Tell if the XML-RPC server will fork into background.
virtual void configure (const xmlpp::Element &element)=0 throw (std::invalid_argument, std::logic_error)
 Configure the daemon based on the XML element supplied.
const std::string getXmlRpcHost (void) const throw (std::logic_error)
 Tell the host name of the XML-RPC server the daemon is listening on.
const unsigned int getXmlRpcPort (void) const throw (std::logic_error)
 Tell the port of the XML-RPC server the daemon is listening on.
const std::string getPidFileName (void) const throw (std::logic_error)
 Tell the file name where the daemon stores its process id.
void start (void) throw (std::logic_error)
 Start the daemon.
bool isRunning (void) throw (std::logic_error)
 Tell if the daemon is running.
void stop (void) throw (std::logic_error)
 Stop the daemon.
virtual void shutdown (void) throw (std::logic_error)
 Shut down the daemon.

Static Public Member Functions

static const std::string getConfigElementName (void) throw ()
 Return the name of the XML element this object expects to be sent to a call to configure().

Protected Member Functions

 XmlRpcDaemon (void) throw ()
 Default constructor.
virtual ~XmlRpcDaemon (void) throw ()
 Virtual destructor.
void checkForConfiguration (void) const throw (std::logic_error)
 Check if the daemon has already been configured, and raise an exception if not so.
void configureXmlRpcDaemon (const xmlpp::Element &element) throw (std::invalid_argument, std::logic_error)
 Configure the XML-RPC daemon itself.
virtual void registerXmlRpcFunctions (Ptr< XmlRpcServer >::Ref xmlRpcServer)=0 throw (std::logic_error)
 Register your XML-RPC functions by implementing this function.
virtual void startup (void) throw (std::logic_error)
 Execute any calls when the daemon is starting up.


Constructor & Destructor Documentation

LiveSupport::Scheduler::XmlRpcDaemon::XmlRpcDaemon ( void   )  throw () [inline, protected]

Default constructor.

Definition at line 196 of file XmlRpcDaemon.h.

virtual LiveSupport::Scheduler::XmlRpcDaemon::~XmlRpcDaemon ( void   )  throw () [inline, protected, virtual]

Virtual destructor.

Definition at line 207 of file XmlRpcDaemon.h.


Member Function Documentation

void LiveSupport::Scheduler::XmlRpcDaemon::checkForConfiguration ( void   )  const throw (std::logic_error) [inline, protected]

Check if the daemon has already been configured, and raise an exception if not so.

Exceptions:
std::logic_error if the daemon has not yet been configured.

Definition at line 219 of file XmlRpcDaemon.h.

Referenced by getPidFileName(), getXmlRpcHost(), getXmlRpcPort(), isRunning(), shutdown(), start(), and stop().

virtual void LiveSupport::Scheduler::XmlRpcDaemon::configure ( const xmlpp::Element &  element  )  throw (std::invalid_argument, std::logic_error) [pure virtual]

Configure the daemon based on the XML element supplied.

Implemtors should call the funtion configureXmlRpcDaemon from here with a proper <xmlRpcDaemon> element.

Parameters:
element the XML element to configure the daemon from.
Exceptions:
std::invalid_argument if the supplied XML element contains bad configuraiton information
std::logic_error if the daemon has already been configured.
See also:
configureXmlRpcDaemon

Implemented in LiveSupport::Scheduler::SchedulerDaemon.

void XmlRpcDaemon::configureXmlRpcDaemon ( const xmlpp::Element &  element  )  throw (std::invalid_argument, std::logic_error) [protected]

Configure the XML-RPC daemon itself.

Pass an <xmlRpcDaemon> element to this function.

Parameters:
element the XML element to configure the XML-RPC daemon from.
Exceptions:
std::invalid_argument if the supplied XML element contains bad configuraiton information
std::logic_error if the daemon has already been configured.

Definition at line 120 of file XmlRpcDaemon.cxx.

References confPidFileNameAttr, confXmlRpcHostAttr, and confXmlRpcPortAttr.

const bool LiveSupport::Scheduler::XmlRpcDaemon::getBackground ( void   )  const throw () [inline]

Tell if the XML-RPC server will fork into background.

Returns:
if true, the XML-RPC server will fork into background, otherwise not (good for debugging).

Definition at line 310 of file XmlRpcDaemon.h.

static const std::string LiveSupport::Scheduler::XmlRpcDaemon::getConfigElementName ( void   )  throw () [inline, static]

Return the name of the XML element this object expects to be sent to a call to configure().

Returns:
the name of the expected XML configuration element.

Definition at line 272 of file XmlRpcDaemon.h.

Referenced by LiveSupport::Scheduler::SchedulerDaemon::configure().

const std::string LiveSupport::Scheduler::XmlRpcDaemon::getPidFileName ( void   )  const throw (std::logic_error) [inline]

Tell the file name where the daemon stores its process id.

Returns:
the name of the file where the process id is stored.
Exceptions:
std::logic_error if the daemon has not yet been configured.

Definition at line 375 of file XmlRpcDaemon.h.

References checkForConfiguration().

const std::string LiveSupport::Scheduler::XmlRpcDaemon::getXmlRpcHost ( void   )  const throw (std::logic_error) [inline]

Tell the host name of the XML-RPC server the daemon is listening on.

Returns:
the host name of the XML-RPC server the daemon is listening on.
Exceptions:
std::logic_error if the daemon has not yet been configured.

Definition at line 345 of file XmlRpcDaemon.h.

References checkForConfiguration().

const unsigned int LiveSupport::Scheduler::XmlRpcDaemon::getXmlRpcPort ( void   )  const throw (std::logic_error) [inline]

Tell the port of the XML-RPC server the daemon is listening on.

Returns:
the port of the XML-RPC server the daemon is listening on.
Exceptions:
std::logic_error if the daemon has not yet been configured.

Definition at line 361 of file XmlRpcDaemon.h.

References checkForConfiguration().

const bool LiveSupport::Scheduler::XmlRpcDaemon::isConfigured ( void   )  const throw () [inline]

Tell if the daemon has already been configured.

If so, an attempt to configure it again will result in an exception.

Returns:
true if the daemon has already been configured, false otherwise.

Definition at line 286 of file XmlRpcDaemon.h.

bool XmlRpcDaemon::isRunning ( void   )  throw (std::logic_error)

Tell if the daemon is running.

If there is a stale pid file stored for the daemon, it is removed during checking (and correctly false is returned).

Returns:
true of the daemon is running, false otherwise.
Exceptions:
std::logic_error if the daemon has not yet been configured.

Definition at line 314 of file XmlRpcDaemon.cxx.

References checkForConfiguration().

Referenced by start().

virtual void LiveSupport::Scheduler::XmlRpcDaemon::registerXmlRpcFunctions ( Ptr< XmlRpcServer >::Ref  xmlRpcServer  )  throw (std::logic_error) [protected, pure virtual]

Register your XML-RPC functions by implementing this function.

Referenced by startup().

void LiveSupport::Scheduler::XmlRpcDaemon::setBackground ( const bool  background  )  throw () [inline]

Set if the XML-RPC server should fork into background.

Parameters:
background if true, the XML-RPC server will fork into background, otherwise not (good for debugging).

Definition at line 298 of file XmlRpcDaemon.h.

void XmlRpcDaemon::shutdown ( void   )  throw (std::logic_error) [virtual]

Shut down the daemon.

This function is public only because the signal handler needs visibility to this function, which will call it. A call to stop() will trigger a signal that will call shutdown().

Exceptions:
std::logic_error if the daemon has not yet been configured.
See also:
stop

Reimplemented in LiveSupport::Scheduler::SchedulerDaemon.

Definition at line 351 of file XmlRpcDaemon.cxx.

References checkForConfiguration().

Referenced by LiveSupport::Scheduler::XmlRpcDaemonShutdownSignalHandler::handleSignal(), and LiveSupport::Scheduler::SchedulerDaemon::shutdown().

void XmlRpcDaemon::start ( void   )  throw (std::logic_error)

Start the daemon.

Exceptions:
std::logic_error if the daemon has not yet been configured.

Definition at line 274 of file XmlRpcDaemon.cxx.

References checkForConfiguration(), isRunning(), and startup().

void XmlRpcDaemon::startup ( void   )  throw (std::logic_error) [protected, virtual]

Execute any calls when the daemon is starting up.

All resources allocated here should be freed up in shutdown(). This function will only return when the daemon ha stopped running.

Exceptions:
std::logic_error if startup could not succeed.
See also:
shutdown

Reimplemented in LiveSupport::Scheduler::SchedulerDaemon.

Definition at line 298 of file XmlRpcDaemon.cxx.

References registerXmlRpcFunctions().

Referenced by start(), and LiveSupport::Scheduler::SchedulerDaemon::startup().

void XmlRpcDaemon::stop ( void   )  throw (std::logic_error)

Stop the daemon.

This function just sends a signal, which will result in shutdown() to get called eventually.

Exceptions:
std::logic_error if the daemon has not yet been configured.
See also:
shutdown

Definition at line 336 of file XmlRpcDaemon.cxx.

References checkForConfiguration().


The documentation for this class was generated from the following files:
Generated on Fri Sep 21 02:00:47 2007 for Campcaster by  1.4.7