Package com.isomorphic.rpc
Class RPCRequest
java.lang.Object
com.isomorphic.base.Base
- All Implemented Interfaces:
com.isomorphic.base.IAutoConfigurable
,com.isomorphic.datasource.Committable
,Callable<RPCResponse>
public class RPCRequest extends BaseRequest<RPCRequest,RPCResponse> implements Callable<RPCResponse>
RPCRequest encapsulates the data sent by the client-side RPCManager. Use the server-side RPCManager class to parse an RPC HttpRequest and retrieve RPCRequest objects.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncall()
Calls through to execute()execute()
If this request is a DMI request, executes the request through the DMI layer and returns an RPCResponse.getAppID()
If this is a DMI request, returns the appID against which this request is being made.getData()
Retrieves the data sent by the client.If this is a DMI request, returns the arguments the client is passing to the DMI method.If this is a DMI request, returns the name of the DMI method being invoked by the client.If this is a DMI request, returns the ID of the ServerObject against which this request is being made.boolean
isDMI()
Returns true if this request is a DMI request, false if it is a custom RPC.Methods inherited from class com.isomorphic.rpc.BaseRequest
freeAllResources, getContext, getDSCacheManager, getDsTransaction, getDSTransaction, getRPCManager, isClientRequest, setClientRequest, setContext, setDSCacheManager, setDsTransaction, setDSTransaction, setRPCManager
-
Method Details
-
getData
Retrieves the data sent by the client. You'll need to cast the data to the appropriate type. The type is determined by the type of JavaScript object that you provided as the "data" parameter to RPCManager.send(). Here's the mapping of JS types to their corresponding Java types:Map of Java type to JS type in an RPCRequest JS Type Java Type Object: {} Map Array: [] List String String Number Long|Double Boolean Boolean Date java.util.Date
Note that the order of keys/values in the Maps created on the server is not guaranteed because JavaScript Object literals do not guarantee order. -
isDMI
public boolean isDMI()Returns true if this request is a DMI request, false if it is a custom RPC.- Returns:
- true if this request is a DMI request, false if it is a custom RPC.
-
getAppID
If this is a DMI request, returns the appID against which this request is being made. This appID maps directly to the the XML definition file as.app.xml. - Returns:
- the appID
- See Also:
-
getServerObjectID
If this is a DMI request, returns the ID of the ServerObject against which this request is being made. Note that this field can contain either the ID of the ServerObject or the className of the ServerObject depending on what was passed by the client.If you're using the loadDMIStubs JSP tag and calling methods directly on the resulting JavaScript classes, the client will always send ServerObject ID if one exists on the ServerObject XML definition and the className if the ID does not exist.
- Returns:
- the ID or className of the ServerObject
- See Also:
-
getMethodName
If this is a DMI request, returns the name of the DMI method being invoked by the client. This maps directly to the 'name' attribute of the <method> definition under ServerObject->visibleMethods in your .app.xml.- Returns:
- the DMI method name being invoked by the client.
- See Also:
-
getMethodArguments
If this is a DMI request, returns the arguments the client is passing to the DMI method. The arguments are in the order provided by the client and have already been translated from JavaScript format to their equivalent Java types.Note that the DMI method invoked may declare that it takes additional, optional arguments that are provided by the DMI layer itself because they cannot be directly passed by the client such as the HttpServletRequest or the HttpSession objects.
- Returns:
- the appID
- See Also:
-
call
Calls through to execute() -
execute
If this request is a DMI request, executes the request through the DMI layer and returns an RPCResponse.If you're writing your own RPC endpoint to replace the provided IDACall, you can use this method in conjuction with isDMI() to preserve builtin DMI handling by writing a dispacher like so:
if (rpcRequest.isDMI()) { rpcManager.send(rpcRequest, rpcRequest.execute()); } else { // Custom RPC - do something with it... }
- Specified by:
execute
in classBaseRequest<RPCRequest,
RPCResponse> - Returns:
- the RPCResponse as generated by the builtin RPC or DMI layer or an error RPCResponse if the request is not a DMI request.
- Throws:
Exception
- if an error occurs during request execution
-