org.codehaus.groovy.grails.web.servlet
Class GrailsDispatcherServlet

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.codehaus.groovy.grails.web.servlet.GrailsDispatcherServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, org.springframework.beans.factory.Aware, org.springframework.context.EnvironmentAware
Direct Known Subclasses:
ErrorHandlingServlet

public class GrailsDispatcherServlet
extends org.springframework.web.servlet.DispatcherServlet

Handles incoming requests for Grails.

Loads the Spring configuration based on the Grails application in the parent application context.

Since:
Jul 2, 2005
See Also:
Serialized Form

Field Summary
protected  org.springframework.web.servlet.HandlerInterceptor[] interceptors
           
protected  org.springframework.web.servlet.ViewResolver layoutViewResolver
           
protected  org.springframework.web.multipart.MultipartResolver multipartResolver
           
 
Fields inherited from class org.springframework.web.servlet.DispatcherServlet
FLASH_MAP_MANAGER_BEAN_NAME, HANDLER_ADAPTER_BEAN_NAME, HANDLER_EXCEPTION_RESOLVER_BEAN_NAME, 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
GrailsDispatcherServlet()
          Constructor.
 
Method Summary
protected  javax.servlet.http.HttpServletRequest checkMultipart(javax.servlet.http.HttpServletRequest request)
          Convert the request into a multipart request.
protected  void copyParamsFromPreviousRequest(org.springframework.web.context.request.RequestAttributes previousRequestAttributes, GrailsWebRequest requestAttributes)
           
protected  org.springframework.web.context.WebApplicationContext createWebApplicationContext(org.springframework.web.context.WebApplicationContext parent)
           
 void destroy()
           
protected  void doDispatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  org.springframework.web.servlet.HandlerInterceptor[] establishInterceptors(org.springframework.web.context.WebApplicationContext webContext)
          Evalutes the given WebApplicationContext for all HandlerInterceptor and WebRequestInterceptor instances
 org.springframework.web.servlet.HandlerExecutionChain getHandler(javax.servlet.http.HttpServletRequest request)
           
protected  void initFrameworkServlet()
           
protected  void initStrategies(org.springframework.context.ApplicationContext context)
           
 void setApplication(org.codehaus.groovy.grails.commons.GrailsApplication application)
          Dependency injection for the application.
protected  void triggerAfterCompletion(org.springframework.web.servlet.HandlerExecutionChain mappedHandler, int interceptorIndex, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.Exception ex)
          Trigger afterCompletion callbacks on the mapped HandlerInterceptors.
protected  javax.servlet.http.HttpServletResponse useWrappedOrOriginalResponse(javax.servlet.http.HttpServletResponse response)
           
 
Methods inherited from class org.springframework.web.servlet.DispatcherServlet
buildLocaleContext, cleanupMultipart, createDefaultStrategy, doService, getDefaultStrategies, getDefaultStrategy, getDefaultViewName, getHandler, getHandlerAdapter, getMultipartResolver, getThemeSource, noHandlerFound, onRefresh, processHandlerException, render, resolveViewName, setCleanupAfterInclude, setDetectAllHandlerAdapters, setDetectAllHandlerExceptionResolvers, setDetectAllHandlerMappings, setDetectAllViewResolvers
 
Methods inherited from class org.springframework.web.servlet.FrameworkServlet
applyInitializers, configureAndRefreshWebApplicationContext, createWebApplicationContext, doDelete, doGet, doOptions, doPost, doPut, doTrace, findWebApplicationContext, getContextAttribute, getContextClass, getContextConfigLocation, getContextId, getNamespace, getServletContextAttributeName, getUsernameForRequest, getWebApplicationContext, initServletBean, initWebApplicationContext, onApplicationEvent, postProcessWebApplicationContext, processRequest, refresh, setContextAttribute, setContextClass, setContextConfigLocation, setContextId, setContextInitializerClasses, setContextInitializers, setDispatchOptionsRequest, setDispatchTraceRequest, setNamespace, setPublishContext, setPublishEvents, setThreadContextInheritable
 
Methods inherited from class org.springframework.web.servlet.HttpServletBean
addRequiredProperty, getServletContext, getServletName, init, initBeanWrapper, setEnvironment
 
