|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
com.google.gwt.user.server.rpc.RemoteServiceServlet
org.gwtwidgets.server.spring.GWTRPCServiceExporter
public class GWTRPCServiceExporter
This component publishes an object (see setService(Object)) as a
service to the GWT RPC protocol. Service targets can be:
setServiceInterfaces(Class[]))RemoteServicehandle*
methods which are invoked by the GWTRPCServiceExporter.
| Field Summary | |
|---|---|
protected java.lang.String |
beanName
|
static int |
COMPRESSION_AUTO
Leave default RPC response compression behavior. |
static int |
COMPRESSION_DISABLED
Disable RPC response compression. |
static int |
COMPRESSION_ENABLED
Force compression of all RPC responses. |
protected int |
compressResponse
|
protected boolean |
disableResponseCaching
|
protected org.apache.commons.logging.Log |
logger
|
protected java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> |
methodCache
|
protected ModulePathTranslation |
modulePathTranslation
|
protected int |
serializationFlags
|
protected SerializationPolicyProvider |
serializationPolicyProvider
|
protected java.lang.Object |
service
|
protected java.lang.Class<?>[] |
serviceInterfaces
|
protected javax.servlet.ServletContext |
servletContext
|
protected boolean |
shouldCheckPermutationStrongName
|
protected boolean |
throwUndeclaredExceptionToServletContainer
|
| Fields inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet |
|---|
perThreadRequest, perThreadResponse |
| Constructor Summary | |
|---|---|
GWTRPCServiceExporter()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
Should be invoked after all properties have been set. |
protected void |
checkPermutationStrongName()
|
protected com.google.gwt.user.server.rpc.SerializationPolicy |
doGetSerializationPolicy(javax.servlet.http.HttpServletRequest request,
java.lang.String moduleBaseURL,
java.lang.String strongName)
|
protected void |
doUnexpectedFailure(java.lang.Throwable e)
|
protected java.lang.String |
encodeResponseForFailure(com.google.gwt.user.server.rpc.RPCRequest rpcRequest,
java.lang.Throwable cause,
java.lang.reflect.Method targetMethod,
java.lang.Object[] targetParameters)
Wrapper around RPC utility invocation |
protected java.lang.reflect.Method |
getMethodToInvoke(java.lang.reflect.Method decodedMethod)
Returns method to invoke on service. |
int |
getSerializationFlags()
Return the set serialization flags (see AbstractSerializationStream.getFlags() |
SerializationPolicyProvider |
getSerializationPolicyProvider()
Returns the installed serialization policy provider. |
java.lang.Object |
getService()
Return target service. |
javax.servlet.ServletContext |
getServletContext()
Returns the servlet context |
protected java.lang.String |
handleExporterProcessingException(java.lang.Exception e)
Invoked by processCall(String) for an exception if no suitable
exception handler was found. |
protected java.lang.String |
handleIllegalAccessException(java.lang.IllegalAccessException e,
java.lang.Object service,
java.lang.reflect.Method targetMethod,
com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
Handles an exception which is raised when a method access is attempted to a method which is not part of the RPC interface. |
protected java.lang.String |
handleIllegalArgumentException(java.lang.IllegalArgumentException e,
java.lang.Object service,
java.lang.reflect.Method targetMethod,
com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
Handles an exception which is raised when a method invocation with bad arguments is attempted. |
protected java.lang.String |
handleIncompatibleRemoteServiceException(com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException cause)
Invoked by processCall(String) when RPC throws an
IncompatibleRemoteServiceException. |
protected java.lang.String |
handleInvocationTargetException(java.lang.reflect.InvocationTargetException e,
java.lang.Object service,
java.lang.reflect.Method targetMethod,
java.lang.Object[] parameters,
com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
Handles exceptions thrown by the target service, which are wrapped in InvocationTargetExceptions due to invocation by reflection. |
org.springframework.web.servlet.ModelAndView |
handleRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Implementation of inherited interface |
protected java.lang.String |
handleServiceException(java.lang.Exception e,
java.lang.Object service,
java.lang.reflect.Method targetMethod,
com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
Handles exceptions thrown during a service invocation that are not handled by other exception handlers. |
protected java.lang.String |
handleUndeclaredThrowableException(java.lang.Exception e,
java.lang.Object service,
java.lang.reflect.Method targetMethod,
com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
Handles UndeclaredThrowableExceptions which are thrown by the
target service. |
protected java.lang.String |
invokeMethodOnService(java.lang.Object service,
java.lang.reflect.Method targetMethod,
java.lang.Object[] targetParameters,
com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
Handles method invocation on a service and is invoked by processCall(String). |
protected void |
onAfterResponseSerialized(java.lang.String serializedResponse)
|
protected void |
onBeforeRequestDeserialized(java.lang.String serializedRequest)
|
protected void |
preprocessHTTP(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Disables HTTP response caching by modifying response headers for browsers. |
java.lang.String |
processCall(java.lang.String payload)
Overridden from RemoteServiceServlet and invoked by the servlet
code. |
protected java.lang.String |
processResponse(java.lang.String response)
Post-processes an RPC response. |
void |
setBeanName(java.lang.String beanName)
|
protected void |
setCompressResponse(int compressResponse)
Enables or disables compression of RPC output. |
void |
setModulePathTranslation(ModulePathTranslation modulePathTranslation)
|
void |
setResponseCachingDisabled(boolean disableResponseCaching)
Can be used to set HTTP response headers that explicitly disable caching on the browser side. |
void |
setSerializationFlags(int serializationFlags)
Set serialization flags (see AbstractSerializationStream.getFlags(). |
void |
setSerializationPolicyProvider(SerializationPolicyProvider serializationPolicyProvider)
Assign a new serialization policy provider. |
void |
setService(java.lang.Object service)
Set the wrapped service bean. |
void |
setServiceInterfaces(java.lang.Class<com.google.gwt.user.client.rpc.RemoteService>[] serviceInterfaces)
Specifies the interfaces which must be implemented by the service bean. |
void |
setServletConfig(javax.servlet.ServletConfig servletConfig)
Setter for servlet configuration |
void |
setServletContext(javax.servlet.ServletContext servletContext)
Implementation of ServletContextAware, is invoked by the Spring
application context. |
void |
setShouldCheckPermutationStrongName(boolean shouldCheckPermutationStrongName)
Specify whether RemoteServiceServlet.checkPermutationStrongName() should be invoked
for the current request. |
void |
setThrowUndeclaredExceptionToServletContainer(boolean throwUndeclaredExceptionToServletContainer)
When enabled will throw exceptions which originate from the service and have not been declared in the RPC interface back to the servlet container. |
protected boolean |
shouldCompressResponse(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String responsePayload)
|
java.lang.String |
toString()
|
| Methods inherited from class com.google.gwt.user.server.rpc.RemoteServiceServlet |
|---|
getSerializationPolicy, processPost |
| Methods inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet |
|---|
doPost, getPermutationStrongName, getThreadLocalRequest, getThreadLocalResponse, onAfterRequestDeserialized, readContent |
| Methods inherited from class javax.servlet.http.HttpServlet |
|---|
doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
| Methods inherited from class javax.servlet.GenericServlet |
|---|
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletInfo, getServletName, init, init, log, log |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int COMPRESSION_DISABLED
public static final int COMPRESSION_AUTO
public static final int COMPRESSION_ENABLED
protected org.apache.commons.logging.Log logger
protected java.lang.Class<?>[] serviceInterfaces
protected java.lang.Object service
protected javax.servlet.ServletContext servletContext
protected int compressResponse
protected boolean disableResponseCaching
protected boolean throwUndeclaredExceptionToServletContainer
protected java.lang.String beanName
protected SerializationPolicyProvider serializationPolicyProvider
protected int serializationFlags
protected boolean shouldCheckPermutationStrongName
protected ModulePathTranslation modulePathTranslation
protected java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> methodCache
| Constructor Detail |
|---|
public GWTRPCServiceExporter()
| Method Detail |
|---|
public void setModulePathTranslation(ModulePathTranslation modulePathTranslation)
protected void checkPermutationStrongName()
checkPermutationStrongName in class com.google.gwt.user.server.rpc.RemoteServiceServletpublic void setShouldCheckPermutationStrongName(boolean shouldCheckPermutationStrongName)
RPCServiceExporterRemoteServiceServlet.checkPermutationStrongName() should be invoked
for the current request. Disabled by default for backwards compatibility with older SL versions.
setShouldCheckPermutationStrongName in interface RPCServiceExporterpublic int getSerializationFlags()
AbstractSerializationStream.getFlags()
public void setSerializationFlags(int serializationFlags)
AbstractSerializationStream.getFlags(). Default value is
AbstractSerializationStream.DEFAULT_FLAGS
serializationFlags - protected java.lang.String processResponse(java.lang.String response)
response - Response
protected void doUnexpectedFailure(java.lang.Throwable e)
doUnexpectedFailure in class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
protected void preprocessHTTP(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
request - response - public SerializationPolicyProvider getSerializationPolicyProvider()
DefaultSerializationPolicyProvider is used
public void setSerializationPolicyProvider(SerializationPolicyProvider serializationPolicyProvider)
serializationPolicyProvider - public void setServletContext(javax.servlet.ServletContext servletContext)
ServletContextAware, is invoked by the Spring
application context.
setServletContext in interface org.springframework.web.context.ServletContextAwareservletContext - public javax.servlet.ServletContext getServletContext()
getServletContext in interface javax.servlet.ServletConfiggetServletContext in class javax.servlet.GenericServletServletContextprotected void onAfterResponseSerialized(java.lang.String serializedResponse)
onAfterResponseSerialized in class com.google.gwt.user.server.rpc.RemoteServiceServletprotected void onBeforeRequestDeserialized(java.lang.String serializedRequest)
onBeforeRequestDeserialized in class com.google.gwt.user.server.rpc.RemoteServiceServlet
protected java.lang.String invokeMethodOnService(java.lang.Object service,
java.lang.reflect.Method targetMethod,
java.lang.Object[] targetParameters,
com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
throws java.lang.Exception
processCall(String).
service - Service to invoke method ontargetMethod - Method to invoke.targetParameters - Parameters to pass to method. Can be null for no arguments.rpcRequest - RPCRequest instance for this request
java.lang.Exception
protected java.lang.String handleIllegalArgumentException(java.lang.IllegalArgumentException e,
java.lang.Object service,
java.lang.reflect.Method targetMethod,
com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
SecurityException. For details on arguments please consult
invokeMethodOnService(Object, Method, Object[], RPCRequest).
e - Exception thrownservice - targetMethod -
protected java.lang.String handleIllegalAccessException(java.lang.IllegalAccessException e,
java.lang.Object service,
java.lang.reflect.Method targetMethod,
com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
processCall(String). This implementation throws a
SecurityException. For details on arguments please consult
invokeMethodOnService(Object, Method, Object[], RPCRequest).
e - Exception thrownservice - targetMethod -
protected java.lang.String encodeResponseForFailure(com.google.gwt.user.server.rpc.RPCRequest rpcRequest,
java.lang.Throwable cause,
java.lang.reflect.Method targetMethod,
java.lang.Object[] targetParameters)
throws com.google.gwt.user.client.rpc.SerializationException
rpcRequest - RPCRequestcause - Exception to handletargetMethod - Method which threw the exceptiontargetParameters - Method arguments
java.lang.Exception
com.google.gwt.user.client.rpc.SerializationException
protected java.lang.String handleInvocationTargetException(java.lang.reflect.InvocationTargetException e,
java.lang.Object service,
java.lang.reflect.Method targetMethod,
java.lang.Object[] parameters,
com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
throws java.lang.Exception
InvocationTargetExceptions due to invocation by reflection. This
method is invoked by processCall(String). This implementation
encodes exceptions as RPC errors and returns them. For details on
arguments please consult
invokeMethodOnService(Object, Method, Object[], RPCRequest).
e - Exception thrownservice - targetMethod - parameters - rpcRequest -
java.lang.Exception
protected java.lang.String handleServiceException(java.lang.Exception e,
java.lang.Object service,
java.lang.reflect.Method targetMethod,
com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
throws java.lang.Exception
processCall(String) on
exceptions which have escaped the other exception handlers such as
handleIllegalAccessException(IllegalAccessException, Object, Method, RPCRequest)
etc. This implementation re-casts 'e'. For details on arguments please
consult
invokeMethodOnService(Object, Method, Object[], RPCRequest).
e - Exception thrownservice - targetMethod - rpcRequest -
java.lang.Exception
protected java.lang.String handleUndeclaredThrowableException(java.lang.Exception e,
java.lang.Object service,
java.lang.reflect.Method targetMethod,
com.google.gwt.user.server.rpc.RPCRequest rpcRequest)
throws java.lang.Exception
UndeclaredThrowableExceptions which are thrown by the
target service. This method is invoked by
processCall(String). This implementation re-casts 'e'. For
details on arguments please consult
invokeMethodOnService(Object, Method, Object[], RPCRequest).
e - Exception thrownservice - targetMethod - rpcRequest -
java.lang.Exception
protected java.lang.reflect.Method getMethodToInvoke(java.lang.reflect.Method decodedMethod)
throws java.lang.NoSuchMethodException
ReflectionUtils.getRPCMethod(Object, Class[], Method)
decodedMethod - Method as determined by RPC
java.lang.NoSuchMethodException
public java.lang.String processCall(java.lang.String payload)
throws com.google.gwt.user.client.rpc.SerializationException
RemoteServiceServlet and invoked by the servlet
code.
processCall in class com.google.gwt.user.server.rpc.RemoteServiceServletcom.google.gwt.user.client.rpc.SerializationException
protected java.lang.String handleIncompatibleRemoteServiceException(com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException cause)
throws com.google.gwt.user.client.rpc.SerializationException
processCall(String) when RPC throws an
IncompatibleRemoteServiceException. This implementation
propagates the exception back to the client via RPC.
e - Exception thrown
com.google.gwt.user.client.rpc.SerializationExceptionprotected java.lang.String handleExporterProcessingException(java.lang.Exception e)
processCall(String) for an exception if no suitable
exception handler was found. This is the outermost exception handler,
catching any exceptions not caught by other exception handlers or even
thrown by those handlers. This implementation wraps 'e' in a
RuntimeException which is then thrown.
e -
public void setService(java.lang.Object service)
setService in interface RPCServiceExporterservice - Service to which the decoded requests are forwarded
public org.springframework.web.servlet.ModelAndView handleRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException
handleRequest in interface org.springframework.web.servlet.mvc.Controllerjavax.servlet.ServletException
java.io.IOExceptionHttpRequestHandler#handleRequest(HttpServletRequest, HttpServletResponse)}public void setServiceInterfaces(java.lang.Class<com.google.gwt.user.client.rpc.RemoteService>[] serviceInterfaces)
RemoteService which
is implemented by the service bean is assumed. Implementation note:
as methods are only lazily bound to the service implementation you may get
away with mismatches between the specified interfaces and the actual implementation
as long as no method is invoked which has a different/missing signature in the interface
and the service implementation.
setServiceInterfaces in interface RPCServiceExporterserviceInterfaces -
public void afterPropertiesSet()
throws java.lang.Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanjava.lang.ExceptionInitializingBean.afterPropertiesSet()public java.lang.Object getService()
GWTRPCServiceExporter has a single
target service which it redirects RPC to.
protected boolean shouldCompressResponse(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
java.lang.String responsePayload)
shouldCompressResponse in class com.google.gwt.user.server.rpc.RemoteServiceServletprotected void setCompressResponse(int compressResponse)
COMPRESSION_AUTO. Allowed values are
COMPRESSION_ENABLED, COMPRESSION_DISABLED and
COMPRESSION_AUTO.
compressResponse - public void setResponseCachingDisabled(boolean disableResponseCaching)
setResponseCachingDisabled in interface RPCServiceExporterresponseCaching - public void setThrowUndeclaredExceptionToServletContainer(boolean throwUndeclaredExceptionToServletContainer)
setThrowUndeclaredExceptionToServletContainer in interface RPCServiceExporterthrowUndeclaredExceptionToServletContainer - Defaults to falsepublic void setServletConfig(javax.servlet.ServletConfig servletConfig)
setServletConfig in interface org.springframework.web.context.ServletConfigAwarepublic void setBeanName(java.lang.String beanName)
setBeanName in interface org.springframework.beans.factory.BeanNameAware
protected com.google.gwt.user.server.rpc.SerializationPolicy doGetSerializationPolicy(javax.servlet.http.HttpServletRequest request,
java.lang.String moduleBaseURL,
java.lang.String strongName)
doGetSerializationPolicy in class com.google.gwt.user.server.rpc.RemoteServiceServletpublic java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||