public abstract class BaseRequest extends Base
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.
BaseResponse
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. |
void | 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. |
public abstract BaseResponse execute() throws java.lang.Exception
BaseResponse
java.lang.Exception
public BaseRequest freeAllResources()
public RPCManager getRPCManager()
public void setRPCManager(RPCManager rpcManager)
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.
rpcManager
- The RPCManager to use for this requestpublic DSTransaction getDSTransaction()
BaseRequest.getDSTransaction()
.BaseRequest.getDsTransaction()
public DSTransaction getDsTransaction()
public void setDSTransaction(DSTransaction dsTransaction)
BaseRequest.setDsTransaction(DSTransaction)
.dsTransaction
- the DSTransaction to associate.BaseRequest.setDsTransaction(DSTransaction)
public void setDsTransaction(DSTransaction dsTransaction)
This will also call DSTransaction.registerRequest(BaseRequest)
in order to register this request on the transaction.
dsTransaction
- the DSTransaction to associate.public RequestContext getContext()
RequestContext
associated with this request.public void setContext(RequestContext context)
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.
context
- the RequestContext to set on this request.RequestContext.instance(Servlet, HttpServletRequest, HttpServletResponse)
public boolean isClientRequest()
public BaseRequest setClientRequest(java.lang.Boolean clientRequest)
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.
clientRequest
- pass in true if this request originated from a client.