#include <XmlRpcDaemon.h>
Inheritance diagram for LiveSupport::Scheduler::XmlRpcDaemon:
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:
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" >
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. |
LiveSupport::Scheduler::XmlRpcDaemon::XmlRpcDaemon | ( | void | ) | throw () [inline, protected] |
virtual LiveSupport::Scheduler::XmlRpcDaemon::~XmlRpcDaemon | ( | void | ) | throw () [inline, protected, virtual] |
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.
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.
element | the XML element to configure the daemon from. |
std::invalid_argument | if the supplied XML element contains bad configuraiton information | |
std::logic_error | if the daemon has already been configured. |
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.
element | the XML element to configure the XML-RPC daemon from. |
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.
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().
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.
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.
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.
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.
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).
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] |
void LiveSupport::Scheduler::XmlRpcDaemon::setBackground | ( | const bool | background | ) | throw () [inline] |
Set if the XML-RPC server should fork into background.
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().
std::logic_error | if the daemon has not yet been configured. |
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.
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.
std::logic_error | if startup could not succeed. |
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.
std::logic_error | if the daemon has not yet been configured. |
Definition at line 336 of file XmlRpcDaemon.cxx.
References checkForConfiguration().