Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
HydraExpress Servlet Development Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

6.4 Defining Filters, Servlets, and Listeners

Each filter, servlet, or listener implementation must contain a macro that expands to a create function. The Agent uses this function to load an instance of the class.

The name of each macro starts with RWSF_DEFINE. HydraExpress includes two macros for each type of object, as shown in Table 2:

Table 2: Macros for defining filters, servlets, and listeners

Macro Expands to Function Name
RWSF_DEFINE_SERVLET(ServletClass) createServletClass
RWSF_DEFINE_SERVLET_NAME(ServletClass, functionName) functionName
RWSF_DEFINE_LISTENER(ListenerClass) createListenerClass
RWSF_DEFINE_LISTENER_NAME(ListenerClass, functionName) functionName
RWSF_DEFINE_FILTER(FilterClass) createFilterClass
RWSF_DEFINE_FILTER_NAME(FilterClass, functionName) functionName

Of the two versions of each servlet, listener, and filter macro in Table 2, the first listed uses the default function name "create<typeofClass>". For example, the macro RWSF_DEFINE_SERVLET(MyServlet) expands to the function createMyServlet in the class, MyServlet. The Agent uses the function to construct an instance of the servlet.

This is referenced in the servlet configuration file web.xml:

The second macro, RWSF_DEFINE_SERVLET_NAME(ServletClass, functionName) allows you to create a custom function name that is more relevant to your own applications, such as:

In this example, the function name will be generateServlet instead of createServletClass, and web.xml will define the servlet like this:

Note the servlet configuration above indicates that class MyServlet has been built into the shared library, MyServlet_library.

See Chapter 4 for information on adding filters, listeners, and servlets to the servlet container.



Previous fileTop of DocumentContentsIndex pageNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.