AutoRPC GWT Generator
Annotation processor to generate GWT RPC async interfaces and RxJava adapter types. Add autorpc-gwt-processor
to your classpath (not required at runtime) and your async interfaces will be automatically generated. Rx interfaces will be generated only if the RxJava library is in the classpath.
Example project here. To run the example project just execute mvn gwt:devmode
from parent project.
Download
Releases are deployed to the Central Repository.
Snapshots of the development version are available in Sonatype's snapshots
repository.
Notes
The processor generates async interfaces for all classes annotated with @RemoteServiceRelativePath
. This should works correctly almost always, but if you do not use this annotation you can use @AutoRpcGwt
annotation included in the autorpc-gwt-annotations
project (in this case, you should add this project as a dependency). However, if what you want is to skip the generation of one of yours services, you can add the annotation @SkipRpcGwt
. You can use whatever annotation that matches this name or just add a dependency to autorpc-gwt-annotations
and use the provided one.
Async interfaces returns always Request
. GWT RPC support void
, Request
and RequestBuilder
as return types, but this libs has considered that there are no advantages of returning void
instead of Request
. And returning Request
might be interesting in some situations like request cancellation (automatically done by the Rx adapter if the observable is unsubscribed). RequestBuilder
might be used in some cases to add some header, this return type is not supported to simplify implementation, but you can (and, IMO should) manipulate the RequestBuilder
using a custom RpcRequestBuilder
and overriding doCreate
or doFinish
like in this example.
GreetingServiceAsync async = GWT.create(GreetingService.class);
((RemoteServiceProxy) async).setRpcRequestBuilder(new RpcRequestBuilder() {
@Override protected void doFinish(RequestBuilder rb) {
super.doFinish(rb);
rb.setHeader("X-Custom-Header", "Hi!");
}
});