cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (Confluence)" <conflue...@apache.org>
Subject [CONF] Apache CXF Documentation > Continuations
Date Tue, 26 Nov 2013 17:19:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/en/2176/1/1/_/styles/combined.css?spaceKey=CXF20DOC&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CXF20DOC/Continuations">Continuations</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~sergey_beryozkin">Sergey
Beryozkin</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>CXF offers Servlet3 and
legacy Jetty Continuations HTTP as well as JMS ContinuationProvider implementations.  <br></td></tr>
            <tr><td class="diff-changed-lines" >ContinuationProvider can be used
to get [Continuation|http://svn.apache.org/repos/asf/cxf/trunk/core/src/main/java/org/apache/cxf/continuations/Continuation.java]
which <span class="diff-changed-words">represent<span class="diff-added-chars"style="background-color:
#dfd;">s</span></span> a current active or suspended invocation. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>The provider and continuations
can be obtained from the current CXF message like this:  <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p><span style="font-size:2em;font-weight:bold"> Continuations </span></p>

<div>
<ul>
    <li><a href='#Continuations-ContinuationsAPI'>Continuations API</a></li>
    <li><a href='#Continuations-UseAsyncMethod'>UseAsyncMethod</a></li>
    <li><a href='#Continuations-JAXRS2.0AsyncResponse'>JAX-RS 2.0 AsyncResponse</a></li>
    <li><a href='#Continuations-SuspendinginvocationsfromCXFinterceptors'>Suspending
invocations from CXF interceptors</a></li>
</ul></div>

<h1><a name="Continuations-ContinuationsAPI"></a>Continuations API </h1>

<p>CXF offers Continuations API to manage asynchronous (suspended) invocations.</p>

<p><a href="http://svn.apache.org/repos/asf/cxf/trunk/core/src/main/java/org/apache/cxf/continuations/ContinuationProvider.java"
class="external-link" rel="nofollow">ContinuationProvider</a> represents a transport
capable of suspending and resuming the invocations on request. </p>

<p>CXF offers Servlet3 and legacy Jetty Continuations HTTP as well as JMS ContinuationProvider
implementations. <br/>
ContinuationProvider can be used to get <a href="http://svn.apache.org/repos/asf/cxf/trunk/core/src/main/java/org/apache/cxf/continuations/Continuation.java"
class="external-link" rel="nofollow">Continuation</a> which represents a current
active or suspended invocation. </p>

<p>The provider and continuations can be obtained from the current CXF message like
this: </p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
import org.apache.cxf.continuations.ContinuationProvider;
import org.apache.cxf.continuations.Continuation;

ContinuationProvider provider = (ContinuationProvider)message.get(ContinuationProvider.class.getName())
Continuation continuation = (Continuation)provider.getContinuation();
</pre>
</div></div> 

<p>The continuation can be suspended and resumed. </p>

<p>Calling Continuation.suspend() and returning from the current method/code is enough
to get CXF suspending the request. Additionally throwing <a href="http://svn.apache.org/repos/asf/cxf/trunk/core/src/main/java/org/apache/cxf/continuations/SuspendedInvocationException.java"
class="external-link" rel="nofollow">SuspendedInvocationException</a> was required
originally but is no longer required/recommended.</p>

<p>Resuming the continuation will get the suspended thread returning, this is typically
done by a thread which has completed an asynchronous task. </p>

<p>Advanced applications can register <a href="http://svn.apache.org/repos/asf/cxf/trunk/core/src/main/java/org/apache/cxf/continuations/ContinuationCallback.java"
class="external-link" rel="nofollow">ContinuationCallback</a> with the current exchange
in order to get the notifications that a given Continuation has completed its work by returning
the data to the client. </p>

<p>The custom applications can interact directly with Continuations API. CXF also offers
higher-level support for asynchronous invocations built on top of Continuations API.</p>


<h1><a name="Continuations-UseAsyncMethod"></a>UseAsyncMethod</h1>

<p>JAX-WS frontend supports this annotation, please check the <a href="http://cxf.apache.org/docs/annotations.html"
class="external-link" rel="nofollow">CXF Annotations</a> page for more information.</p>

<h1><a name="Continuations-JAXRS2.0AsyncResponse"></a>JAX-RS 2.0 AsyncResponse</h1>

<p>JAX-RS 2.0 AsyncResponse is implemented in terms of Continuations API. Please see
<a href="http://cxf.apache.org/docs/jax-rs-basics.html#JAX-RSBasics-Suspendedinvocations"
class="external-link" rel="nofollow">this section</a> for more information. </p>

<h1><a name="Continuations-SuspendinginvocationsfromCXFinterceptors"></a>Suspending
invocations from CXF interceptors</h1>

<p>Advanced custom CXF interceptors can suspend the incoming requests and resume them
when needed. <br/>
Example:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Default; brush: java; gutter: false" style="font-size:12px; font-family:
ConfluenceInstalledFont,monospace;">
//TODO
</pre>
</div></div>






    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://cwiki.apache.org/confluence/users/removespacenotification.action?spaceKey=CXF20DOC">Stop
watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://cwiki.apache.org/confluence/users/editmyemailsettings.action">Change
email notification preferences</a>
</div>
        <a href="https://cwiki.apache.org/confluence/display/CXF20DOC/Continuations">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=34842124&revisedVersion=5&originalVersion=4">View
Changes</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message