public String processCall(String payload) throws SerializationException { try { RPCRequest rpcRequest = RPC.decodeRequest(payload, this.getClass()); return RPC.invokeAndEncodeResponse(this, rpcRequest.getMethod(), rpcRequest.getParameters()); } catch (IncompatibleRemoteServiceException ex) { return RPC.encodeResponseForFailure(null, ex); } }
public void doPost(HttpServletRequest httpRequest, HttpServletResponse httpResponse) { String payload = readPayloadAsUtf8(httpRequest); try { try { RPCRequest rpcRequest = RPC.decodeRequest(payload); Object targetInstance = getInstanceToHandleRequest(httpRequest, rpcRequest); Method targetMethod = maybeMapRequestedMethod(targetInstance, rpcRequest.getMethod()); Object[] targetParameters = maybeMapParameters(rpcRequest.getParameters()); try { Object result = targetMethod.invoke(targetInstance, targetParameters); result = maybeMapResult(rpcRequest.getMethod(), result); /* * Encode the object that will be given to the client code's * AsyncCallback::onSuccess(Object) method. */ String encodedResult = RPC.encodeResponseForSuccess( rpcRequest.getMethod(), result); sendResponseForSuccess(httpResponse, encodedResult); } catch (IllegalArgumentException e) { SecurityException securityException = new SecurityException( "Blocked attempt to invoke method " + targetMethod); securityException.initCause(e); throw securityException; } catch (IllegalAccessException e) { SecurityException securityException = new SecurityException( "Blocked attempt to access inaccessible method " + targetMethod + (targetInstance != null ? " on target " + targetInstance : "")); securityException.initCause(e); throw securityException; } catch (InvocationTargetException e) { Throwable cause = e.getCause(); Throwable mappedThrowable = maybeMapThrowable(cause, rpcRequest.getMethod()); /* * Encode the exception that will be passed back to the client's * client code's AsyncCallback::onFailure(Throwable) method. */ String failurePayload = RPC.encodeResponseForFailure( rpcRequest.getMethod(), mappedThrowable); sendResponseForFailure(httpResponse, failurePayload); } } catch (IncompatibleRemoteServiceException e) { sendResponseForFailure(httpResponse, RPC.encodeResponseForFailure(null, e)); } } catch (Throwable e) { /* * Return a generic error which will be passed to the client code's * AsyncCallback::onFailure(Throwable) method. */ sendResponseForGenericFailure(httpResponse); } }
decodeRequest(String) | Returns an RPCRequest that is built by decoding the contents of an encoded RPC request. |
decodeRequest(String, Class) | Returns an RPCRequest that is built by decoding the contents of an encoded RPC request and optionally validating that type can handle the request. |
decodeRequest(String, Class, SerializationPolicyProvider) | Returns an RPCRequest that is built by decoding the contents of an encoded RPC request and optionally validating that type can handle the request. |
encodeResponseForFailure(Method, Throwable) | Returns a string that encodes an exception. |
encodeResponseForFailure(Method, Throwable, SerializationPolicy) | Returns a string that encodes an exception. |
encodeResponseForSuccess(Method, Object) | Returns a string that encodes the object. |
encodeResponseForSuccess(Method, Object, SerializationPolicy) | Returns a string that encodes the object. |
getDefaultSerializationPolicy() | Returns a default serialization policy. |
invokeAndEncodeResponse(Object, Method, Object[]) | Returns a string that encodes the result of calling a service method, which could be the value returned by the method or an exception thrown by it. |
invokeAndEncodeResponse(Object, Method, Object[], SerializationPolicy) | Returns a string that encodes the result of calling a service method, which could be the value returned by the method or an exception thrown by it. |
This method is equivalent to calling decodeRequest(String, Class)
with null
for the type parameter.
null
, the
implementation checks that the type is assignable to the
RemoteService interface requested in the encoded request string.
Invoking this method with null
for the type parameter,
decodeRequest(encodedRequest, null)
, is equivalent to
calling decodeRequest(encodedRequest)
.
null
, the implementation checks that the
type is assignable to the RemoteService interface encoded
in the encoded request string.null
, the
implementation checks that the type is assignable to the
RemoteService interface requested in the encoded request string.
If the serializationPolicyProvider parameter is not null
, it is
asked for a SerializationPolicy to use to restrict the set of types
that can be decoded from the request. If this parameter is
null
, then only subtypes of
IsSerializable or
types which have custom field serializers can be decoded.
Invoking this method with null
for the type parameter,
decodeRequest(encodedRequest, null)
, is equivalent to
calling decodeRequest(encodedRequest)
.
null
, the implementation checks that the
type is assignable to the RemoteService interface encoded
in the encoded request string.null
, the
implementation asks this provider for a
SerializationPolicy which will be used to restrict the set
of types that can be decoded from this requestnull
, it is an error if the exception is not in the
method's list of checked exceptions.null
null
, it is an error if the exception is not in the
method's list of checked exceptions.
If the serializationPolicy parameter is not null
, it is used to
determine what types can be encoded as part of this response. If this
parameter is null
, then only subtypes of
IsSerializable or
types which have custom field serializers may be encoded.
null
If the serializationPolicy parameter is not null
, it is used to
determine what types can be encoded as part of this response. If this
parameter is null
, then only subtypes of
IsSerializable or
types which have custom field serializers may be encoded.
This method does no security checking; security checking must be done on the method prior to this invocation.
If the serializationPolicy parameter is not null
, it is used to
determine what types can be encoded as part of this response. If this
parameter is null
, then only subtypes of
IsSerializable or
types which have custom field serializers may be encoded.
This method does no security checking; security checking must be done on the method prior to this invocation.