Reaction Home

com.zynaptic.reaction
Interface Deferrable<T,U>

Type Parameters:
T - This type identifier specifies the type of data which may be passed to the deferrable object via the onCallback method.
U - This type identified specifies the type of data which will be returned by either the onCallback or onErrback method.

public interface Deferrable<T,U>

Defines the deferrable callback interface. Any object which implements this interface is referred to as a deferrable object, implying that it supports deferred callbacks.


Method Summary
 U onCallback(Deferred<T> deferred, T data)
          This is the callback handler for deferrable objects.
 U onErrback(Deferred<T> deferred, java.lang.Exception error)
          This is the error callback handler for deferrable objects.
 

Method Detail

onCallback

U onCallback(Deferred<T> deferred,
             T data)
             throws java.lang.Exception
This is the callback handler for deferrable objects. It is called in response to a deferred event which indicates successful completion of a given task.

Parameters:
deferred - This is the deferred event object through which the callback was issued.
data - This is a data object of type T which encapsulates any information being passed back as a result of the deferred event.
Returns:
Returns a data object of type U which will be propagated to the next deferrable in the chain as the onCallback data parameter.
Throws:
java.lang.Exception - Exceptions thrown by callback handlers are propagated to the next deferrable in the chain as the onErrback error parameter.

onErrback

U onErrback(Deferred<T> deferred,
            java.lang.Exception error)
            throws java.lang.Exception
This is the error callback handler for deferrable objects. It is called in response to a deferred error which indicates the failure of a given task.

Parameters:
deferred - This is the deferred event object through which the error callback was issued.
error - This is the Exception object which has been caught on task failure. It contains information about the cause of the error. It can be either handled locally or re-thrown to pass it up the callback chain.
Returns:
Returns a data object of type U which will be propagated to the next deferrable in the chain as the onCallback data parameter.
Throws:
java.lang.Exception - Exceptions thrown by error callback handlers are propagated to the next deferrable in the chain as the onErrback error parameter.

Reaction Home