org.gwtwidgets.server.spring
Class GWTHandler

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.handler.AbstractHandlerMapping
              extended by org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
                  extended by org.gwtwidgets.server.spring.GWTHandler
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.core.Ordered, org.springframework.web.context.ServletConfigAware, org.springframework.web.context.ServletContextAware, org.springframework.web.servlet.HandlerMapping

public class GWTHandler
extends org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
implements org.springframework.web.servlet.HandlerMapping, org.springframework.beans.factory.InitializingBean, org.springframework.web.context.ServletContextAware, org.springframework.web.context.ServletConfigAware

The GWTHandler implements a Spring HandlerMapping which maps RPC from URLs to RemoteService implementations. It does so by wrapping service beans with a GWTRPCServiceExporter dynamically proxying all RemoteService interfaces implemented by the service and delegating RPC to these interfaces to the service. It is possible to use custom implementations of the GWTRPCServiceExporter, see setServiceExporterFactory(RPCServiceExporterFactory). Will also pick up any beans with an GWTRequestHandlerMapping annotation and publish it under the specified URL.

Author:
John Chilton, George Georgovassilis, g.georgovassilis[at]gmail.com

Field Summary
protected  boolean disableResponseCaching
           
protected  RPCServiceExporterFactory factory
           
protected  boolean responseCompressionEnabled
           
protected  boolean scanParentApplicationContext
           
protected  javax.servlet.ServletConfig servletConfig
           
protected  boolean shouldCheckPermutationStrongName
           
protected  boolean throwUndeclaredExceptionToServletContainer
           
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Fields inherited from interface org.springframework.web.servlet.HandlerMapping
BEST_MATCHING_PATTERN_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
GWTHandler()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked automatically by Spring after initialisation.
protected  java.util.Map<java.lang.String,java.lang.Object> getMappings()
           
 void setDisableResponseCaching(boolean disableResponseCaching)
          Can be used to explicitly disable caching of RPC responses in the client by modifying the HTTP headers of the response.
 void setMappings(java.util.Map<java.lang.String,java.lang.Object> mapping)
          Set a mapping between URLs and services
 void setResponseCompressionEnabled(boolean responseCompressionEnabled)
           
 void setScanParentApplicationContext(boolean scanParentApplicationContext)
          Recursively scan the parent application contexts for annotated beans to publish.
 void setServiceExporterFactory(RPCServiceExporterFactory factory)
          Optionally, a RPCServiceExporterFactory can be injected if a different implementation or setup is required.
 void setServletConfig(javax.servlet.ServletConfig servletConfig)
          Setter for servlet configuration
 void setShouldCheckPermutationStrongName(boolean shouldCheckPermutationStrongName)
          Should RPC check the permutation strong name? Disabled by default.
 void setThrowUndeclaredExceptionToServletContainer(boolean throwUndeclaredExceptionToServletContainer)
           
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
buildPathExposingHandler, exposePathWithinMapping, exposeUriTemplateVariables, getHandlerInternal, getHandlerMap, getPathMatcher, getRootHandler, initInterceptors, lookupHandler, registerHandler, registerHandler, setAlwaysUseFullPath, setLazyInitHandlers, setMappedInterceptors, setPathMatcher, setRootHandler, setUrlDecode, setUrlPathHelper, validateHandler
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getOrder, initApplicationContext, setDefaultHandler, setInterceptors, setOrder
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.web.servlet.HandlerMapping
getHandler
 
Methods inherited from interface org.springframework.web.context.ServletContextAware
setServletContext
 

Field Detail

factory

protected RPCServiceExporterFactory factory

disableResponseCaching

protected boolean disableResponseCaching

throwUndeclaredExceptionToServletContainer

protected boolean throwUndeclaredExceptionToServletContainer

scanParentApplicationContext

protected boolean scanParentApplicationContext

servletConfig

protected javax.servlet.ServletConfig servletConfig

responseCompressionEnabled

protected boolean responseCompressionEnabled

shouldCheckPermutationStrongName

protected boolean shouldCheckPermutationStrongName
Constructor Detail

GWTHandler

public GWTHandler()
Method Detail

setShouldCheckPermutationStrongName

public void setShouldCheckPermutationStrongName(boolean shouldCheckPermutationStrongName)
Should RPC check the permutation strong name? Disabled by default. If either the specified RPCServiceExporterFactory or this flag is set, then checks will be enforced.

Parameters:
shouldCheckPermutationStrongName -

setResponseCompressionEnabled

public void setResponseCompressionEnabled(boolean responseCompressionEnabled)

setScanParentApplicationContext

public void setScanParentApplicationContext(boolean scanParentApplicationContext)
Recursively scan the parent application contexts for annotated beans to publish. Beans from applications contexts that are lower in the hierarchy overwrite beans found in parent application contexts.

Parameters:
scanParentApplicationContext - Defaults to false

getMappings

protected java.util.Map<java.lang.String,java.lang.Object> getMappings()

setMappings

public void setMappings(java.util.Map<java.lang.String,java.lang.Object> mapping)
Set a mapping between URLs and services

Parameters:
mapping -

afterPropertiesSet

public void afterPropertiesSet()
                        throws java.lang.Exception
Invoked automatically by Spring after initialisation.

Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
Throws:
java.lang.Exception

setServiceExporterFactory

public void setServiceExporterFactory(RPCServiceExporterFactory factory)
Optionally, a RPCServiceExporterFactory can be injected if a different implementation or setup is required. Note that after initialization, the following sequence of invocations will be performed on the serviceExporter :

exporter.setServletContext();
exporter.setService();
exporter.setServiceInterfaces();
exporter.afterPropertiesSet();

Parameters:
factory -

setDisableResponseCaching

public void setDisableResponseCaching(boolean disableResponseCaching)
Can be used to explicitly disable caching of RPC responses in the client by modifying the HTTP headers of the response.

Parameters:
disableResponseCaching -

setThrowUndeclaredExceptionToServletContainer

public void setThrowUndeclaredExceptionToServletContainer(boolean throwUndeclaredExceptionToServletContainer)
Parameters:
throwUndeclaredExceptionToServletContainer -
See Also:
RPCServiceExporter#setThrowUndeclaredExceptionToServletContainer(boolean)}

setServletConfig

public void setServletConfig(javax.servlet.ServletConfig servletConfig)
Setter for servlet configuration

Specified by:
setServletConfig in interface org.springframework.web.context.ServletConfigAware


Copyright © 2011. All Rights Reserved.