Methods inherited from class javax.servlet.http.HttpServlet
doHead, getLastModified, 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
 

Field Detail

interceptors

protected org.springframework.web.servlet.HandlerInterceptor[] interceptors

multipartResolver

protected org.springframework.web.multipart.MultipartResolver multipartResolver

layoutViewResolver

protected org.springframework.web.servlet.ViewResolver layoutViewResolver
Constructor Detail

GrailsDispatcherServlet

public GrailsDispatcherServlet()
Constructor.

Method Detail

initFrameworkServlet

protected void initFrameworkServlet()
                             throws javax.servlet.ServletException,
                                    org.springframework.beans.BeansException
Overrides:
initFrameworkServlet in class org.springframework.web.servlet.FrameworkServlet
Throws:
javax.servlet.ServletException
org.springframework.beans.BeansException

initStrategies

protected void initStrategies(org.springframework.context.ApplicationContext context)
Overrides:
initStrategies in class org.springframework.web.servlet.DispatcherServlet

createWebApplicationContext

protected org.springframework.web.context.WebApplicationContext createWebApplicationContext(org.springframework.web.context.WebApplicationContext parent)
                                                                                     throws org.springframework.beans.BeansException
Overrides:
createWebApplicationContext in class org.springframework.web.servlet.FrameworkServlet
Throws:
org.springframework.beans.BeansException

establishInterceptors

protected org.springframework.web.servlet.HandlerInterceptor[] establishInterceptors(org.springframework.web.context.WebApplicationContext webContext)
Evalutes the given WebApplicationContext for all HandlerInterceptor and WebRequestInterceptor instances

Parameters:
webContext - The WebApplicationContext
Returns:
An array of HandlerInterceptor instances

destroy

public void destroy()
Specified by:
destroy in interface javax.servlet.Servlet
Overrides:
destroy in class org.springframework.web.servlet.FrameworkServlet

setApplication

public void setApplication(org.codehaus.groovy.grails.commons.GrailsApplication application)
Dependency injection for the application.

Parameters:
application - the application

doDispatch

protected void doDispatch(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response)
                   throws java.lang.Exception
Overrides:
doDispatch in class org.springframework.web.servlet.DispatcherServlet
Throws:
java.lang.Exception

useWrappedOrOriginalResponse

protected javax.servlet.http.HttpServletResponse useWrappedOrOriginalResponse(javax.servlet.http.HttpServletResponse response)

copyParamsFromPreviousRequest

protected void copyParamsFromPreviousRequest(org.springframework.web.context.request.RequestAttributes previousRequestAttributes,
                                             GrailsWebRequest requestAttributes)

triggerAfterCompletion

protected void triggerAfterCompletion(org.springframework.web.servlet.HandlerExecutionChain mappedHandler,
                                      int interceptorIndex,
                                      javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response,
                                      java.lang.Exception ex)
                               throws java.lang.Exception
Trigger afterCompletion callbacks on the mapped HandlerInterceptors. Will just invoke afterCompletion for all interceptors whose preHandle invocation has successfully completed and returned true.

Parameters:
mappedHandler - the mapped HandlerExecutionChain
interceptorIndex - index of last interceptor that successfully completed
ex - Exception thrown on handler execution, or null if none
Throws:
java.lang.Exception
See Also:
HandlerInterceptor.afterCompletion(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, java.lang.Exception)

checkMultipart

protected javax.servlet.http.HttpServletRequest checkMultipart(javax.servlet.http.HttpServletRequest request)
                                                        throws org.springframework.web.multipart.MultipartException
Convert the request into a multipart request. If no multipart resolver is set, simply use the existing request.

Overrides:
checkMultipart in class org.springframework.web.servlet.DispatcherServlet
Parameters:
request - current HTTP request
Returns:
the processed request (multipart wrapper if necessary)
Throws:
org.springframework.web.multipart.MultipartException

getHandler

public org.springframework.web.servlet.HandlerExecutionChain getHandler(javax.servlet.http.HttpServletRequest request)
                                                                 throws java.lang.Exception
Overrides:
getHandler in class org.springframework.web.servlet.DispatcherServlet
Throws:
java.lang.Exception