Groovy Documentation

grails.async
[Java] Interface PromiseFactory


public interface PromiseFactory

An interface capable of creating Promise instances. The Promises static methods use this interface to create promises. The default Promise creation mechanism can be overriden by setting Promises.setPromiseFactory

Authors:
Graeme Rocher
Since:
2.3


Method Summary
void addPromiseDecoratorLookupStrategy(PromiseDecoratorLookupStrategy lookupStrategy)

Adds a PromiseDecoratorLookupStrategy.

groovy.lang.Closure applyDecorators(groovy.lang.Closure c, java.util.List decorators)

Applies the registered decorators to the given closure

Promise createBoundPromise(java.lang.Object value)

Creates a promise with a value pre-bound to it

Promise createPromise(java.util.Map map)

Creates a promise from the given map where the values of the map are either closures or Promise instances

Promise createPromise(Promise... promises)

Creates a promise from one or more other promises

Promise createPromise(groovy.lang.Closure... c)

Creates a promise from one or many closures

Promise createPromise(groovy.lang.Closure c, java.util.List decorators)

Creates a promise from one or many closures

Promise createPromise(java.util.List closures, java.util.List decorators)

Creates a promise from one or many closures

Promise createPromise(java.util.List closures)

Creates a promise from one or many closures

Promise onComplete(java.util.List promises, groovy.lang.Closure callable)

Executes the given callback when the list of promises completes

Promise onError(java.util.List promises, groovy.lang.Closure callable)

Executes the given callback if an error occurs for the list of promises

java.util.List waitAll(Promise... promises)

Synchronously waits for all promises to complete returning a list of values

java.util.List waitAll(java.util.List promises)

Synchronously waits for all promises to complete returning a list of values

java.util.List waitAll(java.util.List promises, long timeout, java.util.concurrent.TimeUnit units)

Synchronously waits for all promises to complete returning a list of values

 

Method Detail

addPromiseDecoratorLookupStrategy

public void addPromiseDecoratorLookupStrategy(PromiseDecoratorLookupStrategy lookupStrategy)
Adds a PromiseDecoratorLookupStrategy. The strategy implementation must be stateless, do not add a strategy that contains state
Parameters:
lookupStrategy - The lookup strategy


applyDecorators

public groovy.lang.Closure applyDecorators(groovy.lang.Closure c, java.util.List decorators)
Applies the registered decorators to the given closure
Parameters:
c - The closure
decorators - The decorators
Returns:
The decorated closure


createBoundPromise

public Promise createBoundPromise(java.lang.Object value)
Creates a promise with a value pre-bound to it
Parameters:
value - The value
- The type of the value
Returns:
A Promise


createPromise

public Promise createPromise(java.util.Map map)
Creates a promise from the given map where the values of the map are either closures or Promise instances
Parameters:
map - The map
Returns:
A promise


createPromise

public Promise createPromise(Promise... promises)
Creates a promise from one or more other promises
Parameters:
promises - The promises
Returns:
The promise


createPromise

public Promise createPromise(groovy.lang.Closure... c)
Creates a promise from one or many closures
Parameters:
c - One or many closures
Returns:
A promise


createPromise

public Promise createPromise(groovy.lang.Closure c, java.util.List decorators)
Creates a promise from one or many closures
Parameters:
c - One or many closures
Returns:
A promise


createPromise

public Promise createPromise(java.util.List closures, java.util.List decorators)
Creates a promise from one or many closures
Parameters:
closures - One or many closures
Returns:
A promise


createPromise

public Promise createPromise(java.util.List closures)
Creates a promise from one or many closures
Parameters:
closures - One or many closures
Returns:
A promise


onComplete

public Promise onComplete(java.util.List promises, groovy.lang.Closure callable)
Executes the given callback when the list of promises completes
Parameters:
promises - The promises
callable - The callback to execute


onError

public Promise onError(java.util.List promises, groovy.lang.Closure callable)
Executes the given callback if an error occurs for the list of promises
Parameters:
promises - The promises The promises
callable - The error callback to execute


waitAll

public java.util.List waitAll(Promise... promises)
Synchronously waits for all promises to complete returning a list of values
Parameters:
promises - The promises
Returns:
The list of bound values


waitAll

public java.util.List waitAll(java.util.List promises)
Synchronously waits for all promises to complete returning a list of values
Parameters:
promises - The promises
Returns:
The list of bound values


waitAll

public java.util.List waitAll(java.util.List promises, long timeout, java.util.concurrent.TimeUnit units)
Synchronously waits for all promises to complete returning a list of values
Parameters:
promises - The promises
Returns:
The list of bound values


 

Groovy Documentation