Overview | Package | Class | Tree | Deprecated | Index | Help
| GWT 2.0.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.google.gwt.rpc.server
Class RpcServlet

    java.lang.Object
      javax.servlet.GenericServlet
          javax.servlet.http.HttpServlet
              com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
                  com.google.gwt.rpc.server.RpcServlet

All Implemented Interfaces:
  java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

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.

See Also:
  Serialized Form

Field Summary
`protected static java.lang.String` | `CLIENT_ORACLE_EXTENSION`

Fields inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
`perThreadRequest, perThreadResponse`

Constructor Summary
`RpcServlet()` The default constructor.

Method Summary
`protected boolean` | `allowHostedModeConnections()` Indicates whether or not an RPC request from a hosted 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.

Methods inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
`doPost, doUnexpectedFailure, 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, getServletContext, getServletInfo, getServletName, init, init, log, log`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### CLIENT_ORACLE_EXTENSION

    protected static final java.lang.String CLIENT_ORACLE_EXTENSION

See Also:
  Constant Field Values

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(javax.servlet.http.HttpServletRequest request,
                                  javax.servlet.http.HttpServletResponse response)
                           throws javax.servlet.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.

  Specified by:
    `processPost` in class `AbstractRemoteServiceServlet`
  Throws:
    `java.io.IOException`
    `javax.servlet.ServletException`
    `SerializationException`

### allowHostedModeConnections

    protected boolean allowHostedModeConnections()

  Indicates whether or not an RPC request from a hosted mode client should be serviced. Requests from hosted mode clients will expose unobfuscated identifiers in the payload. It is intended that developers override this method to restrict access based on installation-specific logic (such as a range of IP addresses, checking for certain cookies, etc.)

  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.

  Returns:
    `true` if a hosted mode connection should be allowed
  See Also:
    `AbstractRemoteServiceServlet.getThreadLocalRequest()`, `InetAddress`

### findClientOracleData

    protected java.io.InputStream findClientOracleData(java.lang.String requestModuleBasePath,
                                                       java.lang.String permutationStrongName)
                                                throws SerializationException

  Override this method to control access to permutation-specific data. For instance, the permutation-specific data may be stored in a database in order to support older clients.

  The default implementation attempts to load the file from the ServletContext as `requestModuleBasePath + permutationStrongName + CLIENT_ORACLE_EXTENSION`

  Parameters:
    `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()`
  Throws:
    `SerializationException`

### getRequestModuleBasePath

    protected final java.lang.String getRequestModuleBasePath()

  Extract the module's base path from the current request.

  Returns:
    the module's base path, modulo protocol and host, as reported by `GWT.getModuleBaseURL()` or `null` if the request did not contain the "X-GWT-Module-Base" header

### shouldCompressResponse

    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. This method is only called in cases where the requester accepts GZIP encoding.

  This implementation currently returns `true` if the request originates from a non-local address. Subclasses can override this logic.

  Parameters:
    `request` - the request being served
    `response` - the response that will be written into
  Returns:
    `true` if responsePayload should be GZIP compressed, otherwise `false`.

Overview | Package | Class | Tree | Deprecated | Index | Help
| GWT 2.0.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD