Class PluginGwtRpc
- java.lang.Object
-
- org.pentaho.platform.web.gwt.rpc.AbstractGwtRpc
-
- org.pentaho.platform.web.gwt.rpc.PluginGwtRpc
-
public class PluginGwtRpc extends AbstractGwtRpc
ThePluginGwtRpc
class is a specialized GWT-RPC which can be used to handle remote calls to services of Pentaho Platform plugins, e.g./gwtrpc/serviceName
.Plugin GWT remote services must be registered in the current
IServiceManager
with the service type `gwt`.Plugins can register a remote services in their
plugin.xml
file, using thewebservice
element, like in the following:<webservice id="<serviceName>" type="gwt" class="<my.remote.service.Class>" />
This service would become exposed under the Pentaho context URL
/gwtrpc/<serviceName>
. The class<my.remote.service.Class>
must be accessible in the plugin's class loader and should implement theRemoteService
interface.Plugin remote services handle GWT serialization policies in one of two ways:
A static serialization policy can be defined in the plugin's
plugin.spring.xml
, by registering with the Pentaho System a bean of a class extending fromSerializationPolicy
, such asPentahoSerializationPolicy
. This policy will be used whatever the strong name being requested. For example:<bean class="org.pentaho.platform.web.servlet.PentahoSerializationPolicy"> <property name="whiteList"> <util:list> <value>com.allen_sauer.gwt.dnd.client.DragHandlerCollection</value> ... </util:list> </property> <pen:publish as-type="CLASSES"> <pen:attributes> <pen:attr key="plugin" value="[my-plugin]"/> </pen:attributes> </pen:publish> </bean>
In this example, the classes which are allowed to be exchanged between client and server must be specified in the property named
whiteList
. Moreover, instead of[my-plugin]
, the identifier of the plugin should be used instead.The second way to register serialization policies is by using the GWT-RPC files that GWT automatically creates when compiling GWT code. These files have a custom internal format, are named like
<strong-name>.gwt.rpc
and are placed in the same directory as the remaining compiled GWT code (e.g./content/data-access/resources/gwt/
). One such file could be named825CCA5A63214CE13B23AAA2FCB5C8CA.gwt.rpc
. The serialization policy strong name is unique to it and is not necessarily shared with the strong name of a particular GWT module. This file is searched for anywhere in the plugin's file system, viaIPluginResourceLoader.findResources(ClassLoader, String)
and at least one file with such name must exist, or an error is logged and the loading fails. If more than one file exists, the first one found is used and a warning is logged.
-
-
Field Summary
-
Fields inherited from class org.pentaho.platform.web.gwt.rpc.AbstractGwtRpc
HTTP_GWT_RPC_ATTRIBUTE
-
-
Constructor Summary
Constructors Constructor Description PluginGwtRpc(javax.servlet.http.HttpServletRequest request)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PluginGwtRpc
getInstance(javax.servlet.http.HttpServletRequest httpRequest)
Gets the instance ofPluginGwtRpc
which is associated with the given HTTP request, creating one, if needed.static PluginGwtRpc
getInstance(javax.servlet.http.HttpServletRequest httpRequest, IGwtRpcSerializationPolicyCache serializationPolicyCache)
Gets the instance ofPluginGwtRpc
which is associated with the given HTTP request, creating one, if needed.protected 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 Object
resolveTarget()
Resolves the target object on which the remote call will be made.-
Methods inherited from class org.pentaho.platform.web.gwt.rpc.AbstractGwtRpc
getAppContextPath, getDefaultSerializationPolicy, getInstance, getRequest, getRequestPayload, getSerializationPolicy, getSerializationPolicyCache, getServletContext, getServletContextPath, getServletRequest, getTarget, getTargetClassLoader, invoke, loadSerializationPolicyFromInputStream, setSerializationPolicyCache
-
-
-
-
Method Detail
-
resolveTarget
@NonNull protected Object resolveTarget() throws GwtRpcProxyException
Description copied from class:AbstractGwtRpc
Resolves the target object on which the remote call will be made.- Specified by:
resolveTarget
in classAbstractGwtRpc
- Returns:
- The target object.
- Throws:
GwtRpcProxyException
- if the target object cannot be resolved.
-
loadSerializationPolicy
@Nullable protected com.google.gwt.user.server.rpc.SerializationPolicy loadSerializationPolicy(@NonNull String moduleContextPath, @Nullable String strongName)
Description copied from class:AbstractGwtRpc
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.
- Specified by:
loadSerializationPolicy
in classAbstractGwtRpc
- 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 byAbstractGwtRpc.getDefaultSerializationPolicy()
.
-
getInstance
@NonNull public static PluginGwtRpc getInstance(@NonNull javax.servlet.http.HttpServletRequest httpRequest)
Gets the instance ofPluginGwtRpc
which is associated with the given HTTP request, creating one, if needed.This method does not use a
IGwtRpcSerializationPolicyCache
which becomes associated to a created instance for retrieving the appropriate serialization policy. To specify a serialization policy cache, use the methodgetInstance(HttpServletRequest, IGwtRpcSerializationPolicyCache)
.- Parameters:
httpRequest
- The HTTP request.- Returns:
- The associated
PluginGwtRpc
instance.
-
getInstance
@NonNull public static PluginGwtRpc getInstance(@NonNull javax.servlet.http.HttpServletRequest httpRequest, @Nullable IGwtRpcSerializationPolicyCache serializationPolicyCache)
Gets the instance ofPluginGwtRpc
which is associated with the given HTTP request, creating one, if needed.When the instance needs to be created, the given
IGwtRpcSerializationPolicyCache
, viaserializationPolicyCache
, is associated with it.- Parameters:
httpRequest
- The HTTP request.serializationPolicyCache
- A serialization policy cache instance to initialize a created instance with.- Returns:
- The associated
PluginGwtRpc
instance. - See Also:
AbstractGwtRpc.getInstance(HttpServletRequest, java.util.function.Function, IGwtRpcSerializationPolicyCache)
-
-