Reaction Home

com.zynaptic.reaction
Interface DeferredConcentrator<T>

Type Parameters:
T - This type parameter identifies the type of the data object which will be passed into the deferred concentrator via the input deferred event objects.

public interface DeferredConcentrator<T>

Defines a concentrator for deferred events. This allows the results of multiple deferred event callbacks to be assembled into a list and then passed up a single output callback chain. A list is assembled by adding input deferred event objects, then requesting the output deferred event object - which implies that the input list is complete.

A callback will be generated by the output deferred event only if all input deferred events completed successfully. In this case, the callback parameter will be an array list containing the callback data returned by each of the input callback chains, listed according to the order in which the deferred event objects were added.

If an errback is encountered on any of the input deferred events, it will be propagated to the output callback chain and all other results will be discarded. Only the first errback condition to be generated will be passed back in this way.


Method Summary
 void addInputDeferred(Deferred<T> deferred)
          Adds an input deferred event object to the concentrator list.
 Deferred<java.util.List<T>> getOutputDeferred()
          Accesses the output deferred event object for the concentrator list.
 

Method Detail

addInputDeferred

void addInputDeferred(Deferred<T> deferred)
                      throws DeferredTerminationException
Adds an input deferred event object to the concentrator list. The callback chain associated with the deferred event object will automatically be terminated.

Parameters:
deferred - This is the deferred event object which is to be added to the concentrator list.
Throws:
DeferredTerminationException - This exception is thrown if the deferred event object being passed as the parameter has already had its callback chain terminated, or the output deferred event object has already been requested which prevents further additions to the list.

getOutputDeferred

Deferred<java.util.List<T>> getOutputDeferred()
Accesses the output deferred event object for the concentrator list. The deferred event object which is returned will have its callbacks triggered on completion of all the deferred events held in the list or its errbacks triggered if one of the deferred input events generates an errback. This should only be called once all the input deferred event objects have been added to the concentrator list.

Returns:
Returns the deferred event object which will have its callbacks executed on completion of all the deferred input events.

Reaction Home