2009/04/15 - Apache HiveMind has been retired.

For more information, please explore the Attic.

Apache > HiveMind
Apache
 
Font size:      

HiveMind Servlet Filter

HiveMind includes a feature to streamline the use of HiveMind within a web application: a servlet filter that can automatically construct the HiveMind Registry and ensure that end-of-request thread cleanup occurs.

The filter class is HiveMindFilter. It constructs a standard HiveMind Registry (and includes WEB-INF/hivemodule.xml, if present) when initialized, and will shutdown the Registry when the containing application is undeployed.

Each request will be terminated with a call to the Registry's cleanupThread() method, which will cleanup any thread-local values, including service implementations that are bound to the current thread.

The HiveMindFilter class includes a static method for accessing the Registry.

Deployment Descriptor

To make use of the filter, it must be declared inside the web deployment descriptor (web.xml). Filters can be attached to servlets, or URL patterns, or both. Here's an example:

<filter>
  <filter-name>HiveMindFilter</filter-name>
  <filter-class>org.apache.hivemind.servlet.HiveMindFilter</filter-class>
</filter>

<servlet>
  <servlet-name>MyServlet</servlet-name>
  <servlet-class>myco.servlets.MyServlet</servlet-class>
</servlet>

<filter-mapping>
  <filter-name>HiveMindFilter</filter-name>
  <servlet-name>MyServlet</servlet-name>
</filter-mapping>