Interface LocalOperation<T>

  • Type Parameters:
    T - the type of the result of this Operation
    All Superinterfaces:
    Operation<T>, PrimitiveOperation<T>

    public interface LocalOperation<T>
    extends Operation<T>
    An Operation that executes a user defined action when executed. Does not perform any database action. The result of a LocalOperation is the result of calling the Callable. This type allows user code to execute arbitrary code at particular points in the sequence of Operations executed by a Session without having to execute a specific database action at the same time.
    • Method Detail

      • onExecution

        LocalOperation<T> onExecution​(java.util.concurrent.Callable<T> action)
        Provides an action for this Operation. The action is called when this LocalOperation is executed. The result of this LocalOperation is the result of executing the action. ISSUE: Should this use Supplier rather than Callable?
        Parameters:
        action - called when this Operation is executed
        Returns:
        this LocalOperation
        Throws:
        java.lang.IllegalStateException - if this method has already been called or this Operation has been submitted.
      • onError

        LocalOperation<T> onError​(java.util.function.Consumer<java.lang.Throwable> handler)
        Provides an error handler for this Operation. If execution of this Operation results in an error, before the Operation is completed, the handler is called with the Throwable as the argument. The type of the Throwable is implementation dependent.
        Specified by:
        onError in interface Operation<T>
        Returns:
        this LocalOperation
      • timeout

        LocalOperation<T> timeout​(java.time.Duration minTime)
        The minimum time before this Operation might be canceled automatically. The default value is forever. The time is counted from the beginning of Operation execution. The Operation will not be canceled before minTime after the beginning of execution. Some time at least minTime after the beginning of execution, an attempt will be made to cancel the Operation if it has not yet completed. Implementations are encouraged to attempt to cancel within a reasonable time, though what is reasonable is implementation dependent.
        Specified by:
        timeout in interface Operation<T>
        Parameters:
        minTime - minimum time to wait before attempting to cancel
        Returns:
        this LocalOperation