com.isomorphic.servlet
Class IDACall

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.isomorphic.servlet.BaseServlet
                    |
                    +--com.isomorphic.servlet.IDACall
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class IDACall
extends com.isomorphic.servlet.BaseServlet

This servlet handles built-in SmartClient datasource operations by default. It is configured as the default actionURL for the RPCManager on the client-side. You can extend this class and use the API hooks provided here to do something custom, like Authentication/Authorization checks.

See Also:
Serialized Form

Method Summary
 DSResponse handleDSRequest(DSRequest dsRequest, RPCManager rpc, RequestContext context)
          This method is called by processRequest() to handle a DSRequest sent from the client.
 RPCResponse handleRPCRequest(RPCRequest rpcRequest, RPCManager rpc, RequestContext context)
          This method is called by processRequest() to handle a RPCRequest sent from the client.
 void processRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Servlet entry point to process the request.
 

Method Detail

processRequest

public void processRequest(javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response)
                    throws javax.servlet.ServletException,
                           java.io.IOException
Servlet entry point to process the request. Default implementation instantiates an RPCManager, and invokes handleRPCRequest() or handleDSRequest() for each RPC encoded in this HTTP request.
Parameters:
request - The HttpServletRequest
response - The HttpServletResponse
Throws:
javax.servlet.ServletException - As per HttpServlet.service()
java.io.IOException - As per HttpServlet.service()

handleDSRequest

public DSResponse handleDSRequest(DSRequest dsRequest,
                                  RPCManager rpc,
                                  RequestContext context)
                           throws java.lang.Exception
This method is called by processRequest() to handle a DSRequest sent from the client. This method may be called multiple times while processing a single HTTP request (if the client sent multiple requests in a batch via RPCManager.startQueue()).

The default implementation of this method simply does this:

   try {
       return dsRequest.execute();
   } catch (Exception e) {
       DSResponse dsResponse = new DSResponse();
       context.staticLog.warn("dsRequest.execute() failed: ", e);
       dsResponse.setStatus(DSResponse.STATUS_FAILURE);
       dsResponse.setData(e.getMessage());
       return dsResponse;
   }
 
Parameters:
dsRequest - The DSRequest to process
RPCmanager - The RPCManager that was used to demultiplex the DSRequest
RequestContext - RequestContext class provides accessors to Servlet basics like HttpServletRequest, HttpServletResponse
Throws:
java.lang.Exception - If an error occurs. If possible, you should wrap any error in a DSResponse with an error status code and handle it on the client.

handleRPCRequest

public RPCResponse handleRPCRequest(RPCRequest rpcRequest,
                                    RPCManager rpc,
                                    RequestContext context)
                             throws java.lang.Exception
This method is called by processRequest() to handle a RPCRequest sent from the client. This method may be called multiple times while processing a single HTTP request (if the client sent multiple requests in a batch via RPCManager.startQueue()).

The default implementation of this method simply does this:

   try {
       return rpcRequest.execute();
   } catch (Exception e) {
       context.staticLog.warn("rpcRequest.execute() failed: ", e);
       RPCResponse rpcResponse = new RPCResponse();
       rpcResponse.setStatus(RPCResponse.STATUS_FAILURE);
       rpcResponse.setData(e.getMessage());
       return rpcResponse;
   }
 
Parameters:
dsRequest - The DSRequest to process
RPCmanager - The RPCManager that was used to demultiplex the DSRequest
RequestContext - RequestContext class provides accessors to Servlet basics like HttpServletRequest, HttpServletResponse
Throws:
java.lang.Exception - If an error occurs. If possible, you should wrap any error in a RPCResponse with an error status code and handle it on the client.