src/jdk.incubator.adba/share/classes/jdk/incubator/sql2/OperationGroup.java
branchJDK-8188051-branch
changeset 56824 62e92191354d
parent 56797 fb523d4d9185
child 56828 64304e37e9b1
equal deleted inserted replaced
56823:6ba0dbf6a75f 56824:62e92191354d
   117    * parallel, member {@link Operation}s may be executed in any order including
   117    * parallel, member {@link Operation}s may be executed in any order including
   118    * in parallel. If an {@link OperationGroup} is sequential, the default,
   118    * in parallel. If an {@link OperationGroup} is sequential, the default,
   119    * member {@link Operation}s are executed strictly in the order they are
   119    * member {@link Operation}s are executed strictly in the order they are
   120    * submitted.
   120    * submitted.
   121    *
   121    *
   122    * Note: There is no covariant override of this method in {@link Connection}
   122    * Note: There is no covariant override of this method in {@link Session}
   123    * as there is only a small likelihood of needing it.
   123    * as there is only a small likelihood of needing it.
   124    *
   124    *
   125    * @return this {@link OperationGroup}
   125    * @return this {@link OperationGroup}
   126    * @throws IllegalStateException if this {@link OperationGroup} has been
   126    * @throws IllegalStateException if this {@link OperationGroup} has been
   127    * submitted, any member {@link Operation}s have been created, or this method
   127    * submitted, any member {@link Operation}s have been created, or this method
   140    * {@link SqlSkippedException} with the cause set to the original exception.
   140    * {@link SqlSkippedException} with the cause set to the original exception.
   141    *
   141    *
   142    * The result of this {@link OperationGroup}'s execution is the result of collecting the
   142    * The result of this {@link OperationGroup}'s execution is the result of collecting the
   143    * results of the member {@link Operation}s that complete normally. 
   143    * results of the member {@link Operation}s that complete normally. 
   144    *
   144    *
   145    * Note: There is no covariant override of this method in {@link Connection}
   145    * Note: There is no covariant override of this method in {@link Session}
   146    * as there is only a small likelihood of needing it.
   146    * as there is only a small likelihood of needing it.
   147    *
   147    *
   148    * @return this {@link OperationGroup}
   148    * @return this {@link OperationGroup}
   149    * @throws IllegalStateException if this {@link OperationGroup} has been 
   149    * @throws IllegalStateException if this {@link OperationGroup} has been 
   150    * submitted, any member {@link Operation}s have been created, or this method
   150    * submitted, any member {@link Operation}s have been created, or this method
   160    * executed. If {@link Boolean#FALSE} or if it is completed exceptionally the
   160    * executed. If {@link Boolean#FALSE} or if it is completed exceptionally the
   161    * member {@link Operation}s are not executed but are removed from the queue.
   161    * member {@link Operation}s are not executed but are removed from the queue.
   162    * After all member {@link Operation}s have been removed from the queue this
   162    * After all member {@link Operation}s have been removed from the queue this
   163    * {@link OperationGroup} is completed with {@code null}.
   163    * {@link OperationGroup} is completed with {@code null}.
   164    *
   164    *
   165    * Note: There is no covariant override of this method in Connection as there
   165    * Note: There is no covariant override of this method in Session as there
   166    * is only a small likelihood of needing it.
   166    * is only a small likelihood of needing it.
   167    *
   167    *
   168    * ISSUE: Should the member Operations be skipped or otherwise completed
   168    * ISSUE: Should the member Operations be skipped or otherwise completed
   169    * exceptionally?
   169    * exceptionally?
   170    *
   170    *
   187    * 
   187    * 
   188    * If the {@link OperationGroup} is dependent and one of its member {@link Operation}s
   188    * If the {@link OperationGroup} is dependent and one of its member {@link Operation}s
   189    * completes exceptionally and its queue is empty the {@link OperationGroup}
   189    * completes exceptionally and its queue is empty the {@link OperationGroup}
   190    * is completed.
   190    * is completed.
   191    *
   191    *
   192    * Note: There is no covariant override of this method in Connection as there
   192    * Note: There is no covariant override of this method in Session as there
   193    * is only a small likelihood of needing it.
   193    * is only a small likelihood of needing it.
   194    *
   194    *
   195    * ISSUE: Need a better name.
   195    * ISSUE: Need a better name.
   196    *
   196    *
   197    * @return a Submission for this OperationGroup
   197    * @return a Submission for this OperationGroup
   206    * this method is called no additional member {@link Operation}s can be
   206    * this method is called no additional member {@link Operation}s can be
   207    * submitted. Once all member {@link Operation}s have been removed from the
   207    * submitted. Once all member {@link Operation}s have been removed from the
   208    * queue this {@link OperationGroup} will be completed and removed from the
   208    * queue this {@link OperationGroup} will be completed and removed from the
   209    * queue.
   209    * queue.
   210    *
   210    *
   211    * Note: There is no covariant override of this method in Connection as there
   211    * Note: There is no covariant override of this method in Session as there
   212    * is only a small likelihood of needing it.
   212    * is only a small likelihood of needing it.
   213    *
   213    *
   214    * ISSUE: Need a better name.
   214    * ISSUE: Need a better name.
   215    *
   215    *
   216    * @return the same Submission that was returned by {@link OperationGroup#submitHoldingForMoreMembers}
   216    * @return the same Submission that was returned by {@link OperationGroup#submitHoldingForMoreMembers}
   275    * Return a new {@link ArrayRowCountOperation}.
   275    * Return a new {@link ArrayRowCountOperation}.
   276    * <p>
   276    * <p>
   277    * Usage Note: Frequently use of this method will require a type witness to
   277    * Usage Note: Frequently use of this method will require a type witness to
   278    * enable correct type inferencing.
   278    * enable correct type inferencing.
   279    * <pre><code>
   279    * <pre><code>
   280    *   conn.<b>&lt;List&lt;Integer&gt;&gt;</b>arrayCountOperation(sql)
   280    *   session.<b>&lt;List&lt;Integer&gt;&gt;</b>arrayCountOperation(sql)
   281    *     .set ...
   281    *     .set ...
   282    *     .collect ...
   282    *     .collect ...
   283    *     .submit ...
   283    *     .submit ...
   284    * </code></pre>
   284    * </code></pre>
   285    *
   285    *
   389    * convenience methods do so.</p>
   389    * convenience methods do so.</p>
   390    *
   390    *
   391    * The type argument {@link S} of the containing {@link OperationGroup} must
   391    * The type argument {@link S} of the containing {@link OperationGroup} must
   392    * be a supertype of {@link TransactionOutcome}.
   392    * be a supertype of {@link TransactionOutcome}.
   393    *
   393    *
   394    * @param trans the Transaction that determines whether the Operation does a
   394    * @param trans the TransactionEnd that determines whether the Operation does a 
   395    * database commit or a database rollback.
   395    * database commit or a database rollback.
   396    * @return an {@link Operation} that will end the database transaction.
   396    * @return an {@link Operation} that will end the database transaction.
   397    * @throws IllegalStateException if this {@link OperationGroup} has been
   397    * @throws IllegalStateException if this {@link OperationGroup} has been
   398    * submitted and is not held or is parallel.
   398    * submitted and is not held or is parallel.
   399    */
   399    */
   400   public Operation<TransactionOutcome> endTransactionOperation(Transaction trans);
   400   public Operation<TransactionOutcome> endTransactionOperation(TransactionEnd trans);
   401 
   401 
   402   /**
   402   /**
   403    * Convenience method that creates and submits a endTransaction
   403    * Convenience method that creates and submits a endTransaction
   404    * {@link Operation} that commits by default but can be set to rollback by
   404    * {@link Operation} that commits by default but can be set to rollback by
   405    * calling {@link Transaction#setRollbackOnly}. The endTransaction Operation
   405    * calling {@link TransactionEnd#setRollbackOnly}. The endTransaction Operation
   406    * is never skipped.
   406    * is never skipped.
   407    *
   407    *
   408    * @param trans the Transaction that determines whether the {@link Operation} is a
   408    * @param trans the TransactionEnd that determines whether the {@link Operation} is a
   409    * database commit or a database rollback.
   409    * database commit or a database rollback.
   410    * @return this {@link OperationGroup}
   410    * @return a {@link CompletionStage} that is completed with the outcome of the 
       
   411    * transaction
   411    * @throws IllegalStateException if this {@link OperationGroup} has been
   412    * @throws IllegalStateException if this {@link OperationGroup} has been
   412    * submitted and is not held or is parallel.
   413    * submitted and is not held or is parallel.
   413    */
   414    */
   414   public default CompletionStage<TransactionOutcome> commitMaybeRollback(Transaction trans) {
   415   public default CompletionStage<TransactionOutcome> commitMaybeRollback(TransactionEnd trans) {
   415     catchErrors();
   416     catchErrors();
   416     return this.endTransactionOperation(trans).submit().getCompletionStage();
   417     return this.endTransactionOperation(trans).submit().getCompletionStage();
   417   }
   418   }
   418 
   419 
   419   /**
   420   /**
   464   @Override
   465   @Override
   465   public OperationGroup<S, T> timeout(Duration minTime);
   466   public OperationGroup<S, T> timeout(Duration minTime);
   466 
   467 
   467   @Override
   468   @Override
   468   public OperationGroup<S, T> onError(Consumer<Throwable> handler);
   469   public OperationGroup<S, T> onError(Consumer<Throwable> handler);
       
   470   
   469 }
   471 }