Package com.yahoo.jrt
Class Request
java.lang.Object
com.yahoo.jrt.Request
A Request bundles information about a single RPC invocation. A
Request contains the name of the method, the method parameters, the
method return values and also error information if something went
wrong. Request objects are used by both RPC clients and RPC
servers. An RPC client is the one requesting the invocation. An RPC
server is the one performing the invocation. The RPC client uses a
Target
to invoke the request. The RPC server registers a
Method
with the Supervisor
. Note that RPC
client/server roles are independent of connection client/server
roles, since invocations can be performed both ways across a Target
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
abort()
Abort a request.boolean
checkReturnTypes
(String returnTypes) Check if this Request contains return types compatible with the given type string.void
detach()
Detach a method invocation.void
Create a new empty set of parameters for this request.int
Obtain the error code associated with this RequestObtain the error message associated with this Request, if anyObtain the application context associated with this request.boolean
isError()
Check if an error has occurred with this RequestObtain the method nameObtain the parametersvoid
Return this request.Obtain the return valuesvoid
setContext
(Object context) Set the application context associated with this request.void
Register the fact that an error has occurred.target()
Obtain the Target representing our end of the connection over which this request was invoked.toString()
-
Constructor Details
-
Request
Create a new Request with the given method name.- Parameters:
methodName
- name of the method you want to invoke
-
-
Method Details
-
setContext
Set the application context associated with this request.- Parameters:
context
- application context
-
getContext
Obtain the application context associated with this request.- Returns:
- application context
-
methodName
Obtain the method name- Returns:
- method name
-
parameters
Obtain the parameters- Returns:
- request parameters
-
returnValues
Obtain the return values- Returns:
- request return values
-
discardParameters
public void discardParameters()Create a new empty set of parameters for this request. The old set of parameters will still be valid, but will no longer be part of this request. This method may be used to allow earlier garbage collection of large parameters that are no longer needed. While the obvious use of this method is to get rid of parameters when being an RPC server it can also be used after starting an RPC request on a client. -
target
Obtain the Target representing our end of the connection over which this request was invoked. This method may only be invoked during method handling (RPC server aspect).- Returns:
- Target representing our end of the connection over which this request was invoked
- Throws:
IllegalStateException
- if invoked inappropriately
-
abort
public void abort()Abort a request. This method may only be called by the RPC client after an asynchronous method invocation was requested.- Throws:
IllegalStateException
- if invoked inappropriately
-
detach
public void detach()Detach a method invocation. This method may only be invoked during method handling (RPC server aspect). If this method is invoked, the method is not returned when the method handler returns. Instead, the application must invoke thereturnRequest
method when it wants the request to be returned.- Throws:
IllegalStateException
- if invoked inappropriately
-
returnRequest
public void returnRequest()Return this request. This method may only be invoked after thedetach
method has been invoked, and only once per request. Note that if you detach a method without invoking this method, it will never be returned, causing a resource leak (NB: not good).- Throws:
IllegalStateException
- if invoked inappropriately
-
setError
Register the fact that an error has occurred.- Parameters:
errorCode
- the error code (seeErrorCode
)errorMessage
- the error message
-
checkReturnTypes
Check if this Request contains return types compatible with the given type string. If this Request contains an error it is considered incompatible with all possible type strings. If the return values are not compatible with the given type string and an error condition is not set, theErrorCode.WRONG_RETURN
error will be set. This method is intended to be used by the RPC client after a method has been invoked to verify the return value types. Please refer to theMethod
class description for an explanation of type strings.- Parameters:
returnTypes
- type string- Returns:
- true if all is ok and the return types are compatible with 'returnTypes'
-
isError
public boolean isError()Check if an error has occurred with this Request- Returns:
- true if an error has occurred
-
errorCode
public int errorCode()Obtain the error code associated with this Request- Returns:
- error code
-
errorMessage
Obtain the error message associated with this Request, if any- Returns:
- error message
-
toString
-