Groovy Documentation

com.vaadin.grails.terminal.gwt.server
[Java] Class RestartingApplicationHttpServletRequest

java.lang.Object
  javax.servlet.ServletRequestWrapper
      javax.servlet.http.HttpServletRequestWrapper
          com.vaadin.grails.terminal.gwt.server.RestartingApplicationHttpServletRequest

public class RestartingApplicationHttpServletRequest
extends HttpServletRequestWrapper

An HttpServletRequest wrapper implementation that guarantees the existence of a restartApplication request parameter by artificially setting it with a value of "true".

When the Grails Vaadin plugin determines that a Vaadin component's source code has changed, it will create an instance of this class to use when calling the Vaadin AbstractApplicationServlet that processes all Vaadin requests. This servlet will react to the artificially-set restartApplication request parameter and automatically reload a new Vaadin Application instance that reflects the changed source code.

Note: this class makes strict assumptions of Vaadin's internal implementation details. It is not intended to be used by end-users directly.

Authors:
Les Hazlewood
Since:
1.2


Field Summary
static String RESTART_TOKEN_SESSION_KEY

private Map parameterMap

private static String restartToken

 
Fields inherited from class HttpServletRequestWrapper
BASIC_AUTH, FORM_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH
 
Constructor Summary
RestartingApplicationHttpServletRequest(HttpServletRequest request)

 
Method Summary
String getParameter(String name)

Map getParameterMap()

Enumeration getParameterNames()

String[] getParameterValues(String name)

static String getRestartToken()

Returns a token value used to determine if a request's associated Vaadin application needs to be reloaded.

static void setRestartToken(String token)

Sets a unique token value used to trigger new Vaadin Application instances to be dynamically recreated after a Grails Vaadin component source-code change.

 
Methods inherited from class HttpServletRequestWrapper
getMethod, getHeaders, getHeader, login, logout, getParts, getQueryString, getCookies, getAuthType, getDateHeader, getHeaderNames, getIntHeader, getPathInfo, getPathTranslated, getContextPath, getRemoteUser, isUserInRole, getUserPrincipal, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, isRequestedSessionIdValid, isRequestedSessionIdFromCookie, isRequestedSessionIdFromURL, isRequestedSessionIdFromUrl, authenticate, getPart, getScheme, getProtocol, getInputStream, getAttribute, getContentType, getParameter, getContentLength, getLocalName, setAttribute, getLocalPort, getLocale, isWrapperFor, isWrapperFor, getReader, removeAttribute, getAttributeNames, getServerPort, getRequest, getServletContext, getCharacterEncoding, setCharacterEncoding, getParameterNames, getParameterValues, getParameterMap, getServerName, getRemoteAddr, getRemoteHost, getLocales, isSecure, getRequestDispatcher, getRealPath, getRemotePort, getLocalAddr, startAsync, startAsync, isAsyncStarted, isAsyncSupported, getAsyncContext, getDispatcherType, setRequest, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 
Methods inherited from class ServletRequestWrapper
getScheme, getProtocol, getInputStream, getAttribute, getContentType, getParameter, getContentLength, getLocalName, setAttribute, getLocalPort, getLocale, isWrapperFor, isWrapperFor, getReader, removeAttribute, getAttributeNames, getServerPort, getRequest, getServletContext, getCharacterEncoding, setCharacterEncoding, getParameterNames, getParameterValues, getParameterMap, getServerName, getRemoteAddr, getRemoteHost, getLocales, isSecure, getRequestDispatcher, getRealPath, getRemotePort, getLocalAddr, startAsync, startAsync, isAsyncStarted, isAsyncSupported, getAsyncContext, getDispatcherType, setRequest, wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

RESTART_TOKEN_SESSION_KEY

public static final String RESTART_TOKEN_SESSION_KEY


parameterMap

private final Map parameterMap


restartToken

private static String restartToken


 
Constructor Detail

RestartingApplicationHttpServletRequest

@SuppressWarnings({ "unchecked" })
public RestartingApplicationHttpServletRequest(HttpServletRequest request)


 
Method Detail

getParameter

@Override
public String getParameter(String name)


getParameterMap

@Override
public Map getParameterMap()


getParameterNames

@Override
public Enumeration getParameterNames()


getParameterValues

@Override
public String[] getParameterValues(String name)


getRestartToken

public static String getRestartToken()
Returns a token value used to determine if a request's associated Vaadin application needs to be reloaded. The token-based logic to support reloading functions as follows:
  1. If this method returns null, no source code has changed and the request should be processed as normal.
  2. If this method returns a non-null value, the Application source code has changed:
    1. If the request's session has this exact token value stored as a session attribute , then the Application has already been reloaded for that user session and nothing needs to be done.

    2. If the request does not yet have a session or the session does not reference this exact token value, the Vaadin application associated with the session needs to be reloaded.

      In this case, a ReloadingHttpServletRequest will be created to wrap the original request, but it will additionally impersonating a restartApplication request parameter as being set to true.

      When the Vaadin AbstractApplicationServlet AbstractApplicationServlet#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) the request, it will look at this request parameter and reload the application to reflect the changed Groovy Application class.
Returns:
a token value used to determine if a request's associated Vaadin application needs to be reloaded.


setRestartToken

public static void setRestartToken(String token)
Sets a unique token value used to trigger new Vaadin Application instances to be dynamically recreated after a Grails Vaadin component source-code change. Read the getRestartToken() getRestartToken() JavaDoc to understand how the token influences Application reload.
Parameters:
token - the unique token value used to trigger new Vaadin Application instances to be dynamically recreated after a Grails Vaadin component source-code change.


 

Groovy Documentation