public class RpcServlet extends AbstractRemoteServiceServlet
The servlet base class for your RPC service implementations that automatically deserializes incoming requests from the client and serializes outgoing responses for client/server RPCs.
| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
CLIENT_ORACLE_EXTENSION |
perThreadRequest, perThreadResponse| Constructor and Description |
|---|
RpcServlet()
The default constructor used by service implementations that
extend this class.
|
RpcServlet(java.lang.Object delegate)
The wrapping constructor used by service implementations that are
separate from this class.
|
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
allowHostedModeConnections()
Indicates whether or not an RPC request from a Development Mode client
should be serviced.
|
protected java.io.InputStream |
findClientOracleData(java.lang.String requestModuleBasePath,
java.lang.String permutationStrongName)
Override this method to control access to permutation-specific data.
|
ClientOracle |
getClientOracle()
This method creates the ClientOracle that will provide data about the
remote client.
|
protected java.lang.String |
getRequestModuleBasePath()
Extract the module's base path from the current request.
|
void |
processCall(ClientOracle clientOracle,
java.lang.String payload,
java.io.OutputStream stream)
Process a call originating from the given request.
|
void |
processPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Standard HttpServlet method: handle the POST.
|
protected boolean |
shouldCompressResponse(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Determines whether the response to a given servlet request should or should
not be GZIP compressed.
|
doPost, doUnexpectedFailure, getPermutationStrongName, getThreadLocalRequest, getThreadLocalResponse, onAfterRequestDeserialized, readContentdoDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, serviceprotected static final java.lang.String CLIENT_ORACLE_EXTENSION
public RpcServlet()
public RpcServlet(java.lang.Object delegate)
public ClientOracle getClientOracle() throws SerializationException
findClientOracleData(String, String) to obtain access to
ClientOracle data emitted by the GWT compiler.SerializationExceptionpublic void processCall(ClientOracle clientOracle, java.lang.String payload, java.io.OutputStream stream) throws SerializationException
RPC.invokeAndStreamResponse(Object, java.lang.reflect.Method, Object[], ClientOracle, OutputStream)
method to do the actual work.
Subclasses may optionally override this method to handle the payload in any
way they desire (by routing the request to a framework component, for
instance). The HttpServletRequest and HttpServletResponse
can be accessed via the AbstractRemoteServiceServlet.getThreadLocalRequest() and
AbstractRemoteServiceServlet.getThreadLocalResponse() methods.
clientOracle - the ClientOracle that will be used to interpret the
requestpayload - the UTF-8 request payloadstream - the OutputStream that will receive the encoded responseSerializationException - if we cannot serialize the responsepublic final void processPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
java.io.IOException,
SerializationException
processPost in class AbstractRemoteServiceServletjava.io.IOExceptionjavax.servlet.ServletExceptionSerializationExceptionprotected boolean allowHostedModeConnections()
The default implementation allows hosted-mode connections from the local host, loopback addresses (127.*), site local (RFC 1918), link local (169.254/16) addresses, and their IPv6 equivalents.
true if a Development Mode connection should be
allowedAbstractRemoteServiceServlet.getThreadLocalRequest(),
InetAddressprotected java.io.InputStream findClientOracleData(java.lang.String requestModuleBasePath,
java.lang.String permutationStrongName)
throws SerializationException
The default implementation attempts to load the file from the
ServletContext as
requestModuleBasePath + permutationStrongName + CLIENT_ORACLE_EXTENSION
requestModuleBasePath - the module's base path, modulo protocol and
host, as reported by getRequestModuleBasePath()permutationStrongName - the module's strong name as reported by
AbstractRemoteServiceServlet.getPermutationStrongName()SerializationExceptionprotected final java.lang.String getRequestModuleBasePath()
GWT.getModuleBaseURL() or
null if the request did not contain the
"X-GWT-Module-Base" headerprotected boolean shouldCompressResponse(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
This implementation currently returns true if the request
originates from a non-local address. Subclasses can override this logic.
request - the request being servedresponse - the response that will be written intotrue if responsePayload should be GZIP compressed,
otherwise false.