org.multiverse.api
Interface OrElseBlock

All Superinterfaces:
MultiverseConstants
All Known Implementing Classes:
GammaOrElseBlock

public interface OrElseBlock
extends MultiverseConstants

The OrElse is responsible for executing the either block, or in case of a retry, the orelse block is executed.

Another useful features of this design is that for certain primitives it doesn't require any form of boxing. It also provides an atomicChecked for a TxnVoidCallable which doesn't force a developer to return something when nothing needs to be returned.

Author:
Peter Veentjer.

Field Summary
 
Fields inherited from interface org.multiverse.MultiverseConstants
LOCKMODE_EXCLUSIVE, LOCKMODE_NONE, LOCKMODE_READ, LOCKMODE_WRITE, SHAKE_BUGS, SPIN_YIELD, TRACING_ENABLED
 
Method Summary
 boolean execute(TxnBooleanCallable either, TxnBooleanCallable orelse)
          Executes the either, or when it is retried, the orelse block.
<E> E
execute(TxnCallable<E> either, TxnCallable<E> orelse)
          Executes the either, or when it is retried, the orelse block.
 double execute(TxnDoubleCallable either, TxnDoubleCallable orelse)
          Executes the either, or when it is retried, the orelse block.
 int execute(TxnIntCallable either, TxnIntCallable orelse)
          Executes the either, or when it is retried, the orelse block.
 long execute(TxnLongCallable either, TxnLongCallable orelse)
          Executes the either, or when it is retried, the orelse block.
 void execute(TxnVoidCallable either, TxnVoidCallable orelse)
          Executes the either, or when it is retried, the orelse block.
 boolean executeChecked(TxnBooleanCallable either, TxnBooleanCallable orelse)
          Executes the either, or when it is retried, the orelse block.
<E> E
executeChecked(TxnCallable<E> either, TxnCallable<E> orelse)
          Executes the either, or when it is retried, the orelse block.
 double executeChecked(TxnDoubleCallable either, TxnDoubleCallable orelse)
          Executes the either, or when it is retried, the orelse block.
 int executeChecked(TxnIntCallable either, TxnIntCallable orelse)
          Executes the either, or when it is retried, the orelse block.
 long executeChecked(TxnLongCallable either, TxnLongCallable orelse)
          Executes the either, or when it is retried, the orelse block.
 void executeChecked(TxnVoidCallable either, TxnVoidCallable orelse)
          Executes the either, or when it is retried, the orelse block.
 

Method Detail

execute

<E> E execute(TxnCallable<E> either,
              TxnCallable<E> orelse)
Executes the either, or when it is retried, the orelse block. This operation makes composable blocking operations possible.

If in the execution of the closure a checked exception is thrown, the exception is wrapped in a InvisibleCheckedException. The original exception can be retrieved by calling the getCause method.

Parameters:
either -
orelse -
Returns:
the result of the execution.
Throws:
NullPointerException - if either or orelse is null.
TxnMandatoryException - if no transaction is found on the TxnThreadLocal.
InvisibleCheckedException - if a checked exception is thrown by the closure.

executeChecked

<E> E executeChecked(TxnCallable<E> either,
                     TxnCallable<E> orelse)
                 throws Exception
Executes the either, or when it is retried, the orelse block. This operation makes composable blocking operations possible.

Parameters:
either -
orelse -
Returns:
the result of the execution.
Throws:
NullPointerException - if either or orelse is null.
TxnMandatoryException - if no transaction is found on the TxnThreadLocal.
Exception - if the atomicChecked call fails.

execute

int execute(TxnIntCallable either,
            TxnIntCallable orelse)
Executes the either, or when it is retried, the orelse block. This operation makes composable blocking operations possible.

If in the execution of the closure a checked exception is thrown, the exception is wrapped in a InvisibleCheckedException. The original exception can be retrieved by calling the getCause method.

Parameters:
either -
orelse -
Returns:
the result of the execution.
Throws:
NullPointerException - if either or orelse is null.
TxnMandatoryException - if no transaction is found on the TxnThreadLocal.
InvisibleCheckedException - if a checked exception is thrown by the closure.

executeChecked

int executeChecked(TxnIntCallable either,
                   TxnIntCallable orelse)
                   throws Exception
Executes the either, or when it is retried, the orelse block. This operation makes composable blocking operations possible.

