Class AbstractGwtRpc
- Direct Known Subclasses:
PluginGwtRpc
,SystemGwtRpc
AbstractGwtRpc
class is the base abstract class of classes that represent a GWT
Remote Procedure Call which is made via HTTP.
One instance of this class is initialized with the HttpServletRequest
instance which represents a GWT-RPC
request.
The class exposes functionality to:
-
obtain the target object of the GWT-RPC request, via
getTarget()
; -
obtain the class loader which should be current when the call is performed, via
getTargetClassLoader()
; -
obtain the serialized request payload from the HTTP request, via
getRequestPayload()
; this is useful for low-level integration withRemoteServiceServlet
; -
obtain the parsed request, via
getRequest()
; - invoke the target method on the target object within its class loader and to return a serialized response.
Concrete specialized classes exist that can handle GWT-RPC requests for services of:
-
PluginGwtRpc
- services of Pentaho Platform plugins, e.g./gwtrpc/serviceName
; -
SystemGwtRpc
- services of the Pentaho Platform itself, e.g./ws/gwt/serviceName
.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractGwtRpc
(javax.servlet.http.HttpServletRequest httpRequest) Creates an instance given an HTTP request. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
Gets the associated web app context path.protected static com.google.gwt.user.server.rpc.SerializationPolicy
Gets a serialization policy to use when no specific serialization policy is available.protected static <R extends AbstractGwtRpc>
RgetInstance
(javax.servlet.http.HttpServletRequest httpRequest, Function<javax.servlet.http.HttpServletRequest, R> factory, IGwtRpcSerializationPolicyCache serializationPolicyCache) Gets the instance of a sub-class ofAbstractGwtRpc
,R
, which is stored in the given HTTP request, if there is one already, or creates one and stores it if not.com.google.gwt.user.server.rpc.RPCRequest
Gets the processed GWT-RPC request object.Gets the serialized request payload which is present in the HTTP request.protected com.google.gwt.user.server.rpc.SerializationPolicy
getSerializationPolicy
(String moduleBaseURL, String strongName) Gets the serialization policy cache instance used by this GWT-RPC call.protected javax.servlet.ServletContext
Gets the associated servlet context.protected String
Gets the associated servlet context path.javax.servlet.http.HttpServletRequest
Gets the associated HTTP request.Gets the target object on which the remote call will be made.Gets the class loader which must be current to deserialize the request, invoke the method and serialize the response.invoke()
Makes the remote call on the target object and returns the serialized response.protected abstract com.google.gwt.user.server.rpc.SerializationPolicy
loadSerializationPolicy
(String moduleContextPath, String strongName) Loads the serialization policy having the given GWT module context path and strong name.protected static com.google.gwt.user.server.rpc.SerializationPolicy
loadSerializationPolicyFromInputStream
(ThrowingSupplier<InputStream, IOException> inputStreamSupplier, String serializationPolicyFileName) Loads a serialization policy given an input stream whose content is in GWT-RPC serialization policy standard format.protected abstract Object
Resolves the target object on which the remote call will be made.void
setSerializationPolicyCache
(IGwtRpcSerializationPolicyCache serializationPolicyCache) Sets the serialization policy cache which will be used to load a serialization policy before creating one, or to store the created one if none exists.
-
Field Details
-
HTTP_GWT_RPC_ATTRIBUTE
-
-
Constructor Details
-
AbstractGwtRpc
protected AbstractGwtRpc(@NonNull javax.servlet.http.HttpServletRequest httpRequest) Creates an instance given an HTTP request.- Parameters:
httpRequest
- An HTTP request.
-
-
Method Details
-
setSerializationPolicyCache
public void setSerializationPolicyCache(@Nullable IGwtRpcSerializationPolicyCache serializationPolicyCache) Sets the serialization policy cache which will be used to load a serialization policy before creating one, or to store the created one if none exists.The serialization policy is used to safely deserialize the GWT-RPC request and serialize the GWT-RPC response of this call.
- Parameters:
serializationPolicyCache
- A serialization policy cache instance, ornull
.
-
getSerializationPolicyCache
Gets the serialization policy cache instance used by this GWT-RPC call.- Returns:
- The serialization policy cache instance, if any;
null
, otherwise.
-
getServletRequest
@NonNull public javax.servlet.http.HttpServletRequest getServletRequest()Gets the associated HTTP request.- Returns:
- An HTTP request.
-
getServletContext
@NonNull protected javax.servlet.ServletContext getServletContext()Gets the associated servlet context.Syntax-sugar method equivalent to
getServletRequest().getServletContext()
.- Returns:
- A servlet context.
-
getAppContextPath
Gets the associated web app context path.Syntax-sugar method equivalent to
getServletRequest().getContextPath()
.Example value:
/pentaho
.- Returns:
- The servlet context path.
-
getServletContextPath
Gets the associated servlet context path.Example value:
/gwt/rpc/serviceName?bar=foo
.- Returns:
- The servlet context path.
-
getTarget
Gets the target object on which the remote call will be made.- Returns:
- The target object.
- Throws:
GwtRpcProxyException
- if the target object cannot be resolved.
-
getTargetClassLoader
Gets the class loader which must be current to deserialize the request, invoke the method and serialize the response.- Returns:
- The target class laoder.
- Throws:
GwtRpcProxyException
- if the target class loader cannot be resolved.
-
resolveTarget
Resolves the target object on which the remote call will be made.- Returns:
- The target object.
- Throws:
GwtRpcProxyException
- if the target object cannot be resolved.
-
getRequestPayload
Gets the serialized request payload which is present in the HTTP request.- Returns:
- The serialized request payload.
- Throws:
GwtRpcProxyException
- if the request is not valid.- See Also:
-
RPCServletUtils.readContentAsGwtRpc(HttpServletRequest)
-
getRequest
@NonNull public com.google.gwt.user.server.rpc.RPCRequest getRequest()Gets the processed GWT-RPC request object.- Returns:
- The processed request.
- Throws:
GwtRpcProxyException
- if the request is invalid.- See Also:
-
RPC.decodeRequest(String, Class, com.google.gwt.user.server.rpc.SerializationPolicyProvider)
-
getSerializationPolicy
-
loadSerializationPolicy
@Nullable protected abstract com.google.gwt.user.server.rpc.SerializationPolicy loadSerializationPolicy(@NonNull String moduleContextPath, @Nullable String strongName) Loads the serialization policy having the given GWT module context path and strong name.Typically, this method loads a serialization policy from a persistence medium.
- Parameters:
moduleContextPath
- The GWT module context path (e.g./content/data-access/resources/gwt/
).strongName
- The serialization policy strong name.- Returns:
- The associated serialization policy, if one can be loaded;
null
, otherwise, in which case the default serialization policy is assumed, as returned bygetDefaultSerializationPolicy()
.
-
getDefaultSerializationPolicy
@NonNull protected static com.google.gwt.user.server.rpc.SerializationPolicy getDefaultSerializationPolicy()Gets a serialization policy to use when no specific serialization policy is available.the default serialization policy is a legacy, 1.3.3 compatible, serialization policy and may result in
SerializationException
.- Returns:
- The default serialization policy.
- See Also:
-
RPC.getDefaultSerializationPolicy()
-
loadSerializationPolicyFromInputStream
@Nullable protected static com.google.gwt.user.server.rpc.SerializationPolicy loadSerializationPolicyFromInputStream(@NonNull ThrowingSupplier<InputStream, IOException> inputStreamSupplier, @NonNull String serializationPolicyFileName) Loads a serialization policy given an input stream whose content is in GWT-RPC serialization policy standard format.Helper method for custom implementations.
- Parameters:
inputStreamSupplier
- A supplier of an input stream of the serialization policy.serializationPolicyFileName
- The serialization policy file name; used for logging purposes, only.- Returns:
- The loaded serialization policy, if successfully loaded;
null
, otherwise.
-
invoke
Makes the remote call on the target object and returns the serialized response.- Returns:
- The serialized response.
- Throws:
GwtRpcProxyException
- if the call does not succeed.
-
getInstance
@NonNull protected static <R extends AbstractGwtRpc> R getInstance(@NonNull javax.servlet.http.HttpServletRequest httpRequest, @NonNull Function<javax.servlet.http.HttpServletRequest, R> factory, @Nullable IGwtRpcSerializationPolicyCache serializationPolicyCache) Gets the instance of a sub-class ofAbstractGwtRpc
,R
, which is stored in the given HTTP request, if there is one already, or creates one and stores it if not.The GWT-RPC instance is stored in an HTTP request attribute, as per
ServletRequest.getAttribute(String)
andServletRequest.setAttribute(String, Object)
.Helper method for custom implementations.
- Parameters:
httpRequest
- The HTTP request.factory
- A function which creates an instance of classR
given an HTTP request.serializationPolicyCache
- A serialization policy cache instance to initialize a created instance with.- Returns:
- The associated GWT-RPC instance.
- See Also:
-