| java.lang.Object com.google.gwt.user.server.rpc.RPC
RPC | final public class RPC (Code) | | Utility class for integrating with the RPC system. This class exposes methods
for decoding of RPC requests, encoding of RPC responses, and invocation of
RPC calls on service objects. The operations exposed by this class can be
reused by framework implementors such as Spring and G4jsf to support a wide
range of service invocation policies.
Canonical Example
The following example demonstrates the canonical way to use this class.
Advanced Example
The following example shows a more advanced way of using this class to create
an adapter between GWT RPC entities and POJOs.
|
Method Summary | |
public static RPCRequest | decodeRequest(String encodedRequest) Returns an
RPCRequest that is built by decoding the contents of an
encoded RPC request. | public static RPCRequest | decodeRequest(String encodedRequest, Class> type) Returns an
RPCRequest that is built by decoding the contents of an
encoded RPC request and optionally validating that type can handle the
request. | public static RPCRequest | decodeRequest(String encodedRequest, Class> type, SerializationPolicyProvider 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. | public static String | encodeResponseForFailure(Method serviceMethod, Throwable cause) Returns a string that encodes an exception. | public static String | encodeResponseForFailure(Method serviceMethod, Throwable cause, SerializationPolicy serializationPolicy) Returns a string that encodes an exception. | public static String | encodeResponseForSuccess(Method serviceMethod, Object object) Returns a string that encodes the object. | public static String | encodeResponseForSuccess(Method serviceMethod, Object object, SerializationPolicy serializationPolicy) Returns a string that encodes the object. | public static SerializationPolicy | getDefaultSerializationPolicy() Returns a default serialization policy. | public static String | invokeAndEncodeResponse(Object target, Method serviceMethod, Object[] args) 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. | public static String | invokeAndEncodeResponse(Object target, Method serviceMethod, Object[] args, SerializationPolicy 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.
If the serializationPolicy parameter is not null , it is
used to determine what types can be encoded as part of this response. |
decodeRequest | public static RPCRequest decodeRequest(String encodedRequest)(Code) | | Returns an
RPCRequest that is built by decoding the contents of an
encoded RPC request.
This method is equivalent to calling
RPC.decodeRequest(String,Class) with null for the type parameter.
Parameters: encodedRequest - a string that encodes the RemoteServiceinterface, the service method to call, and the arguments to forthe service method an RPCRequest instance throws: IncompatibleRemoteServiceException - if any of the followingconditions apply:- if the types in the encoded request cannot be deserialized
- if the ClassLoader acquired from
Thread.currentThread().getContextClassLoader() cannot load the service interface or any of the types specifiedin the encodedRequest - the requested interface is not assignable toRemoteService
- the service method requested in the encodedRequest is not amember of the requested service interface
- the type parameter is not
null and is notassignable to the requested RemoteService interface
|
decodeRequest | public static RPCRequest decodeRequest(String encodedRequest, Class> type)(Code) | | Returns an
RPCRequest that is built by decoding the contents of an
encoded RPC request and optionally validating that type can handle the
request. If the type parameter is not 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) .
Parameters: encodedRequest - a string that encodes the RemoteServiceinterface, the service method, and the arguments to pass to theservice method Parameters: type - if not null , the implementation checks that thetype is assignable to the RemoteService interface encodedin the encoded request string. an RPCRequest instance throws: NullPointerException - if the encodedRequest is null throws: IllegalArgumentException - if the encodedRequest is an empty string throws: IncompatibleRemoteServiceException - if any of the followingconditions apply:- if the types in the encoded request cannot be deserialized
- if the ClassLoader acquired from
Thread.currentThread().getContextClassLoader() cannot load the service interface or any of the types specifiedin the encodedRequest - the requested interface is not assignable toRemoteService
- the service method requested in the encodedRequest is not amember of the requested service interface
- the type parameter is not
null and is notassignable to the requested RemoteService interface
|
decodeRequest | public static RPCRequest decodeRequest(String encodedRequest, Class> type, SerializationPolicyProvider serializationPolicyProvider)(Code) | | Returns an
RPCRequest that is built by decoding the contents of an
encoded RPC request and optionally validating that type can handle the
request. If the type parameter is not 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
com.google.gwt.user.client.rpc.IsSerializable 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) .
Parameters: encodedRequest - a string that encodes the RemoteServiceinterface, the service method, and the arguments to pass to theservice method Parameters: type - if not null , the implementation checks that thetype is assignable to the RemoteService interface encodedin the encoded request string. Parameters: serializationPolicyProvider - if not null , theimplementation asks this provider for aSerializationPolicy which will be used to restrict the setof types that can be decoded from this request an RPCRequest instance throws: NullPointerException - if the encodedRequest is null throws: IllegalArgumentException - if the encodedRequest is an empty string throws: IncompatibleRemoteServiceException - if any of the followingconditions apply:- if the types in the encoded request cannot be deserialized
- if the ClassLoader acquired from
Thread.currentThread().getContextClassLoader() cannot load the service interface or any of the types specifiedin the encodedRequest - the requested interface is not assignable toRemoteService
- the service method requested in the encodedRequest is not amember of the requested service interface
- the type parameter is not
null and is notassignable to the requested RemoteService interface
|
encodeResponseForFailure | public static String encodeResponseForFailure(Method serviceMethod, Throwable cause) throws SerializationException(Code) | | Returns a string that encodes an exception. If method is not
null , it is an error if the exception is not in the
method's list of checked exceptions.
Parameters: serviceMethod - the method that threw the exception, may benull Parameters: cause - the Throwable that was thrown a string that encodes the exception throws: NullPointerException - if the the cause is null throws: SerializationException - if the result cannot be serialized throws: UnexpectedException - if the result was an unexpected exception (achecked exception not declared in the serviceMethod's signature) |
encodeResponseForFailure | public static String encodeResponseForFailure(Method serviceMethod, Throwable cause, SerializationPolicy serializationPolicy) throws SerializationException(Code) | | Returns a string that encodes an exception. If method is not
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
com.google.gwt.user.client.rpc.IsSerializable IsSerializable or
types which have custom field serializers may be encoded.
Parameters: serviceMethod - the method that threw the exception, may benull Parameters: cause - the Throwable that was thrown Parameters: serializationPolicy - determines the serialization policy to be used a string that encodes the exception throws: NullPointerException - if the the cause or the serializationPolicyare null throws: SerializationException - if the result cannot be serialized throws: UnexpectedException - if the result was an unexpected exception (achecked exception not declared in the serviceMethod's signature) |
encodeResponseForSuccess | public static String encodeResponseForSuccess(Method serviceMethod, Object object) throws SerializationException(Code) | | Returns a string that encodes the object. It is an error to try to encode
an object that is not assignable to the service method's return type.
Parameters: serviceMethod - the method whose result we are encoding Parameters: object - the instance that we wish to encode a string that encodes the object, if the object is compatible withthe service method's declared return type throws: IllegalArgumentException - if the result is not assignable to theservice method's return type throws: NullPointerException - if the service method is null throws: SerializationException - if the result cannot be serialized |
encodeResponseForSuccess | public static String encodeResponseForSuccess(Method serviceMethod, Object object, SerializationPolicy serializationPolicy) throws SerializationException(Code) | | Returns a string that encodes the object. It is an error to try to encode
an object that is not assignable to the service method's return type.
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
com.google.gwt.user.client.rpc.IsSerializable IsSerializable or
types which have custom field serializers may be encoded.
Parameters: serviceMethod - the method whose result we are encoding Parameters: object - the instance that we wish to encode Parameters: serializationPolicy - determines the serialization policy to be used a string that encodes the object, if the object is compatible withthe service method's declared return type throws: IllegalArgumentException - if the result is not assignable to theservice method's return type throws: NullPointerException - if the serviceMethod or theserializationPolicy are null throws: SerializationException - if the result cannot be serialized |
getDefaultSerializationPolicy | public static SerializationPolicy getDefaultSerializationPolicy()(Code) | | Returns a default serialization policy.
the default serialization policy. |
invokeAndEncodeResponse | public static String invokeAndEncodeResponse(Object target, Method serviceMethod, Object[] args) throws SerializationException(Code) | | 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 does no security checking; security checking must be done on
the method prior to this invocation.
Parameters: target - instance on which to invoke the serviceMethod Parameters: serviceMethod - the method to invoke Parameters: args - arguments used for the method invocation a string which encodes either the method's return or a checkedexception thrown by the method throws: SecurityException - if the method cannot be accessed or if the numberor type of actual and formal arguments differ throws: SerializationException - if an object could not be serialized by thestream throws: UnexpectedException - if the serviceMethod throws a checked exceptionthat is not declared in its signature |
invokeAndEncodeResponse | public static String invokeAndEncodeResponse(Object target, Method serviceMethod, Object[] args, SerializationPolicy serializationPolicy) throws SerializationException(Code) | | 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.
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
com.google.gwt.user.client.rpc.IsSerializable 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.
Parameters: target - instance on which to invoke the serviceMethod Parameters: serviceMethod - the method to invoke Parameters: args - arguments used for the method invocation Parameters: serializationPolicy - determines the serialization policy to be used a string which encodes either the method's return or a checkedexception thrown by the method throws: NullPointerException - if the serviceMethod or theserializationPolicy are null throws: SecurityException - if the method cannot be accessed or if the numberor type of actual and formal arguments differ throws: SerializationException - if an object could not be serialized by thestream throws: UnexpectedException - if the serviceMethod throws a checked exceptionthat is not declared in its signature |
|
|