com.google.gwt.rpc.server
Class RpcServlet

java.lang.Object
  extended by HttpServlet
      extended by com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
          extended by com.google.gwt.rpc.server.RpcServlet
Direct Known Subclasses:
HybridServiceServlet

public class RpcServlet
extends AbstractRemoteServiceServlet

EXPERIMENTAL and subject to change. Do not use this in production code.

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.


Constructor Summary
RpcServlet()
          The default constructor.
 
Method Summary
 ClientOracle getClientOracle()
          This method creates the ClientOracle that will provide data about the remote client.
 void processCall(ClientOracle clientOracle, java.lang.String payload, java.io.OutputStream stream)
          Process a call originating from the given request.
 void processPost(HttpServletRequest request, HttpServletResponse response)
          Standard HttpServlet method: handle the POST.
 
Methods inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
doPost
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RpcServlet

public RpcServlet()
The default constructor.

Method Detail

getClientOracle

public ClientOracle getClientOracle()
                             throws SerializationException
This method creates the ClientOracle that will provide data about the remote client. It delegates to findClientOracleData(String, String) to obtain access to ClientOracle data emitted by the GWT compiler.

Throws:
SerializationException

processCall

public void processCall(ClientOracle clientOracle,
                        java.lang.String payload,
                        java.io.OutputStream stream)
                 throws SerializationException
Process a call originating from the given request. Uses the 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.

This is public so that it can be unit tested easily without HTTP.

Parameters:
clientOracle - the ClientOracle that will be used to interpret the request
payload - the UTF-8 request payload
stream - the OutputStream that will receive the encoded response
Throws:
SerializationException - if we cannot serialize the response

processPost

public final void processPost(HttpServletRequest request,
                              HttpServletResponse response)
                       throws ServletException,
                              java.io.IOException,
                              SerializationException
Standard HttpServlet method: handle the POST. This doPost method swallows ALL exceptions, logs them in the ServletContext, and returns a GENERIC_FAILURE_MSG response with status code 500.

Throws:
java.io.IOException
ServletException
SerializationException