Example usage for java.util.concurrent Callable toString

List of usage examples for java.util.concurrent Callable toString

Introduction

In this page you can find the example usage for java.util.concurrent Callable toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.force66.circuit.Circuit.java

public T invoke(Callable<T> operation) {
    Validate.notNull(operation, "Null operation not allowed.");
    if (!circuitBreakerAlgorithm.isExecutionAllowed()) {
        throw new CircuitException("Operation not available.")
                .addContextValue("callable class", operation.getClass().getName())
                .addContextValue("callable", operation.toString());
    }/*from ww  w.j  a  v a  2s  .co m*/

    try {
        T output = operation.call();
        circuitBreakerAlgorithm.reportExecutionSuccess();
        return output;
    } catch (Exception e) {
        circuitBreakerAlgorithm.reportExecutionFailure(e);
        throw new CircuitException(e).addContextValue("callable class", operation.getClass().getName())
                .addContextValue("callable", operation.toString());
    }

}

From source file:org.force66.insanity.RetryManager.java

public T invoke(Callable<T> operation) {
    Validate.notNull(operation, "Null operation not allowed.");
    int nbrTries = 0;
    Exception lastFailure = null;
    retryAlgorithm.reset();/*from www. j  a v  a 2  s . c o m*/

    while (retryAlgorithm.isExecutionAllowed()) {
        nbrTries++;
        try {
            T output = operation.call();
            return output;
        } catch (Exception e) {
            lastFailure = e;
            retryAlgorithm.reportExecutionFailure(e);
        }
    }

    throw new RetryException("invocation not successful.", lastFailure)
            .addContextValue("callable class", operation.getClass().getName())
            .addContextValue("callable", operation.toString()).addContextValue("nbrTries", nbrTries);
}