-
- Type Parameters:
T
- the type of the result of thisOperation
- All Superinterfaces:
Operation<T>
,PrimitiveOperation<T>
public interface LocalOperation<T> extends Operation<T>
AnOperation
that executes a user defined action when executed. Does not perform any database action. The result of aLocalOperation
is the result of calling theCallable
. This type allows user code to execute arbitrary code at particular points in the sequence ofOperation
s executed by aSession
without having to execute a specific database action at the same time.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description LocalOperation<T>
onError(java.util.function.Consumer<java.lang.Throwable> handler)
Provides an error handler for thisOperation
.LocalOperation<T>
onExecution(java.util.concurrent.Callable<T> action)
Provides an action for thisOperation
.LocalOperation<T>
timeout(java.time.Duration minTime)
The minimum time before thisOperation
might be canceled automatically.-
Methods inherited from interface jdk.incubator.sql2.PrimitiveOperation
submit
-
-
-
-
Method Detail
-
onExecution
LocalOperation<T> onExecution(java.util.concurrent.Callable<T> action)
Provides an action for thisOperation
. The action is called when thisLocalOperation
is executed. The result of thisLocalOperation
is the result of executing the action. ISSUE: Should this use Supplier rather than Callable?- Parameters:
action
- called when thisOperation
is executed- Returns:
- this
LocalOperation
- Throws:
java.lang.IllegalStateException
- if this method has already been called or thisOperation
has been submitted.
-
onError
LocalOperation<T> onError(java.util.function.Consumer<java.lang.Throwable> handler)
Provides an error handler for thisOperation
. If execution of thisOperation
results in an error, before theOperation
is completed, the handler is called with theThrowable
as the argument. The type of theThrowable
is implementation dependent.
-
timeout
LocalOperation<T> timeout(java.time.Duration minTime)
The minimum time before thisOperation
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 beforeminTime
after the beginning of execution. Some time at leastminTime
after the beginning of execution, an attempt will be made to cancel theOperation
if it has not yet completed. Implementations are encouraged to attempt to cancel within a reasonable time, though what is reasonable is implementation dependent.
-
-