org.riotfamily.common.web.servlet
Class ReloadableDispatcherServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.springframework.web.servlet.HttpServletBean
              extended by org.springframework.web.servlet.FrameworkServlet
                  extended by org.springframework.web.servlet.DispatcherServlet
                      extended by org.riotfamily.common.web.servlet.ReloadableDispatcherServlet
All Implemented Interfaces:
Serializable, EventListener, Servlet, ServletConfig, ConfigurableBean, ApplicationListener

public class ReloadableDispatcherServlet
extends DispatcherServlet
implements ConfigurableBean

DispatcherServlet that checks whether one of the configuration files has been modified. If a change is detected the servlet is re-initalized and the underlying BeanFactory is refreshed.

As checks are performed upon each request you might want to set the reloadable init parameter to false when used in a production environment. Alternatively you can add a ReloadableDispatcherServletConfig bean to your ApplicationContext which allows you to set the reloadable property without modifying the web.xml.

Author:
Felix Gnass [fgnass at neteye dot de], Jan-Frederic Linde [jfl at neteye dot de]
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.springframework.web.servlet.DispatcherServlet
HANDLER_ADAPTER_BEAN_NAME, HANDLER_EXCEPTION_RESOLVER_BEAN_NAME, HANDLER_EXECUTION_CHAIN_ATTRIBUTE, HANDLER_MAPPING_BEAN_NAME, LOCALE_RESOLVER_ATTRIBUTE, LOCALE_RESOLVER_BEAN_NAME, MULTIPART_RESOLVER_BEAN_NAME, PAGE_NOT_FOUND_LOG_CATEGORY, pageNotFoundLogger, REQUEST_TO_VIEW_NAME_TRANSLATOR_BEAN_NAME, THEME_RESOLVER_ATTRIBUTE, THEME_RESOLVER_BEAN_NAME, THEME_SOURCE_ATTRIBUTE, VIEW_RESOLVER_BEAN_NAME, WEB_APPLICATION_CONTEXT_ATTRIBUTE
 
Fields inherited from class org.springframework.web.servlet.FrameworkServlet
DEFAULT_CONTEXT_CLASS, DEFAULT_NAMESPACE_SUFFIX, SERVLET_CONTEXT_PREFIX
 
Fields inherited from class org.springframework.web.servlet.HttpServletBean
logger
 
Constructor Summary
ReloadableDispatcherServlet()
           
 
Method Summary
 void configure()
           
protected  void doDispatch(HttpServletRequest request, HttpServletResponse response)
           
 Class<? extends ApplicationContext> getContextClass()
           
 boolean isReloadable()
           
protected  void onRefresh(ApplicationContext context)
           
 void setReloadable(boolean reloadable)
           
 
Methods inherited from class org.springframework.web.servlet.DispatcherServlet
buildLocaleContext, checkMultipart, cleanupMultipart, createDefaultStrategy, doService, getDefaultStrategies, getDefaultStrategy, getDefaultViewName, getHandler, getHandlerAdapter, getLastModified, getMultipartResolver, getThemeSource, initStrategies, noHandlerFound, processHandlerException, render, resolveViewName, setCleanupAfterInclude, setDetectAllHandlerAdapters, setDetectAllHandlerExceptionResolvers, setDetectAllHandlerMappings, setDetectAllViewResolvers, setThreadContextInheritable
 
Methods inherited from class org.springframework.web.servlet.FrameworkServlet
createWebApplicationContext, destroy, doDelete, doGet, doOptions, doPost, doPut, doTrace, findWebApplicationContext, getContextAttribute, getContextConfigLocation, getNamespace, getServletContextAttributeName, getUsernameForRequest, getWebApplicationContext, initFrameworkServlet, initServletBean, initWebApplicationContext, onApplicationEvent, postProcessWebApplicationContext, processRequest, refresh, setContextAttribute, setContextClass, setContextConfigLocation, setDispatchOptionsRequest, setDispatchTraceRequest, setNamespace, setPublishContext, setPublishEvents
 
Methods inherited from class org.springframework.web.servlet.HttpServletBean
addRequiredProperty, getServletContext, getServletName, init, initBeanWrapper
 
Methods inherited from class javax.servlet.http.HttpServlet
doHead, service, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletInfo, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReloadableDispatcherServlet

public ReloadableDispatcherServlet()
Method Detail

getContextClass

public Class<? extends ApplicationContext> getContextClass()
Overrides:
getContextClass in class FrameworkServlet

setReloadable

public void setReloadable(boolean reloadable)

isReloadable

public boolean isReloadable()
Specified by:
isReloadable in interface ConfigurableBean

onRefresh

protected void onRefresh(ApplicationContext context)
                  throws BeansException
Overrides:
onRefresh in class DispatcherServlet
Throws:
BeansException

doDispatch

protected void doDispatch(HttpServletRequest request,
                          HttpServletResponse response)
                   throws Exception
Overrides:
doDispatch in class DispatcherServlet
Throws:
Exception

configure

public void configure()
Specified by:
configure in interface ConfigurableBean