- All Implemented Interfaces and Traits:
- java.lang.annotation.Annotation
@java.lang.annotation.Documented
@java.lang.annotation.Retention(value: RetentionPolicy.SOURCE)
@java.lang.annotation.Target(value: [ElementType.TYPE, ElementType.FIELD])
@org.codehaus.groovy.transform.GroovyASTTransformationClass(value: org.grails.async.transform.internal.DelegateAsyncTransformation)
@interface DelegateAsync
An AST transformation that takes each method in the given class and adds a delegate method that returns a Promise and executes the method asynchronously.
For example given the following class:
class BookApi {
List listBooksByTitle(String title) { }
}
If the annotation is applied to a new class:
@DelegateAsync(BookApi)
class AsyncBookApi {}
The resulting class is transformed into:
class AsyncBookApi {
private BookApi $bookApi
Promise> listBooksByTitle(String title) {
(Promise>)Promises.createPromise {
$bookApi.listBooksByTitle(title)
}
}
}
- Authors:
- Graeme Rocher
- Since:
- 2.3