GWT-maven-plugin can generate asynchronous interface for your GWT-RPC services. Considering the following Server-side RPC interface:
import com.google.gwt.user.client.rpc.RemoteService;
public interface HelloWorldService
extends RemoteService
{
String helloWorld( String message );
}
.. the plugin will automagically generate the asynchrounous interface used on client-side code. Thanks to this feature, you don't have to write and maintain this boring code. As a bonus, the generated code includes an utility class to retrieve the RPC proxy from client-side code:
@RemoteServiceRelativePath( "HelloWorld" )
public interface HelloWorldServiceAsync
{
String helloWorld( String message, AsyncCallBack<String> callback );
public static class Util
{
public static ContactPrefereServiceAsync getInstance()
...
}
}
The generated interface includes a nested Util class to help retrieve an HelloWorldServiceAsync implementation.
The plugin will use @RemoteServiceRelativePath annotation on the service interface to set the service URI in this utility class. In previous example, the service will be bound to URI [module]/HelloWorld. If not present, the service URI is constructed from interface name applying the rpcPattern format. Setting this parameter to ".rpc" will create an Util class to retrieve the service on URI [module]/HelloWorldService.rpc.
To enable this feature, simply include the generateAsync goal in your POM.xml:
<project>
[...]
<build>
<plugins>
[...]
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>generateAsync</goal>
</goals>
</execution>
</executions>
</plugin>
[...]
</plugins>
</build>
[...]
</project>
To avoid full scan of project sources, the plugin uses a naming convention for RPC services. By default, it only checks **/*Service.java source files. You can override this convention using the servicePattern parameter.
The rpcExtension is used to configure the URL pattern used on the server to publish the GWT-RPC services. It will be used by the generator to create helper code (see later).
The failOnError parameter can also be helpfull if you have issue with the generator.