public class IDACall extends BaseServlet
NOTE: This servlet is configured to automatically set character encoding on requests and responses to UTF-8. If you wish to force a different encoding, you can do so by specifying an init-param
in your web.xml file, like so:
<servlet> <servlet-name>IDACall</servlet-name> <servlet-class>com.isomorphic.servlet.IDACall</servlet-class> <init-param> <param-name>encoding</param-name> <param-value>some-other-encoding</param-value> </init-param> </servlet>If you wish to switch off explicit encoding altogether, use the
init-param
to set a value of "none". Please see the client-side documentation on Internationalization for a discussion of why this procedure is necessary.
Modifier and Type | Method and Description |
---|---|
DSResponse | handleDSRequest(DSRequest dsRequest, RPCManager rpc, RequestContext context) This method is called by processRPCTransaction() to handle a DSRequest sent from the client. |
DSResponse | handleDSRequestError(DSRequest dsRequest, RPCManager rpc, RequestContext context, java.lang.Throwable t) This method is called by handleDSRequest() to handle an Exception thrown by execution. |
RPCResponse | handleRPCRequest(RPCRequest rpcRequest, RPCManager rpc, RequestContext context) This method is called by processRPCTransaction() to handle a RPCRequest sent from the client. |
RPCResponse | handleRPCRequestError(RPCRequest rpcRequest, RPCManager rpc, RequestContext context, java.lang.Throwable t) This method is called by handleRPCRequest() to handle an Exception thrown by execution. |
void | processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) Servlet entry point to process the request. |
void | processRPCTransaction(RPCManager rpc, RequestContext context) Process an RPC transaction. |
handleError, handleError
public void processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
IDACall.processRPCTransaction(RPCManager, RequestContext)
to handle each RPC encoded in this HTTP request.request
- The HttpServletRequestresponse
- The HttpServletResponsejavax.servlet.ServletException
- As per HttpServlet.service()java.io.IOException
- As per HttpServlet.service()public void processRPCTransaction(RPCManager rpc, RequestContext context) throws java.lang.Exception
IDACall.handleRPCRequest(RPCRequest, RPCManager, RequestContext)
or IDACall.handleDSRequest(DSRequest, RPCManager, RequestContext)
depending on the request type.rpc
- The RPCManager for this HTTP requestcontext
- RequestContext class provides accessors to Servlet basics like HttpServletRequest, HttpServletResponsejava.lang.Exception
- For backwards compatibility this method is still declared as throwing an exception, but the default implementation logic traps and handles all Exceptions.public DSResponse handleDSRequest(DSRequest dsRequest, RPCManager rpc, RequestContext context) throws java.lang.Exception
The default implementation of this method simply does this:
try { return dsRequest.execute(); } catch (Throwable t1) { return handleDSRequestError(dsRequest, rpc, context, t); }
dsRequest
- The DSRequest to processrpc
- The RPCManager that was used to demultiplex the DSRequestcontext
- RequestContext class provides accessors to Servlet basics like HttpServletRequest, HttpServletResponsejava.lang.Exception
- For backwards compatibility this method is still declared as throwing an exception, but the default implementation logic (as shown above) traps and handles all Exceptions. DSResponse with an error status code and handle it on the client.public DSResponse handleDSRequestError(DSRequest dsRequest, RPCManager rpc, RequestContext context, java.lang.Throwable t)
Note that if you want to provide your own custom handling, the recommended way to do this is to override this method to handle your specific cases and to then fall through to a call to super.handleDSRequestError()
to allow the default error handling logic to handle various builtin features of the server.
dsRequest
- The DSRequest that resulted in an Exception being thrownrpc
- The RPCManager that was used to demultiplex the DSRequestcontext
- RequestContext class provides accessors to Servlet basics like HttpServletRequest, HttpServletResponset
- The Throwable that was thrown. Declared as a Throwable to trap both Exceptions and Errors. DSResponse with an error status code and handle it on the client.public RPCResponse handleRPCRequest(RPCRequest rpcRequest, RPCManager rpc, RequestContext context) throws java.lang.Exception
The default implementation of this method simply does this:
try { return rpcRequest.execute(); } catch (Throwable t) { return handleRPCRequestError(rpcRequest, rpc, context, t) }
rpcRequest
- The RPCRequest to processrpc
- The RPCManager that was used to demultiplex the DSRequestcontext
- RequestContext class provides access to Servlet basics like HttpServletRequest, HttpServletResponseFor
- backwards compatibility this method is still declared as throwing an exception, but the default implementation logic (as shown above) traps and handles all Exceptions.java.lang.Exception
public RPCResponse handleRPCRequestError(RPCRequest rpcRequest, RPCManager rpc, RequestContext context, java.lang.Throwable t)
Note that if you want to provide your own custom handling, the recommended way to do this is to override this method to handle your specific cases and to then fall through to a call to super.handleRPCRequestError()
to allow the default error handling logic to handle various builtin features of the server.
rpcRequest
- The RPCRequest that resulted in an Exception being thrownrpc
- The RPCManager that was used to demultiplex the RPCRequestcontext
- RequestContext class provides accessors to Servlet basics like HttpServletRequest, HttpServletResponset
- The Throwable that was thrown. Declared as a Throwable to trap both Exceptions and Errors.