codejuicer / asynchronize

Java APT processor to generate an asynchronous version of interfaces
Apache License 2.0
3 stars 0 forks source link

Asynchronize Processor

Generates an asynchronous version of a Java interface by using APT

Maven Coordinates

<dependency>
    <groupId>org.codejuicer</groupId>
    <artifactId>asynchronize-processor</artifactId>
    <version>0.9.1</version>
</dependency>

Overview

-- Watch a 4 minutes Video overview of the library --

This processor generates an 'asynchronous' interface from a Java interface, and creates a copy of all the methods accepting an extra argument for callback.

For examples, given the interface:

@Asynchronize
public interface Hello {
  String sayHello(String hello);
}

The following is generated by the processor:

public interface HelloAsync {
  void sayHello(String hello, AsyncCallback<String> callback);
}

It is designed to be used for GWT by specyfing its AsyncCallback as annotation option:

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.RemoteService;

import org.codejuicer.asynchronize.annotation.Asynchronize;

@Asynchronize(callback = AsyncCallback.class)
public interface MyGwtRpcService extends RemoteService {
// ...
}

It is however indipendent from GWT and can be used also with other platforms, for example with Guava's FutureCallback. It can be used to generate interfaces that can be imported in Android.

The processor is dedicated to automate the generation of the interface only and do not provide (yet) a framework to implement asynchronous calls in java.

Usage Options:

Work in progress - see subproject asynchronize-example

Q&A

Please open a github issue for tech or documentation questions