org.apache.hivemind.servlet
Class HiveMindFilter

java.lang.Object
  |
  +--org.apache.hivemind.servlet.HiveMindFilter
All Implemented Interfaces:
javax.servlet.Filter

public class HiveMindFilter
extends java.lang.Object
implements javax.servlet.Filter

Servlet filter that constructs the Registry at startup. It ensures that each request is properly terminated with a call to ThreadEventNotifier.fireThreadCleanup(). It also makes the Registry available during the request by storing it as a request attribute.

Author:
Howard Lewis Ship

Field Summary
static java.lang.String CONTEXT_KEY
          ServletContext attribute key that stores the Registry.
static java.lang.String REQUEST_KEY
          Request attribute key that stores the Registry.
 
Constructor Summary
HiveMindFilter()
           
 
Method Summary
 void destroy()
          Invokes Registry.shutdown().
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, javax.servlet.FilterChain chain)
          Passes the request to the filter chain, but then invokes ThreadEventNotifier#fireThreadCleanup() (from a finally block).
static Registry getRegistry(javax.servlet.http.HttpServletRequest request)
          Returns the Registry that was stored as a request attribute in doFilter(ServletRequest, ServletResponse, FilterChain).
protected  java.util.Locale getRegistryLocale()
          Returns the default Locale.
 void init(javax.servlet.FilterConfig config)
          Constructs a Registry and stores it into the ServletContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTEXT_KEY

public static final java.lang.String CONTEXT_KEY
ServletContext attribute key that stores the Registry.

See Also:
Constant Field Values

REQUEST_KEY

public static final java.lang.String REQUEST_KEY
Request attribute key that stores the Registry.

See Also:
Constant Field Values
Constructor Detail

HiveMindFilter

public HiveMindFilter()
Method Detail

init

public void init(javax.servlet.FilterConfig config)
          throws javax.servlet.ServletException
Constructs a Registry and stores it into the ServletContext. Any exception throws is logged.

Specified by:
init in interface javax.servlet.Filter
javax.servlet.ServletException

getRegistryLocale

protected java.util.Locale getRegistryLocale()
Returns the default Locale. Subclasses may override to select a particular locale for the Registry.


doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response,
                     javax.servlet.FilterChain chain)
              throws java.io.IOException,
                     javax.servlet.ServletException
Passes the request to the filter chain, but then invokes ThreadEventNotifier#fireThreadCleanup() (from a finally block).

Specified by:
doFilter in interface javax.servlet.Filter
java.io.IOException
javax.servlet.ServletException

destroy

public void destroy()
Invokes Registry.shutdown().

Specified by:
destroy in interface javax.servlet.Filter

getRegistry

public static Registry getRegistry(javax.servlet.http.HttpServletRequest request)
Returns the Registry that was stored as a request attribute in doFilter(ServletRequest, ServletResponse, FilterChain).