blob: f4210c43d2de5dec1a91b7d4837dc6b45e8da6e5 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- NewPage -->
<html lang="en">
<head>
<title>Asynchronous.Result</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="Asynchronous.Result";
}
}
catch(err) {
}
//-->
var methods = {"i0":9,"i1":9,"i2":9};
var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],8:["t4","Concrete 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/Asynchronous.html" title="annotation in jakarta.enterprise.concurrent"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../jakarta/enterprise/concurrent/ContextService.html" title="interface in jakarta.enterprise.concurrent"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?jakarta/enterprise/concurrent/Asynchronous.Result.html" target="_top">Frames</a></li>
<li><a href="Asynchronous.Result.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../allclasses-noframe.html">All&nbsp;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:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</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="Class Asynchronous.Result" class="title">Class Asynchronous.Result</h2>
</div>
<div class="contentContainer">
<ul class="inheritance">
<li>java.lang.Object</li>
<li>
<ul class="inheritance">
<li>jakarta.enterprise.concurrent.Asynchronous.Result</li>
</ul>
</li>
</ul>
<div class="description">
<ul class="blockList">
<li class="blockList">
<dl>
<dt>Enclosing class:</dt>
<dd><a href="../../../jakarta/enterprise/concurrent/Asynchronous.html" title="annotation in jakarta.enterprise.concurrent">Asynchronous</a></dd>
</dl>
<hr>
<br>
<pre>public static final class <span class="typeNameLabel">Asynchronous.Result</span>
extends java.lang.Object</pre>
<div class="block">Mechanism by which the Jakarta EE Product Provider makes available
to the asynchronous method implementation the same
<code>CompletableFuture</code>
instance that the Jakarta EE Product Provider supplies to the caller
of the asynchronous method.
<p>
Before invoking the asynchronous method implementation on a thread,
the Jakarta EE Product Provider invokes the <a href="../../../jakarta/enterprise/concurrent/Asynchronous.Result.html#setFuture-java.util.concurrent.CompletableFuture-"><code>setFuture(java.util.concurrent.CompletableFuture&lt;T&gt;)</code></a> method
which makes available to the asynchronous method implementation
the same <code>CompletableFuture</code> that the Jakarta EE Product Provider
returns to the caller.
<p>
The asynchronous method implementation invokes the <a href="../../../jakarta/enterprise/concurrent/Asynchronous.Result.html#getFuture--"><code>getFuture()</code></a> method
to obtain the same <code>CompletableFuture</code> that the
Jakarta EE Product Provider returns to the caller.
The asynchronous method implementation can choose to complete
this future (normally or exceptionally) or otherwise arrange for its
completion, for example upon completion of a pipeline of completion stages.
Having this same <code>CompletableFuture</code> also enables the asynchronous
method implementation to determine if the caller has forcibly completed
(such as by cancellation or any other means) the <code>CompletableFuture</code>,
in which case the asynchronous method implementation could decide to end
immediately rather than continue processing.
<p>
For example,
<pre>
@Asynchronous
public CompletableFuture &lt;Double&gt; hoursWorked(LocalDateTime from, LocalDateTime to) {
CompletableFuture &lt;Double&gt; future = Asynchronous.Result.getFuture();
if (future.isDone())
return future;
try (Connection con = ((DataSource) InitialContext.doLookup(
"java:comp/env/jdbc/timesheetDB")).getConnection()) {
...
for (ResultSet result = stmt.executeQuery(); result.next() &amp;&amp; !future.isDone(); )
...
future.complete(total);
} catch (NamingException | SQLException x) {
future.completeExceptionally(x);
}
return future;
}
</pre>
After the asynchronous method completes, the Jakarta EE Product Provider
invokes the <a href="../../../jakarta/enterprise/concurrent/Asynchronous.Result.html#setFuture-java.util.concurrent.CompletableFuture-"><code>setFuture(java.util.concurrent.CompletableFuture&lt;T&gt;)</code></a> method with a <code>null</code> value
to clear it from the thread.</div>
<dl>
<dt><span class="simpleTagLabel">Since:</span></dt>
<dd>3.0</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">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</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>static &lt;T&gt;&nbsp;java.util.concurrent.CompletableFuture&lt;T&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/Asynchronous.Result.html#complete-T-">complete</a></span>(T&nbsp;result)</code>
<div class="block">Completes the <code>CompletableFuture</code>
instance that the Jakarta EE Product Provider supplies to the caller of the
asynchronous method.</div>
</td>
</tr>
<tr id="i1" class="rowColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;java.util.concurrent.CompletableFuture&lt;T&gt;</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/Asynchronous.Result.html#getFuture--">getFuture</a></span>()</code>
<div class="block">Obtains the same <code>CompletableFuture</code>
instance that the Jakarta EE Product Provider supplies to the caller of the
asynchronous method.</div>
</td>
</tr>
<tr id="i2" class="altColor">
<td class="colFirst"><code>static &lt;T&gt;&nbsp;void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../jakarta/enterprise/concurrent/Asynchronous.Result.html#setFuture-java.util.concurrent.CompletableFuture-">setFuture</a></span>(java.util.concurrent.CompletableFuture&lt;T&gt;&nbsp;future)</code>
<div class="block">Before invoking the asynchronous method implementation on a thread,
the Jakarta EE Product Provider invokes this method to make available
to the asynchronous method implementation the same <code>CompletableFuture</code>
that the Jakarta EE Product Provider returns to the caller.</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
<!-- -->
</a>
<h3>Methods inherited from class&nbsp;java.lang.Object</h3>
<code>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</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="complete-java.lang.Object-">
<!-- -->
</a><a name="complete-T-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>complete</h4>
<pre>public static&nbsp;&lt;T&gt;&nbsp;java.util.concurrent.CompletableFuture&lt;T&gt;&nbsp;complete(T&nbsp;result)</pre>
<div class="block">Completes the <code>CompletableFuture</code>
instance that the Jakarta EE Product Provider supplies to the caller of the
asynchronous method.
<p>
This method must only be invoked by the asynchronous method implementation.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - type of result returned by the asynchronous method's <code>CompletableFuture</code>.</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>result</code> - result with which to complete the asynchronous method's <code>CompletableFuture</code>.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the same <code>CompletableFuture</code> that the container returns to the caller.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalStateException</code> - if the <code>CompletableFuture</code> for an asynchronous
method is not present on the thread.</dd>
</dl>
</li>
</ul>
<a name="getFuture--">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>getFuture</h4>
<pre>public static&nbsp;&lt;T&gt;&nbsp;java.util.concurrent.CompletableFuture&lt;T&gt;&nbsp;getFuture()</pre>
<div class="block">Obtains the same <code>CompletableFuture</code>
instance that the Jakarta EE Product Provider supplies to the caller of the
asynchronous method.
<p>
This method must only be invoked by the asynchronous method implementation.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - type of result returned by the asynchronous method's <code>CompletableFuture</code>.</dd>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>the same <code>CompletableFuture</code> that the container returns to the caller.</dd>
<dt><span class="throwsLabel">Throws:</span></dt>
<dd><code>java.lang.IllegalStateException</code> - if the <code>CompletableFuture</code> for an asynchronous
method is not present on the thread.</dd>
</dl>
</li>
</ul>
<a name="setFuture-java.util.concurrent.CompletableFuture-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>setFuture</h4>
<pre>public static&nbsp;&lt;T&gt;&nbsp;void&nbsp;setFuture(java.util.concurrent.CompletableFuture&lt;T&gt;&nbsp;future)</pre>
<div class="block">Before invoking the asynchronous method implementation on a thread,
the Jakarta EE Product Provider invokes this method to make available
to the asynchronous method implementation the same <code>CompletableFuture</code>
that the Jakarta EE Product Provider returns to the caller.
<p>
After the asynchronous method completes, the Jakarta EE Product Provider
invokes this method with a <code>null</code> value
to clear it from the thread.
<p>
This method must only be invoked by the Jakarta EE Product Provider.</div>
<dl>
<dt><span class="paramLabel">Type Parameters:</span></dt>
<dd><code>T</code> - type of result returned by the asynchronous method's <code>CompletableFuture</code>.</dd>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>future</code> - <code>CompletableFuture</code> that the container returns to the caller,
or <code>null</code> to clear it.</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/Asynchronous.html" title="annotation in jakarta.enterprise.concurrent"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
<li><a href="../../../jakarta/enterprise/concurrent/ContextService.html" title="interface in jakarta.enterprise.concurrent"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
</ul>
<ul class="navList">
<li><a href="../../../index.html?jakarta/enterprise/concurrent/Asynchronous.Result.html" target="_top">Frames</a></li>
<li><a href="Asynchronous.Result.html" target="_top">No&nbsp;Frames</a></li>
</ul>
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../allclasses-noframe.html">All&nbsp;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:&nbsp;</li>
<li>Nested&nbsp;|&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.summary">Method</a></li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li>Constr&nbsp;|&nbsp;</li>
<li><a href="#method.detail">Method</a></li>
</ul>
</div>
<a name="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</body>
</html>