org.apache.hivemind.servlet
Class AutoloadingHiveMindFilter

java.lang.Object
  extended by org.apache.hivemind.servlet.AutoloadingHiveMindFilter
All Implemented Interfaces:
javax.servlet.Filter

public class AutoloadingHiveMindFilter
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. Autodetects hivemind modules by calling RegistryBuilder.autoDetectModules(). Specializations can override the addWebInfDescriptor(ServletContext, ClassResolver, RegistryBuilder) method. to add custom modules.

Author:
Howard Lewis Ship

Constructor Summary
AutoloadingHiveMindFilter()
           
 
Method Summary
protected  void addDefaultModules(RegistryBuilder builder, ClassResolver resolver)
           
protected  void addWebInfDescriptor(javax.servlet.ServletContext context, ClassResolver resolver, RegistryBuilder builder)
          Invoked from constructRegistry(FilterConfig) to add an web specific application descriptor if one exists.
protected  Registry constructRegistry(javax.servlet.FilterConfig config)
          Invoked from init(FilterConfig) to actually construct the Registry.
 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 Registry.cleanupThread()   (from a finally block).
static Registry getRegistry(javax.servlet.http.HttpServletRequest request)
          Returns the Registry that was stored as a request attribute inside method 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.
static void rebuildRegistry(javax.servlet.http.HttpServletRequest request)
          Sets a flag in the request that will cause the current Registry to be shutdown and replaced with a new Registry (at the end of the current request).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoloadingHiveMindFilter

public AutoloadingHiveMindFilter()
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
Throws:
javax.servlet.ServletException

constructRegistry

protected Registry constructRegistry(javax.servlet.FilterConfig config)
Invoked from init(FilterConfig) to actually construct the Registry. Subclasses may override if they have specific initialization needs, or have nonstandard rules for finding HiveMind module deployment descriptors.


addWebInfDescriptor

protected void addWebInfDescriptor(javax.servlet.ServletContext context,
                                   ClassResolver resolver,
                                   RegistryBuilder builder)
Invoked from constructRegistry(FilterConfig) to add an web specific application descriptor if one exists.


getRegistryLocale

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


addDefaultModules

protected void addDefaultModules(RegistryBuilder builder,
                                 ClassResolver resolver)

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 Registry.cleanupThread()   (from a finally block).

Specified by:
doFilter in interface javax.servlet.Filter
Throws:
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 inside method doFilter(ServletRequest, ServletResponse, FilterChain).


rebuildRegistry

public static void rebuildRegistry(javax.servlet.http.HttpServletRequest request)
Sets a flag in the request that will cause the current Registry to be shutdown and replaced with a new Registry (at the end of the current request).



Copyright © 2003-2007 Apache Software Foundation. All Rights Reserved.