Groovy Documentation

grails.async
[Groovy] Annotation Type DelegateAsync

java.lang.Object
  grails.async.DelegateAsync

@java.lang.annotation.Documented
@java.lang.annotation.Retention(RetentionPolicy.SOURCE)
@java.lang.annotation.Target([ElementType.TYPE, ElementType.FIELD])
@org.codehaus.groovy.transform.GroovyASTTransformationClass("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


Method Summary
java.lang.Class value()

@default DelegateAsync

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Method Detail

value

java.lang.Class value()
Default:
DelegateAsync


 

Groovy Documentation