Parameters:
either -
orelse -
Returns:
the result of the execution.
Throws:
NullPointerException - if either or orelse is null.
TxnMandatoryException - if no transaction is found on the TxnThreadLocal.
Exception - if the atomicChecked call fails.

execute

long execute(TxnLongCallable either,
             TxnLongCallable orelse)
Executes the either, or when it is retried, the orelse block. This operation makes composable blocking operations possible.

If in the execution of the closure a checked exception is thrown, the exception is wrapped in a InvisibleCheckedException. The original exception can be retrieved by calling the getCause method.

Parameters:
either -
orelse -
Returns:
the result of the execution.
Throws:
NullPointerException - if either or orelse is null.
TxnMandatoryException - if no transaction is found on the TxnThreadLocal.
InvisibleCheckedException - if a checked exception is thrown by the closure.

executeChecked

long executeChecked(TxnLongCallable either,
                    TxnLongCallable orelse)
                    throws Exception
Executes the either, or when it is retried, the orelse block. This operation makes composable blocking operations possible.

Parameters:
either -
orelse -
Returns:
the result of the execution.
Throws:
NullPointerException - if either or orelse is null.
TxnMandatoryException - if no transaction is found on the TxnThreadLocal.
Exception - if the atomicChecked call fails.

execute

double execute(TxnDoubleCallable either,
               TxnDoubleCallable orelse)
Executes the either, or when it is retried, the orelse block. This operation makes composable blocking operations possible.

If in the execution of the closure a checked exception is thrown, the exception is wrapped in a InvisibleCheckedException. The original exception can be retrieved by calling the getCause method.

Parameters:
either -
orelse -
Returns:
the result of the execution.
Throws:
NullPointerException - if either or orelse is null.
TxnMandatoryException - if no transaction is found on the TxnThreadLocal.
InvisibleCheckedException - if a checked exception is thrown by the closure.

executeChecked

double executeChecked(TxnDoubleCallable either,
                      TxnDoubleCallable orelse)
                      throws Exception
Executes the either, or when it is retried, the orelse block. This operation makes composable blocking operations possible.

Parameters:
either -
orelse -
Returns:
the result of the execution.
Throws:
NullPointerException - if either or orelse is null.
TxnMandatoryException - if no transaction is found on the TxnThreadLocal.
Exception - if the atomicChecked call fails.

execute

boolean execute(TxnBooleanCallable either,
                TxnBooleanCallable orelse)
Executes the either, or when it is retried, the orelse block. This operation makes composable blocking operations possible.

If in the execution of the closure a checked exception is thrown, the exception is wrapped in a InvisibleCheckedException. The original exception can be retrieved by calling the getCause method.

Parameters:
either -
orelse -
Returns:
the result of the execution.
Throws:
NullPointerException - if either or orelse is null.
TxnMandatoryException - if no transaction is found on the TxnThreadLocal.
InvisibleCheckedException - if a checked exception is thrown by the closure.

executeChecked

boolean executeChecked(TxnBooleanCallable either,
                       TxnBooleanCallable orelse)
                       throws Exception
Executes the either, or when it is retried, the orelse block. This operation makes composable blocking operations possible.

Parameters:
either -
orelse -
Returns:
the result of the execution.
Throws:
NullPointerException - if either or orelse is null.
TxnMandatoryException - if no transaction is found on the TxnThreadLocal.
Exception - if the atomicChecked call fails.

execute

void execute(TxnVoidCallable either,
             TxnVoidCallable orelse)
Executes the either, or when it is retried, the orelse block. This operation makes composable blocking operations possible.

If in the execution of the closure a checked exception is thrown, the exception is wrapped in a InvisibleCheckedException. The original exception can be retrieved by calling the getCause method.

Parameters:
either -
orelse -
Throws:
NullPointerException - if either or orelse is null.
TxnMandatoryException - if no transaction is found on the TxnThreadLocal.
InvisibleCheckedException - if a checked exception is thrown by the closure.

executeChecked

void executeChecked(TxnVoidCallable either,
                    TxnVoidCallable orelse)
                    throws Exception
Executes the either, or when it is retried, the orelse block. This operation makes composable blocking operations possible.

Parameters:
either -
orelse -
Throws:
NullPointerException - if either or orelse is null.
TxnMandatoryException - if no transaction is found on the TxnThreadLocal.
Exception - if the atomicChecked call fails.


Copyright © 2012. All Rights Reserved.