| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| <!-- NewPage --> |
| <html lang="en"> |
| <head> |
| <title>ManagedExecutorService</title> |
| <link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style"> |
| <script type="text/javascript" src="../../../script.js"></script> |
| |
| <link rel="shortcut icon" href="/img/jakarta-favicon.ico"> |
| </head> |
| <body> |
| <script type="text/javascript"><!-- |
| try { |
| if (location.href.indexOf('is-external=true') == -1) { |
| parent.document.title="ManagedExecutorService"; |
| } |
| } |
| catch(err) { |
| } |
| //--> |
| var methods = {"i0":6,"i1":6,"i2":6,"i3":6,"i4":6,"i5":6,"i6":6,"i7":6,"i8":6,"i9":6}; |
| var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],4:["t3","Abstract Methods"]}; |
| var altColor = "altColor"; |
| var rowColor = "rowColor"; |
| var tableTab = "tableTab"; |
| var activeTableTab = "activeTableTab"; |
| </script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="topNav"><a name="navbar.top"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.top.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../index-all.html">Index</a></li> |
| <li><a href="../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../jakarta/enterprise/concurrent/ManagedExecutors.html" title="class in jakarta.enterprise.concurrent"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../jakarta/enterprise/concurrent/ManagedScheduledExecutorDefinition.html" title="annotation in jakarta.enterprise.concurrent"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../index.html?jakarta/enterprise/concurrent/ManagedExecutorService.html" target="_top">Frames</a></li> |
| <li><a href="ManagedExecutorService.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_top"> |
| <li><a href="../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_top"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.top"> |
| <!-- --> |
| </a></div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="subTitle">jakarta.enterprise.concurrent</div> |
| <h2 title="Interface ManagedExecutorService" class="title">Interface ManagedExecutorService</h2> |
| </div> |
| <div class="contentContainer"> |
| <div class="description"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <dl> |
| <dt>All Superinterfaces:</dt> |
| <dd>java.util.concurrent.Executor, java.util.concurrent.ExecutorService</dd> |
| </dl> |
| <dl> |
| <dt>All Known Subinterfaces:</dt> |
| <dd><a href="../../../jakarta/enterprise/concurrent/ManagedScheduledExecutorService.html" title="interface in jakarta.enterprise.concurrent">ManagedScheduledExecutorService</a></dd> |
| </dl> |
| <hr> |
| <br> |
| <pre>public interface <span class="typeNameLabel">ManagedExecutorService</span> |
| extends java.util.concurrent.ExecutorService</pre> |
| <div class="block">A manageable version of a <code>ExecutorService</code>. |
| <p> |
| A ManagedExecutorService extends the Java™ SE ExecutorService to provide |
| methods for submitting tasks for execution in a Jakarta™ EE environment. |
| Implementations of the ManagedExecutorService are |
| provided by a Jakarta EE Product Provider. Application Component Providers |
| use the Java Naming and Directory Interface™ (JNDI) to look-up instances of one |
| or more ManagedExecutorService objects using resource environment references. |
| ManagedExecutorService instances can also be injected into application |
| components through the use of the <code>Resource</code> annotation. |
| <p> |
| The Jakarta Concurrency specification describes several |
| behaviors that a ManagedExecutorService can implement. The Application |
| Component Provider and Deployer identify these requirements and map the |
| resource environment reference appropriately. |
| <p> |
| The most common uses for a ManagedExecutorService is to run short-duration asynchronous |
| tasks such as for processing of asynchronous methods in Jakarta |
| Enterprise Beans or for processing async tasks for Servlets that |
| supports asynchronous processing. |
| <p> |
| Tasks are run in managed threads provided by the Jakarta EE Product Provider |
| and are run within the application component context that submitted the task. |
| All tasks run without an explicit transaction (they do not enlist in the application |
| component's transaction). If a transaction is required, use a |
| <code>jakarta.transaction.UserTransaction</code> instance. A UserTransaction instance is |
| available in JNDI using the name: "java:comp/UserTransaction" or by |
| requesting an injection of a <code>jakarta.transaction.UserTransaction</code> object |
| using the <code>Resource</code> annotation. |
| <p> |
| Example: |
| <pre> |
| public run() { |
| // Begin of task |
| InitialContext ctx = new InitialContext(); |
| UserTransaction ut = (UserTransaction) ctx.lookup("java:comp/UserTransaction"); |
| ut.begin(); |
| |
| // Perform transactional business logic |
| |
| ut.commit(); |
| } |
| </pre> |
| |
| Tasks can optionally provide an <a href="../../../jakarta/enterprise/concurrent/ManagedTaskListener.html" title="interface in jakarta.enterprise.concurrent"><code>ManagedTaskListener</code></a> to receive |
| notifications of lifecycle events, through the use of <a href="../../../jakarta/enterprise/concurrent/ManagedTask.html" title="interface in jakarta.enterprise.concurrent"><code>ManagedTask</code></a> |
| interface. |
| <p> |
| Example: |
| <pre> |
| public class MyRunnable implements Runnable, ManagedTask { |
| ... |
| public void run() { |
| ... |
| } |
| |
| public ManagedTaskListener getManagedTaskListener() { |
| return myManagedTaskListener; |
| } |
| ... |
| } |
| |
| MyRunnable task = ...; |
| ManagedExecutorService executor = ...; |
| |
| executor.submit(task); // lifecycle events will be notified to myManagedTaskListener |
| </pre> |
| |
| Asynchronous tasks are typically submitted to the ManagedExecutorService using one |
| of the <code>submit</code> methods, each of which return a <code>Future</code> |
| instance. The <code>Future</code> represents the result of the task and can also be used to |
| check if the task is complete or wait for its completion. |
| <p> |
| |
| If the task is canceled, the result for the task is a |
| <code>CancellationException</code> exception. If the task is unable |
| to run due to a reason other than cancellation, the result is a |
| <a href="../../../jakarta/enterprise/concurrent/AbortedException.html" title="class in jakarta.enterprise.concurrent"><code>AbortedException</code></a> exception. |
| <p> |
| |
| Example: |
| <pre> |
| /** |
| * Retrieve all accounts from several account databases in parallel. |
| * Resource Mappings: |
| * type: jakarta.enterprise.concurrent.ManagedExecutorService |
| * jndi-name: concurrent/ThreadPool |
| */ |
| public List<Account> getAccounts(long accountId) { |
| try { |
| javax.naming.InitialContext ctx = new InitialContext(); |
| <b>ManagedExecutorService mes = (ManagedExecutorService) |
| ctx.lookup("java:comp/env/concurrent/ThreadPool");</b> |
| |
| // Create a set of tasks to perform the account retrieval. |
| ArrayList<Callable<Account>> retrieverTasks = new ArrayList<Callable<Account>>(); |
| retrieverTasks.add(new EISAccountRetriever()); |
| retrieverTasks.add(new RDBAccountRetriever()); |
| |
| // Submit the tasks to the thread pool and wait for them |
| // to complete (successfully or otherwise). |
| <b>List<Future<Account>> taskResults= mes.invokeAll(retrieverTasks);</b> |
| |
| // Retrieve the results from the resulting Future list. |
| ArrayList<Account> results = new ArrayList<Account>(); |
| for(Future<Account> taskResult : taskResults) { |
| try { |
| <b>results.add(taskResult.get());</b> |
| } catch (ExecutionException e) { |
| Throwable cause = e.getCause(); |
| // Handle the AccountRetrieverError. |
| } |
| } |
| |
| return results; |
| |
| } catch (NamingException e) { |
| // Throw exception for fatal error. |
| } catch (InterruptedException e) { |
| // Throw exception for shutdown or other interrupt condition. |
| } |
| } |
| |
| |
| public class EISAccountRetriever implements Callable<Account> { |
| public Account call() { |
| // Connect to our eis system and retrieve the info for the account. |
| //... |
| return null; |
| } |
| } |
| |
| public class RDBAccountRetriever implements Callable<Account> { |
| public Account call() { |
| // Connect to our database and retrieve the info for the account. |
| //... |
| } |
| } |
| |
| public class Account { |
| // Some account data... |
| } |
| </pre> |
| |
| <p>ManagedExecutorService provides various methods which correspond to the |
| static methods of <code>CompletableFuture</code> and its |
| constructor/<code>newIncompleteFuture</code> method, |
| enabling you to create completion stages that are backed by the <code>ManagedExecutorService</code> |
| as the default asynchronous execution facility, both for those stages |
| as well as all dependent stages that are created from those, and so on. |
| This allows you to create pipelines of completion stage actions that run |
| with consistent and predictable thread context, regardless of which thread each |
| dependent action ends up running on.</p> |
| |
| <p>Example:</p> |
| <pre> |
| <code>ManagedExectorService executor = InitialContext.doLookup("java:comp/DefaultManagedExecutorService"); |
| ... |
| CompletableFuture<Integer> future = executor |
| .supplyAsync(supplier) |
| .thenApply(function1) |
| .thenApplyAsync(function2) |
| ... |
| </code> |
| </pre> |
| |
| <p>Context propagation to completion stages that are backed by a |
| <code>ManagedExecutorService</code> must be done in a consistent |
| and predictable manner, which is defined as follows,</p> |
| |
| <ul> |
| <li> |
| If the supplied action is already contextual, (for example, |
| <code>contextService.createContextualProxy(action, Runnable.class)</code>), |
| then the action runs with the already-captured context. |
| </li> |
| <li> |
| Otherwise, each type of thread context is either propagated from the thread |
| that creates the completion stage or the context is marked to be cleared, according to the |
| configuration of the <code>ManagedExecutorService</code> that is the default asynchronous execution facility |
| for the new stage and its parent stage. In the case that a <code>ManagedExecutorService</code> is supplied |
| as the <code>executor</code> argument to a <code>*Async</code> method, the supplied |
| <code>ManagedExecutorService</code> is used to run the action, but not to determine the thread context |
| propagation and clearing. |
| </li> |
| </ul> |
| |
| <p>Each type of thread context is applied (either as cleared or previously captured) |
| to the thread that runs the action. The applied thread context is removed after the action |
| completes, whether successfully or exceptionally, restoring the thread's prior context.</p> |
| |
| <p>When dependent stages are created from the completion stage, and likewise from any dependent stages |
| created from those, and so on, thread context is captured or cleared in the same manner. |
| This guarantees that the action performed by each stage always runs under the thread context |
| of the code that creates the completion stage, unless the user explicitly overrides this by supplying a |
| pre-contextualized action.</p> |
| |
| <p>Completion stages that are backed by a <code>ManagedExecutorService</code> must raise |
| <code>IllegalArgumentException</code> if supplied with an action that implements |
| <a href="../../../jakarta/enterprise/concurrent/ManagedTask.html" title="interface in jakarta.enterprise.concurrent"><code>ManagedTask</code></a>.</p></div> |
| <dl> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>1.0</dd> |
| <dt><span class="simpleTagLabel">Examples (en):</span></dt> |
| <dd><a href="../../../../../../tomee-9.0/examples/concurrency-utils.html">concurrency-utils</a></dd> |
| <dt><span class="simpleTagLabel">Examples (pt):</span></dt> |
| <dd><a href="../../../../../../tomee-9.0/pt/examples/concurrency-utils.html">concurrency-utils</a></dd> |
| </dl> |
| </li> |
| </ul> |
| </div> |
| <div class="summary"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.summary"> |
| <!-- --> |
| </a> |
| <h3>Method Summary</h3> |
| <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation"> |
| <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd"> </span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd"> </span></span><span id="t3" class="tableTab"><span><a href="javascript:show(4);">Abstract Methods</a></span><span class="tabEnd"> </span></span></caption> |
| <tr> |
| <th class="colFirst" scope="col">Modifier and Type</th> |
| <th class="colLast" scope="col">Method and Description</th> |
| </tr> |
| <tr id="i0" class="altColor"> |
| <td class="colFirst"><code><U> java.util.concurrent.CompletableFuture<U></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ManagedExecutorService.html#completedFuture-U-">completedFuture</a></span>(U value)</code> |
| <div class="block">Returns a new <code>CompletableFuture</code> |
| that is already completed with the specified value.</div> |
| </td> |
| </tr> |
| <tr id="i1" class="rowColor"> |
| <td class="colFirst"><code><U> java.util.concurrent.CompletionStage<U></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ManagedExecutorService.html#completedStage-U-">completedStage</a></span>(U value)</code> |
| <div class="block">Returns a new <code>CompletionStage</code> |
| that is already completed with the specified value.</div> |
| </td> |
| </tr> |
| <tr id="i2" class="altColor"> |
| <td class="colFirst"><code><T> java.util.concurrent.CompletableFuture<T></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ManagedExecutorService.html#copy-java.util.concurrent.CompletableFuture-">copy</a></span>(java.util.concurrent.CompletableFuture<T> stage)</code> |
| <div class="block"> |
| Returns a new <code>CompletableFuture</code> |
| that is completed by the completion of the |
| specified stage.</div> |
| </td> |
| </tr> |
| <tr id="i3" class="rowColor"> |
| <td class="colFirst"><code><T> java.util.concurrent.CompletionStage<T></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ManagedExecutorService.html#copy-java.util.concurrent.CompletionStage-">copy</a></span>(java.util.concurrent.CompletionStage<T> stage)</code> |
| <div class="block"> |
| Returns a new <code>CompletionStage</code> |
| that is completed by the completion of the |
| specified stage.</div> |
| </td> |
| </tr> |
| <tr id="i4" class="altColor"> |
| <td class="colFirst"><code><U> java.util.concurrent.CompletableFuture<U></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ManagedExecutorService.html#failedFuture-java.lang.Throwable-">failedFuture</a></span>(java.lang.Throwable ex)</code> |
| <div class="block">Returns a new <code>CompletableFuture</code> |
| that is already exceptionally completed with the specified <code>Throwable</code>.</div> |
| </td> |
| </tr> |
| <tr id="i5" class="rowColor"> |
| <td class="colFirst"><code><U> java.util.concurrent.CompletionStage<U></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ManagedExecutorService.html#failedStage-java.lang.Throwable-">failedStage</a></span>(java.lang.Throwable ex)</code> |
| <div class="block">Returns a new <code>CompletionStage</code> |
| that is already exceptionally completed with the specified <code>Throwable</code>.</div> |
| </td> |
| </tr> |
| <tr id="i6" class="altColor"> |
| <td class="colFirst"><code><a href="../../../jakarta/enterprise/concurrent/ContextService.html" title="interface in jakarta.enterprise.concurrent">ContextService</a></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ManagedExecutorService.html#getContextService--">getContextService</a></span>()</code> |
| <div class="block">Returns a <a href="../../../jakarta/enterprise/concurrent/ContextService.html" title="interface in jakarta.enterprise.concurrent"><code>ContextService</code></a> which has the same propagation settings as this <code>ManagedExecutorService</code> |
| and uses this <code>ManagedExecutorService</code> as the default asynchronous execution facility for |
| <code>CompletionStage</code> and <code>CompletableFuture</code> instances |
| that it creates via the <code>withContextCapture</code> methods.</div> |
| </td> |
| </tr> |
| <tr id="i7" class="rowColor"> |
| <td class="colFirst"><code><U> java.util.concurrent.CompletableFuture<U></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ManagedExecutorService.html#newIncompleteFuture--">newIncompleteFuture</a></span>()</code> |
| <div class="block">Returns a new incomplete <code>CompletableFuture</code>.</div> |
| </td> |
| </tr> |
| <tr id="i8" class="altColor"> |
| <td class="colFirst"><code>java.util.concurrent.CompletableFuture<java.lang.Void></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ManagedExecutorService.html#runAsync-java.lang.Runnable-">runAsync</a></span>(java.lang.Runnable runnable)</code> |
| <div class="block">Returns a new <code>CompletableFuture</code> |
| that is completed by a task running in this executor |
| after it runs the given action.</div> |
| </td> |
| </tr> |
| <tr id="i9" class="rowColor"> |
| <td class="colFirst"><code><U> java.util.concurrent.CompletableFuture<U></code></td> |
| <td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/ManagedExecutorService.html#supplyAsync-java.util.function.Supplier-">supplyAsync</a></span>(java.util.function.Supplier<U> supplier)</code> |
| <div class="block">Returns a new <code>CompletableFuture</code> |
| that is completed by a task running in this executor |
| after it runs the given action.</div> |
| </td> |
| </tr> |
| </table> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.java.util.concurrent.ExecutorService"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from interface java.util.concurrent.ExecutorService</h3> |
| <code>awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit</code></li> |
| </ul> |
| <ul class="blockList"> |
| <li class="blockList"><a name="methods.inherited.from.class.java.util.concurrent.Executor"> |
| <!-- --> |
| </a> |
| <h3>Methods inherited from interface java.util.concurrent.Executor</h3> |
| <code>execute</code></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| <div class="details"> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <!-- ============ METHOD DETAIL ========== --> |
| <ul class="blockList"> |
| <li class="blockList"><a name="method.detail"> |
| <!-- --> |
| </a> |
| <h3>Method Detail</h3> |
| <a name="completedFuture-java.lang.Object-"> |
| <!-- --> |
| </a><a name="completedFuture-U-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>completedFuture</h4> |
| <pre><U> java.util.concurrent.CompletableFuture<U> completedFuture(U value)</pre> |
| <div class="block"><p>Returns a new <code>CompletableFuture</code> |
| that is already completed with the specified value.</p> |
| |
| <p>This executor is the default asynchronous execution facility for the new completion stage |
| that is returned by this method and all dependent stages that are created from it, |
| and all dependent stages that are created from those, as so forth.</p></div> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>U</code> - result type of the completable future.</dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>value</code> - result with which the completable future is completed.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the new completable future.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>3.0</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="completedStage-java.lang.Object-"> |
| <!-- --> |
| </a><a name="completedStage-U-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>completedStage</h4> |
| <pre><U> java.util.concurrent.CompletionStage<U> completedStage(U value)</pre> |
| <div class="block"><p>Returns a new <code>CompletionStage</code> |
| that is already completed with the specified value.</p> |
| |
| <p>This executor is the default asynchronous execution facility for the new completion stage |
| that is returned by this method and all dependent stages that are created from it, |
| and all dependent stages that are created from those, as so forth.</p></div> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>U</code> - result type of the completion stage.</dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>value</code> - result with which the completion stage is completed.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the new completion stage.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>3.0</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="copy-java.util.concurrent.CompletableFuture-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>copy</h4> |
| <pre><T> java.util.concurrent.CompletableFuture<T> copy(java.util.concurrent.CompletableFuture<T> stage)</pre> |
| <div class="block"><p> |
| Returns a new <code>CompletableFuture</code> |
| that is completed by the completion of the |
| specified stage. |
| </p> |
| |
| <p> |
| The new completable future is backed by the <code>ManagedExecutorService</code> upon which copy is invoked, |
| which serves as the default asynchronous execution facility |
| for the new stage and all dependent stages created from it, and so forth. |
| </p> |
| |
| <p> |
| When dependent stages are created from the new completable future, thread context is captured |
| and/or cleared by the <code>ManagedExecutorService</code>. This guarantees that the action |
| performed by each stage always runs under the thread context of the code that creates the stage, |
| unless the user explicitly overrides by supplying a pre-contextualized action. |
| </p> |
| |
| <p> |
| Invocation of this method does not impact thread context propagation for the supplied |
| completable future or any other dependent stages directly created from it. |
| </p></div> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>T</code> - completable future result type.</dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>stage</code> - a completable future whose completion triggers completion of the new completable |
| future that is created by this method.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the new completable future.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>3.0</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="copy-java.util.concurrent.CompletionStage-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>copy</h4> |
| <pre><T> java.util.concurrent.CompletionStage<T> copy(java.util.concurrent.CompletionStage<T> stage)</pre> |
| <div class="block"><p> |
| Returns a new <code>CompletionStage</code> |
| that is completed by the completion of the |
| specified stage. |
| </p> |
| |
| <p> |
| The new completion stage is backed by the <code>ManagedExecutorService</code> upon which copy is invoked, |
| which serves as the default asynchronous execution facility |
| for the new stage and all dependent stages created from it, and so forth. |
| </p> |
| |
| <p> |
| When dependent stages are created from the new completion stage, thread context is captured |
| and/or cleared by the <code>ManagedExecutorService</code>. This guarantees that the action |
| performed by each stage always runs under the thread context of the code that creates the stage, |
| unless the user explicitly overrides by supplying a pre-contextualized action. |
| </p> |
| |
| <p> |
| Invocation of this method does not impact thread context propagation for the supplied |
| stage or any other dependent stages directly created from it. |
| </p></div> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>T</code> - completion stage result type.</dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>stage</code> - a completion stage whose completion triggers completion of the new stage |
| that is created by this method.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the new completion stage.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>3.0</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="failedFuture-java.lang.Throwable-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>failedFuture</h4> |
| <pre><U> java.util.concurrent.CompletableFuture<U> failedFuture(java.lang.Throwable ex)</pre> |
| <div class="block"><p>Returns a new <code>CompletableFuture</code> |
| that is already exceptionally completed with the specified <code>Throwable</code>.</p> |
| |
| <p>This executor is the default asynchronous execution facility for the new completion stage |
| that is returned by this method and all dependent stages that are created from it, |
| and all dependent stages that are created from those, as so forth.</p></div> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>U</code> - result type of the completable future.</dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>ex</code> - exception or error with which the completable future is completed.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the new completable future.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>3.0</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="failedStage-java.lang.Throwable-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>failedStage</h4> |
| <pre><U> java.util.concurrent.CompletionStage<U> failedStage(java.lang.Throwable ex)</pre> |
| <div class="block"><p>Returns a new <code>CompletionStage</code> |
| that is already exceptionally completed with the specified <code>Throwable</code>.</p> |
| |
| <p>This executor is the default asynchronous execution facility for the new completion stage |
| that is returned by this method and all dependent stages that are created from it, |
| and all dependent stages that are created from those, as so forth.</p></div> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>U</code> - result type of the completion stage.</dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>ex</code> - exception or error with which the completion stage is completed.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the new completion stage.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>3.0</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="getContextService--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>getContextService</h4> |
| <pre><a href="../../../jakarta/enterprise/concurrent/ContextService.html" title="interface in jakarta.enterprise.concurrent">ContextService</a> getContextService()</pre> |
| <div class="block">Returns a <a href="../../../jakarta/enterprise/concurrent/ContextService.html" title="interface in jakarta.enterprise.concurrent"><code>ContextService</code></a> which has the same propagation settings as this <code>ManagedExecutorService</code> |
| and uses this <code>ManagedExecutorService</code> as the default asynchronous execution facility for |
| <code>CompletionStage</code> and <code>CompletableFuture</code> instances |
| that it creates via the <code>withContextCapture</code> methods.</div> |
| <dl> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>a <code>ContextService</code> with the same propagation settings |
| as this <code>ManagedExecutorService</code>.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>3.0</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="newIncompleteFuture--"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>newIncompleteFuture</h4> |
| <pre><U> java.util.concurrent.CompletableFuture<U> newIncompleteFuture()</pre> |
| <div class="block"><p>Returns a new incomplete <code>CompletableFuture</code>.</p> |
| |
| <p>This executor is the default asynchronous execution facility for the new completion stage |
| that is returned by this method and all dependent stages that are created from it, |
| and all dependent stages that are created from those, as so forth.</p></div> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>U</code> - result type of the completable future.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the new completable future.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>3.0</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="runAsync-java.lang.Runnable-"> |
| <!-- --> |
| </a> |
| <ul class="blockList"> |
| <li class="blockList"> |
| <h4>runAsync</h4> |
| <pre>java.util.concurrent.CompletableFuture<java.lang.Void> runAsync(java.lang.Runnable runnable)</pre> |
| <div class="block"><p>Returns a new <code>CompletableFuture</code> |
| that is completed by a task running in this executor |
| after it runs the given action.</p> |
| |
| <p>This executor is the default asynchronous execution facility for the new completion stage |
| that is returned by this method and all dependent stages that are created from it, |
| and all dependent stages that are created from those, as so forth.</p></div> |
| <dl> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>runnable</code> - the action to run before completing the returned completion stage.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the new completable future.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>3.0</dd> |
| </dl> |
| </li> |
| </ul> |
| <a name="supplyAsync-java.util.function.Supplier-"> |
| <!-- --> |
| </a> |
| <ul class="blockListLast"> |
| <li class="blockList"> |
| <h4>supplyAsync</h4> |
| <pre><U> java.util.concurrent.CompletableFuture<U> supplyAsync(java.util.function.Supplier<U> supplier)</pre> |
| <div class="block"><p>Returns a new <code>CompletableFuture</code> |
| that is completed by a task running in this executor |
| after it runs the given action.</p> |
| |
| <p>This executor is the default asynchronous execution facility for the new completion stage |
| that is returned by this method and all dependent stages that are created from it, |
| and all dependent stages that are created from those, as so forth.</p></div> |
| <dl> |
| <dt><span class="paramLabel">Type Parameters:</span></dt> |
| <dd><code>U</code> - result type of the supplier and returned completable stage.</dd> |
| <dt><span class="paramLabel">Parameters:</span></dt> |
| <dd><code>supplier</code> - an action returning the value to be used to complete the returned completion stage.</dd> |
| <dt><span class="returnLabel">Returns:</span></dt> |
| <dd>the new completable future.</dd> |
| <dt><span class="simpleTagLabel">Since:</span></dt> |
| <dd>3.0</dd> |
| </dl> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| <!-- ========= END OF CLASS DATA ========= --> |
| <!-- ======= START OF BOTTOM NAVBAR ====== --> |
| <div class="bottomNav"><a name="navbar.bottom"> |
| <!-- --> |
| </a> |
| <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div> |
| <a name="navbar.bottom.firstrow"> |
| <!-- --> |
| </a> |
| <ul class="navList" title="Navigation"> |
| <li><a href="../../../overview-summary.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="navBarCell1Rev">Class</li> |
| <li><a href="package-tree.html">Tree</a></li> |
| <li><a href="../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../index-all.html">Index</a></li> |
| <li><a href="../../../help-doc.html">Help</a></li> |
| </ul> |
| </div> |
| <div class="subNav"> |
| <ul class="navList"> |
| <li><a href="../../../jakarta/enterprise/concurrent/ManagedExecutors.html" title="class in jakarta.enterprise.concurrent"><span class="typeNameLink">Prev Class</span></a></li> |
| <li><a href="../../../jakarta/enterprise/concurrent/ManagedScheduledExecutorDefinition.html" title="annotation in jakarta.enterprise.concurrent"><span class="typeNameLink">Next Class</span></a></li> |
| </ul> |
| <ul class="navList"> |
| <li><a href="../../../index.html?jakarta/enterprise/concurrent/ManagedExecutorService.html" target="_top">Frames</a></li> |
| <li><a href="ManagedExecutorService.html" target="_top">No Frames</a></li> |
| </ul> |
| <ul class="navList" id="allclasses_navbar_bottom"> |
| <li><a href="../../../allclasses-noframe.html">All Classes</a></li> |
| </ul> |
| <div> |
| <script type="text/javascript"><!-- |
| allClassesLink = document.getElementById("allclasses_navbar_bottom"); |
| if(window==top) { |
| allClassesLink.style.display = "block"; |
| } |
| else { |
| allClassesLink.style.display = "none"; |
| } |
| //--> |
| </script> |
| </div> |
| <div> |
| <ul class="subNavList"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method.summary">Method</a></li> |
| </ul> |
| <ul class="subNavList"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li>Constr | </li> |
| <li><a href="#method.detail">Method</a></li> |
| </ul> |
| </div> |
| <a name="skip.navbar.bottom"> |
| <!-- --> |
| </a></div> |
| <!-- ======== END OF BOTTOM NAVBAR ======= --> |
| </body> |
| </html> |