Plugin servlet filter hooks


Plugin servlet filter hook classes operate on a search request before it begins Funnelback processing, and after result rendering, just before a response is returned to the user. For general customization, the Plugin search lifecycle interface is an easier and more flexible option, however in some advanced cases, it is desirable to use this lower level customization system.

One specific capability enabled by this type of hook is auditing or direct manipulation of the specific byte output returned to Funnelback users.

When developing a custom servlet filter hooks it will be useful to be familiar with Java’s servlet filter mechanism, on which this mechanism is based.

Interface methods

To implement a custom servlet filter hook, you will need to implement the SearchServletFilterHook interface.

SearchServletFilterHook provides three different methods:

  • ServletRequest preFilterRequest(SearchServletFilterHookContext context, ServletRequest request)

  • ServletResponse preFilterResponse(SearchServletFilterHookContext context, ServletRequest request, ServletResponse response)

  • void postFilterResponse(SearchServletFilterHookContext context, ServletRequest request, ServletResponse response)

The methods provided by this interface, preFilterRequest, preFilterResponse and postFilterResponse, allow the hook class to intercept and alter the ServletRequest and ServletResponse objects as necessary. There is also access to the profile configuration for the request, via SearchServletFilterHookContext#getCurrentProfileConfig()

Note that access to the Funnelback search transaction object model is not available from within this hook class, and that all requests to Funnelback’s search interface will be processed through these methods, so the performance of their implementations must be considered during development.

Example: x-forwarded-for-edit

Manipulates the X-Forwarded-For header of HTTP Search Requests.

© 2015- Squiz Pty Ltd