HydraExpress™ C++ API Reference Guide

Product Documentation:
   HydraExpress C++
Documentation Home
List of all members | Public Member Functions
rwsf::Servlet Class Referenceabstract

Abstract base class for servlets. More...

#include <rwsf/servlet/Servlet.h>

Inheritance diagram for rwsf::Servlet:
rwsf::GenericServlet rwsf::HttpServlet rwsf::WebServiceServlet

Public Member Functions

virtual ~Servlet ()
 
virtual void destroy ()=0
 
virtual rwsf::ServletConfig getServletConfig () const
 
virtual std::string getServletInfo () const =0
 
virtual void init (const rwsf::ServletConfig &config)=0
 
virtual void service (rwsf::ServletRequest &req, rwsf::ServletResponse &res)=0
 

Detailed Description

rwsf::Servlet is an abstract base class for servlets. A servlet is a small piece of code that executes inside an Agent running on a server. You would typically use one of the derived classes for creating your own servlets. For example:

Constructor & Destructor Documentation

virtual rwsf::Servlet::~Servlet ( )
virtual

Destructor.

Member Function Documentation

virtual void rwsf::Servlet::destroy ( )
pure virtual

Pure virtual function. In derived classes, warns the servlet that the Agent has removed the servlet. The destroy() function allows the servlet to perform cleanup tasks and deallocate resources. The Agent does not forward requests to the servlet after calling this function. A servlet should perform all resource deallocation and cleanup tasks in the destroy() method rather than the servlet destructor.

Implemented in rwsf::WebServiceServlet, and rwsf::GenericServlet.

virtual rwsf::ServletConfig rwsf::Servlet::getServletConfig ( ) const
virtual

Returns the rwsf::ServletConfig object that was used to initialize this servlet. The rwsf::ServletConfig object contains initialization and startup parameters for this servlet.

Reimplemented in rwsf::GenericServlet.

virtual std::string rwsf::Servlet::getServletInfo ( ) const
pure virtual

Returns a string describing this servlet. By convention, the string typically includes information on the servlet author, version, and copyright.

Implemented in rwsf::GenericServlet.

virtual void rwsf::Servlet::init ( const rwsf::ServletConfig config)
pure virtual

Pure virtual function. In derived classes, initializes the servlet. After this function returns, the Agent is free to call the service() method with requests. The config object contains initialization and startup parameters. A servlet should perform all resource allocation in the init() method.

Derived classes should throw rwsf::ServletUnavailableException to indicate failure. If this function throws an exception, the Agent does not place the servlet into service and the servlet does not receive requests.

Implemented in rwsf::GenericServlet, and rwsf::WebServiceServlet.

virtual void rwsf::Servlet::service ( rwsf::ServletRequest req,
rwsf::ServletResponse res 
)
pure virtual

Pure virtual function. In derived classes, the Agent calls this method when a request arrives for this servlet. The Agent only forwards requests after calling the init() method. This method may be called by multiple threads, so applications should take care to guard resources that might be shared across multiple threads.

Implemented in rwsf::HttpServlet.

Copyright © 2020 Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is registered trademark of Rogue Wave Software, Inc. in the United States and other countries, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.