rwsf::GenericServletrwsf::Servlet
destroy() GenericServlet() getInitParameter() |
getInitParameterNames() getServletConfig() getServletContext() |
getServletInfo() getServletName() init() |
log() ~GenericServlet() |
#include rwsf/servlet/GenericServlet.h
rwsf::GenericServlet is an abstract class that contains a basic framework for a C++ servlet. The class implements specific functionality beyond that offered by rwsf::Servlet. For flexibility, a servlet that does not service HTTP requests may derive from rwsf::GenericServlet and override the pure virtual service() function inherited from rwsf::Servlet.
In practice, the HydraExpress Agent serves HTTP requests. Most HydraExpress servlets derive from rwsf::HttpServlet.
GenericServlet();
Default constructor. Creates an uninitialized servlet.
virtual ~GenericServlet();
Destructor.
void destroy();
Implements method in rwsf::Servlet
Base class documentation:
Pure virtual function. In derived classes, warns the servlet that the Agent has removed the servlet. The destroy() function gives the servlet a chance to perform cleanup tasks and deallocate resources. The Agent will 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.
Implementation documentation:
This method is called by the Agent when this servlet is about to be taken out of service. All cleanup for a servlet should be done in this method rather than in the servlet destructor.
std::string getInitParameter(const std::string & name) const;
Returns the value of the initialization parameter name. Initialization parameters are configured in the deployment descriptor. If the name is not found, returns the empty string. Parameter name comparisons are case-sensitive. To access servlet context initialization parameters use getServletContext().
rwsf::Enumeration< std::string > getInitParameterNames() const;
Returns an enumeration of all the parameter names defined for this servlet in the deployment descriptor. When the deployment descriptor defines no initialization parameters, the enumeration contains no elements. To access servlet context initialization parameter names use getServletContext().
rwsf::ServletConfig getServletConfig() const;
Reimplements method in rwsf::Servlet
Base class documentation:
Returns the rwsf::ServletConfig object that was used to initialize this servlet. The rwsf::ServletConfig object contains initialization and startup parameters for this servlet.
Implementation documentation:
Returns the rwsf::ServletConfig object for this servlet.
rwsf::ServletContext getServletContext() const;
Returns the servlet context for this object. This is a convenience function equivalent to calling getServletConfig().getServletContext().
std::string getServletInfo() const;
Implements method in rwsf::Servlet
Base class documentation:
Returns a string describing this servlet. By convention, the string typically includes information on the servlet author, version, and copyright.
Implementation documentation:
Returns information about this servlet. In rwsf::GenericServlet, returns the empty string.
std::string getServletName() const;
Returns the name of this servlet as defined by the servlet-name element of the deployment descriptor.
void init(const rwsf::ServletConfig & config);
Implements method in rwsf::Servlet
Base class documentation:
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 will not place the servlet into service and the servlet will not receive requests.
Implementation documentation:
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. All resource allocation for a servlet should be done in this method rather than in the servlet constructor.
A derived class that overrides this function must call the parent init() function. Derived classes should throw rwsf::ServletUnavailableException to indicate failure. If this function throws an exception, the Agent will not place the servlet into service and the servlet will not receive requests. Note that, due to C++ scoping rules, the derived servlet should also override the signature that takes no arguments. Only one of the signatures should contain initialization code; the other signature simply forwards to the parent init().
void init();
Initializes the servlet. After this function returns, the Agent is free to call the service method with requests. All resource allocation for a servlet should be done in this method rather than in the servlet constructor.
A derived class that overrides this function must call the parent init() function. Derived classes should throw rwsf::ServletUnavailableException to indicate failure. If this function throws an exception, the Agent will not place the servlet into service and the servlet will not receive requests. Due to C++ scoping rules, a derived servlet that overrides this method should also override the signature that takes an rwsf::ServletConfig. Only one of the signatures should contain initialization code; the other signature simply forwards to the parent init().
void log(const std::string & message) const;
Writes message to the Agent log file. For more information on logging and how to control the logging output, see the HydraExpress Servlet Development Guide.
void log(const std::string & message, const rwsf::Exception & e) const;
Writes message and the string returned by e.why() to the Agent log file. For more information on logging and how to control the logging output see the HydraSCA User's Guide.
© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.