com.isomorphic.rpc

## Class BaseRequest

- java.lang.Object
- - com.isomorphic.base.Base
  - - com.isomorphic.rpc.BaseRequest

- Direct Known Subclasses:
    DSRequest, RPCRequest

      public abstract class BaseRequest
      extends Base

  This is the base for all requests going through the rpc and DataSource layer in Smartclient Server. Both `DSRequest` and `RPCRequest` extend this class in order to function as expected in DataSources as well as other request processing.

  This class was introduced together with `DSTransaction` in order to ease the relationships between the request/response classes and the transaction layer.

  See Also:
    `BaseResponse`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract BaseResponse` | `execute()` Executes this request and returns a response.
    `BaseRequest` | `freeAllResources()` Frees all shared resources (for example, DataSource instances and database connections) used by this request.
    `RequestContext` | `getContext()` Returns the `RequestContext` associated with this request.
    `DSTransaction` | `getDsTransaction()` Returns the DSTransaction associated with this request.
    `DSTransaction` | `getDSTransaction()` This is an alias method for `BaseRequest.getDSTransaction()`.
    `RPCManager` | `getRPCManager()` Returns the RPCManager associated with this DSRequest, if there is one.
    `boolean` | `isClientRequest()` Returns true if this is a request that originated from a client such as via an HTTP request.
    `BaseRequest` | `setClientRequest(java.lang.Boolean clientRequest)` Used to mark this request as coming from a client.
    `BaseRequest` | `setContext(RequestContext context)` Applies a `RequestContext` to this request.
    `void` | `setDsTransaction(DSTransaction dsTransaction)` Sets a DSTransaction to be associated with this request.
    `void` | `setDSTransaction(DSTransaction dsTransaction)` This is an alias method for `BaseRequest.setDsTransaction(DSTransaction)`.
    `void` | `setRPCManager(RPCManager rpcManager)` Associates this request with the specified RPCManager.

- - ### Method Detail

    - #### execute

          public abstract BaseResponse execute()
                                        throws java.lang.Exception

      Executes this request and returns a response. If an application is defined for this request, the execution is dispatched through that application. Otherwise, the execution is dispatched through the DataSource layer.
      Returns:
        a response that extends `BaseResponse`
      Throws:
        `java.lang.Exception`

    - #### freeAllResources

          public BaseRequest freeAllResources()

      Frees all shared resources (for example, DataSource instances and database connections) used by this request.

    - #### getRPCManager

          public RPCManager getRPCManager()

      Returns the RPCManager associated with this DSRequest, if there is one. Note that a DSRequest does not need to operate in the context of an RPCManager, and this method will return null unless you are running in the context of a web application. It is not recommended that you use this value for systems where there is any chance of having to operate outside of a web app, or be usable with automated test software.
      Returns:
        The RPCManager to use for this request, or null if this request is not running in the context of a web application

    - #### setRPCManager

          public void setRPCManager(RPCManager rpcManager)

      Associates this request with the specified RPCManager. For hand-created requests (ie, created in your Java code with "new DSRequest()"), you need to call this method to enable Spring-based DMI and other logic that depends on the current servlet environment, and to have the request participate the current automatic transaction (if any).

      If you want a request to become liable to security checks you will also have to call `BaseRequest.setClientRequest(java.lang.Boolean)` with a parameter of true.

      Note that there is also a convenience constructor that allows you to pass an RPCManager in during construction.

      Parameters:
        `rpcManager` - The RPCManager to use for this request

    - #### getDSTransaction

          public DSTransaction getDSTransaction()

      This is an alias method for `BaseRequest.getDSTransaction()`.
      Returns:
        the DSTransaction
      See Also:
        `BaseRequest.getDsTransaction()`

    - #### getDsTransaction

          public DSTransaction getDsTransaction()

      Returns the DSTransaction associated with this request.
      Returns:
        the DSTransaction

    - #### setDSTransaction

          public void setDSTransaction(DSTransaction dsTransaction)

      This is an alias method for `BaseRequest.setDsTransaction(DSTransaction)`.
      Parameters:
        `dsTransaction` - the DSTransaction to associate.
      See Also:
        `BaseRequest.setDsTransaction(DSTransaction)`

    - #### setDsTransaction

          public void setDsTransaction(DSTransaction dsTransaction)

      Sets a DSTransaction to be associated with this request. The request will be added to the transaction and processed as a part of the transaction.

      This will also call `DSTransaction.registerRequest(BaseRequest)` in order to register this request on the transaction.

      Parameters:
        `dsTransaction` - the DSTransaction to associate.

    - #### getContext

          public RequestContext getContext()

      Returns the `RequestContext` associated with this request.
      Returns:
        the RequestContext

    - #### setContext

          public BaseRequest setContext(RequestContext context)

      Applies a `RequestContext` to this request.

      Normally this is taken care of for you. For examples on when you would explicitly set this please see `RequestContext` documentation.

      Parameters:
        `context` - the RequestContext to set on this request.
      See Also:
        `RequestContext.instance(Servlet, HttpServletRequest, HttpServletResponse)`

    - #### isClientRequest

          public boolean isClientRequest()

      Returns true if this is a request that originated from a client such as via an HTTP request. This method is called to determine if Declarative Security checks should be made on this request.
      Returns:
        true if this request originated from a client.

    - #### setClientRequest

          public BaseRequest setClientRequest(java.lang.Boolean clientRequest)

      Used to mark this request as coming from a client. If this is set to true the request will also be checked against Declarative Security.

      If this request is apart of a DSTransaction this value always take priority over any value specified using `DSTransaction.setClientRequest(Boolean)`. If you want the DSTransaction to take priority you simply leave this unset or set it to null.

      Parameters:
        `clientRequest` - pass in true if this request originated from a client.
      Returns:
        this request for method chaining.