T
- the type of the result of the Operation
PrimitiveOperation<T>
ArrayRowCountOperation<T>
, LocalOperation<T>
, MultiOperation<T>
, OperationGroup<S,T>
, OutOperation<T>
, ParameterizedOperation<T>
, ParameterizedRowCountOperation<T>
, ParameterizedRowOperation<T>
, ParameterizedRowPublisherOperation<T>
, RowCountOperation<T>
, RowOperation<T>
, RowPublisherOperation<T>
, Session
public interface Operation<T> extends PrimitiveOperation<T>
Operation
is created by an
OperationGroup
, configured and submitted. If not submitted it is not
executed. If submitted it is possibly executed according to the attributes of
the OperationGroup
that created it.
If execution of the work results in an error, the Operation is completed
exceptionally. The Throwable
that completes the Operation is
implementation dependent. It is recommended that an implementation use
SqlException in the event of database problems. Other Throwable
s such
as IOException
, NullPointerException
, etc can be used
as appropriate. An implementation should not wrap a useful exception in a
SqlException
unless that provides valuable additional information. An
implementation should use whatever Throwable
best facilitates
appropriate error handling.
An Operation is not required to be thread safe. In general a single user
thread will configure and submit an Operation. Once an Operation is submitted
it is immutable. OperationGroup
is an exception and is thread safe.
Modifier and Type | Method | Description |
---|---|---|
Operation<T> |
onError(java.util.function.Consumer<java.lang.Throwable> handler) |
Provides an error handler for this
Operation . |
Operation<T> |
timeout(java.time.Duration minTime) |
The minimum time before this
Operation might be canceled
automatically. |
submit
Operation<T> onError(java.util.function.Consumer<java.lang.Throwable> handler)
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.handler
- Operation
java.lang.IllegalStateException
- if this method is called more than once on
this operationOperation<T> timeout(java.time.Duration minTime)
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.minTime
- minimum time to wait before attempting to canceljava.lang.IllegalArgumentException
- if minTime <= Duration.ZERO
java.lang.IllegalStateException
- if this method is called more than once on
this operationReport a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2017, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.
DRAFT JDBC 4.4 EA5