Base Class
#include <rwsf/servlet/Filter.h>
rwsf::Filter is the base class for filters. A filter processes the requests and responses for a resource. For example, a filter might compress or encode the response from a Web Service, transform an XML response into HTML, or adapt an incoming request.
The Agent loads filters during initialization. Each rwsf::Filter contains an rwsf::FilterConfig that holds the initialization parameters for the filter. The rwsf::FilterConfig object also provides access to the rwsf::ServletContext object that represents the context within which the filter is deployed.
virtual void destroy();
The Agent calls this function when the filter is removed from service. All cleanup for a filter should be done in this method rather than in the filter destructor.
virtual void doFilter(rwsf::ServletRequest& request, rwsf::ServletResponse& response, rwsf::FilterChain* chain) = 0;
Pure virtual function. Processes a request. In derived classes, the Agent calls this function for each request received from a client. A derived class uses the doFilter() function of the chain to invoke the next filter in the filter chain.
virtual rwsf::FilterConfig getFilterConfig() const;
Returns the rwsf::FilterConfig object that was used to initialize this filter.
virtual void init(const rwsf::FilterConfig& config);
This method is called by the Agent when this filter is first initialized. Override this method in a derived class to add initialization code. All resource allocation for a filter should be done in this method rather than in the filter constructor.
rwsf_DEFINE_FILTER(filterName)
Defines a function that returns a pointer to a new instance of class filterName. The macro names the function by prefacing filterName with the word "create". The Agent uses the function to construct an instance of the filter. For example, to deploy a filter that uses the macro below:
rwsf_DEFINE_FILTER(MyFilter)
the deployment descriptor for the filter should contain the following line, where dllName is the name of the shared library containing the filter:
<filter-class>dllName.createMyFilter</filter-class>
rwsf_DEFINE_FILTER_NAME(filterName, createMethod)
Defines a function named createMethod that returns an instance of class filterName. The Agent uses the function to construct an instance of the filter. For example, to deploy a filter that uses the macro below:
rwsf_DEFINE_FILTER(MyFilter, createMyFilterInstance)
the deployment descriptor for the filter should contain the following line, where dllName is the name of the shared library containing the filter:
<filter-class>dllName.createMyFilterInstance</filter-class>
©2004-2007 Copyright Quovadx, Inc. All Rights Reserved.
Quovadx and Rogue Wave are registered trademarks of Quovadx, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.