Interface BeforeAfterCallable<ValueT>

Type Parameters:
ValueT - the result type returned by call().

public interface BeforeAfterCallable<ValueT>

See the main description page on Yost.com.


Nested Class Summary
static interface BeforeAfterCallable.AllowCallToProceed
          The interface containing the proceed() method, which triggers BeforeAfterCaller to proceed with calling call().
 
Method Summary
 void after(ValueT futureResult, Throwable callThrowable)
          Clean up after call(), whether or not it was successful.
 void before(BeforeAfterCallable.AllowCallToProceed allowCallToProceed)
          Peform the setup required before call() can be called.
 ValueT call()
          Computes a result, or throws an exception if unable to do so.
 

Method Detail

before

void before(BeforeAfterCallable.AllowCallToProceed allowCallToProceed)
            throws Exception
Peform the setup required before call() can be called. before() must either directly call allowCallToProceed.proceed(), or it must call a method that blocks and triggers the calling of proceed() in another thread. In the latter case, the blocking method must block at least until proceed() has been called; typically the blocking method will block until after() does something to allow it to unblock. It is the call to proceed() that triggers BeforeAfterCaller to call call() followed by after() in the worker thread. The call to proceed should be the last thing done by before()

Parameters:
allowCallToProceed - the object whose proceed() method must be called.
Throws:
Exception

call

ValueT call()
            throws Exception
Computes a result, or throws an exception if unable to do so.

Returns:
computed result
Throws:
Exception - if unable to compute a result

after

void after(ValueT futureResult,
           Throwable callThrowable)
           throws Exception
Clean up after call(), whether or not it was successful.

Parameters:
futureResult - the result of the call() method, if any
callThrowable - the Throwable thrown by call(), if any
Throws:
Exception