Class RemoteServiceServlet
public
class
RemoteServiceServlet
extends
HttpServlet
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.
Constructors
Methods
Constructor Detail
RemoteServiceServlet
public RemoteServiceServlet()
The default constructor.
Method Detail
doPost
public final void doPost(HttpServletRequest request, HttpServletResponse response)
This is called internally.
Parameters
- request
-
- response
-
getThreadLocalRequest
protected final HttpServletRequest getThreadLocalRequest()
Gets the
HttpServletRequest
object for the current call. It
is stored thread-locally so that simultaneous invocations can have
different request objects.
getThreadLocalResponse
protected final HttpServletResponse getThreadLocalResponse()
Gets the
HttpServletResponse
object for the current call. It
is stored thread-locally so that simultaneous invocations can have
different response objects.
onAfterResponseSerialized
protected void
onAfterResponseSerialized(
String serializedResponse)
Override this method to examine the serialized response that will be
returned to the client. The default implementation does nothing and need
not be called by subclasses.
Parameters
- serializedResponse
-
onBeforeRequestDeserialized
protected void
onBeforeRequestDeserialized(
String serializedRequest)
Override this method to examine the serialized version of the request
payload before it is deserialized into objects. The default implementation
does nothing and need not be called by subclasses.
Parameters
- serializedRequest
-
processCall
This is public so that it can be unit tested easily without HTTP.
Parameters
- payload
-
shouldCompressResponse
protected boolean
shouldCompressResponse(
HttpServletRequest request, HttpServletResponse response, String responsePayload)
Determines whether the response to a given servlet request should or should
not be GZIP compressed. This method is only called in cases where the
requestor accepts GZIP encoding.
This implementation currently returns true
if the response
string's estimated byte length is longer than 256 bytes. Subclasses can
override this logic.
Parameters
- request
- the request being served
- response
- the response that will be written into
- responsePayload
- the payload that is about to be sent to the client
Return Value
true
if responsePayload should be GZIP compressed,
otherwise
false
.