Class PluginGwtRpc


  • public class PluginGwtRpc
    extends AbstractGwtRpc
    The PluginGwtRpc 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 the webservice 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 the RemoteService 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 from SerializationPolicy, such as PentahoSerializationPolicy. 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 named 825CCA5A63214CE13B23AAA2FCB5C8CA.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, via IPluginResourceLoader.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.