Author: buildbot
Date: Thu Feb 11 02:01:13 2021
New Revision: 1071128

Log:
Production update by buildbot for cxf

Modified:
    websites/production/cxf/content/cache/docs.pageCache
    websites/production/cxf/content/docs/developing-a-consumer.html

Modified: websites/production/cxf/content/cache/docs.pageCache
==============================================================================
Binary files - no diff available.

Modified: websites/production/cxf/content/docs/developing-a-consumer.html
==============================================================================
--- websites/production/cxf/content/docs/developing-a-consumer.html (original)
+++ websites/production/cxf/content/docs/developing-a-consumer.html Thu Feb 11 
02:01:13 2021
@@ -117,7 +117,7 @@ Apache CXF -- Developing a Consumer
          <td height="100%">
            <!-- Content -->
            <div class="wiki-content">
-<div id="ConfluenceContent"><h1 
id="DevelopingaConsumer-DevelopingaConsumerwithCXF">Developing a Consumer with 
CXF</h1><h2 id="DevelopingaConsumer-GeneratingtheStubCode">Generating the Stub 
Code</h2><p>The starting point for developing a service consumer (or client) in 
CXF is a WSDL contract, complete with port type, binding, and service 
definitions. You can then use the <a shape="rect" 
href="wsdl-to-java.html">wsdl2java</a> utility to generate the Java stub code 
from the WSDL contract. The stub code provides the supporting code that is 
required to invoke operations on the remote service.<br clear="none"> For CXF 
clients, the wsdl2java utility can generate the following kinds of 
code:</p><ul><li>Stub code - supporting files for implementing a CXF 
client.</li><li>Client starting point code - sample client code that connects 
to the remote service and invokes every operation on the remote 
service.</li><li>Ant build file - a <code>build.xml</code> file intended for 
use with the ant buil
 d utility. It has targets for building and for running the sample client 
application.</li></ul><h4 
id="DevelopingaConsumer-BasicHelloWorldWSDLcontract">Basic HelloWorld WSDL 
contract</h4><p>The below shows the HelloWorld WSDL contract. This contract 
defines a single port type, <code>Greeter</code>, with a SOAP binding, 
<code>Greeter_SOAPBinding</code>, and a service, <code>SOAPService</code>, 
which has a single port, <code>SoapPort</code>.</p><p><span 
class="confluence-anchor-link" 
id="DevelopingaConsumer-Example1"></span></p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>HelloWorld WSDL Contract</b></div><div 
class="codeContent panelContent pdl">
+<div id="ConfluenceContent"><h1 
id="DevelopingaConsumer-DevelopingaConsumerwithCXF">Developing a Consumer with 
CXF</h1><h2 id="DevelopingaConsumer-GeneratingtheStubCode">Generating the Stub 
Code</h2><p>The starting point for developing a service consumer (or client) in 
CXF is a WSDL contract, complete with port type, binding, and service 
definitions. You can then use the <a shape="rect" 
href="wsdl-to-java.html">wsdl2java</a> utility to generate the Java stub code 
from the WSDL contract. The stub code provides the supporting code that is 
required to invoke operations on the remote service.<br clear="none">For CXF 
clients, the wsdl2java utility can generate the following kinds of 
code:</p><ul><li>Stub code - supporting files for implementing a CXF 
client.</li><li>Client starting point code - sample client code that connects 
to the remote service and invokes every operation on the remote 
service.</li><li>Ant build file - a <code>build.xml</code> file intended for 
use with the ant build
  utility. It has targets for building and for running the sample client 
application.</li></ul><h4 
id="DevelopingaConsumer-BasicHelloWorldWSDLcontract">Basic HelloWorld WSDL 
contract</h4><p>The below shows the HelloWorld WSDL contract. This contract 
defines a single port type, <code>Greeter</code>, with a SOAP binding, 
<code>Greeter_SOAPBinding</code>, and a service, <code>SOAPService</code>, 
which has a single port, <code>SoapPort</code>.</p><p><span 
class="confluence-anchor-link" 
id="DevelopingaConsumer-Example1"></span></p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>HelloWorld WSDL Contract</b></div><div 
class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default">&lt;wsdl:definitions 
name="HelloWorld" targetNamespace="http://apache.org/hello_world_soap_http"; 
     xmlns="http://schemas.xmlsoap.org/wsdl/"; 
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
@@ -285,11 +285,11 @@ Apache CXF -- Developing a Consumer
 </pre>
 </div></div><p>The <code>Greeter</code> port type defines the following WSDL 
operations:</p><ul><li><code>sayHi</code> - has a single output parameter, of 
<code>xsd:string</code>.</li><li><code>greetMe</code> - has an input parameter, 
of <code>xsd:string</code>, and an output parameter, of 
<code>xsd:string</code>.</li><li><code>greetMeOneWay</code> - has a single 
input parameter, of <code>xsd:string</code>. Because this operation has no 
output parameters, CXF can optimize this call to be a oneway invocation (that 
is, the client does not wait for a response from the 
server).</li><li><code>pingMe</code> - has no input parameters and no output 
parameters, but it can raise a fault exception.</li></ul><p>This WSDL also 
defines a binding, <code>Greeter_SOAPBinding</code>, for the SOAP protocol. In 
practice, the binding is normally generated automatically - for example, by 
running either of the CXF wsdl2soap or wsdl2xml utilities. Likewise, the 
<code>SOAPService</code> service can be gener
 ated automatically by running the CXF wsdl2service utility.</p><h4 
id="DevelopingaConsumer-Generatingthestubcode">Generating the stub 
code</h4><p>After defining the WSDL contract, you can generate client code 
using the CXF wsdl2java utility. Enter the following command at a command-line 
prompt:</p><div class="panel" style="border-width: 1px;"><div 
class="panelContent">
 <p><code>wsdl2java -ant -client -d <em>ClientDir</em> 
hello_world.wsdl</code></p>
-</div></div><p>Where <em>ClientDir</em> is the location of a directory where 
you would like to put the generated files and<code> hello_world.wsdl</code> is 
a file containing the contract shown in the WSDL above. The <code>-ant</code> 
option generates an ant <code>build.xml</code> file, for use with the ant build 
utility. The <code>-client</code> option generates starting point code for a 
client <code>main()</code> method.</p><p>The preceding wsdl2java command 
generates the following Java 
packages:</p><ul><li><code>org.apache.hello_world_soap_http</code> <br 
clear="none"> This package name is generated from the <code>
+</div></div><p>Where <em>ClientDir</em> is the location of a directory where 
you would like to put the generated files and<code> hello_world.wsdl</code> is 
a file containing the contract shown in the WSDL above. The <code>-ant</code> 
option generates an ant <code>build.xml</code> file, for use with the ant build 
utility. The <code>-client</code> option generates starting point code for a 
client <code>main()</code> method.</p><p>The preceding wsdl2java command 
generates the following Java 
packages:</p><ul><li><code>org.apache.hello_world_soap_http</code> <br 
clear="none">This package name is generated from the <code>
       <span class="nolink">http://apache.org/hello_world_soap_http</span>
-    </code> target namespace. All of the WSDL entities defined in this target 
namespace (for example, the Greeter port type and the SOAPService service) map 
to Java classes in the corresponding Java 
package.</li><li><code>org.apache.hello_world_soap_http.types</code> <br 
clear="none"> This package name is generated from the <code>
+    </code> target namespace. All of the WSDL entities defined in this target 
namespace (for example, the Greeter port type and the SOAPService service) map 
to Java classes in the corresponding Java 
package.</li><li><code>org.apache.hello_world_soap_http.types</code> <br 
clear="none">This package name is generated from the <code>
       <span class="nolink">http://apache.org/hello_world_soap_http/types</span>
-    </code> target namespace. All of the XML types defined in this target 
namespace (that is, everything defined in the <code>wsdl:types</code> element 
of the HelloWorld contract) map to Java classes in the corresponding Java 
package.</li></ul><p>The stub files generated by the wsdl2java command fall 
into the following categories:</p><ul><li>Classes representing WSDL entities 
(in the <code>org.apache.hello_world_soap_http</code> package) - the following 
classes are generated to represent WSDL entities:<ul><li><code>Greeter</code> 
is a Java interface that represents the Greeter WSDL port type. In JAX-WS 
terminology, this Java interface is a service endpoint 
interface.</li><li><code>SOAPService</code> is a Java class that represents the 
SOAPService WSDL <code>service</code> element.</li><li><code>PingMeFault</code> 
is a Java exception class (extending <code>java.lang.Exception</code>) that 
represents the pingMeFault WSDL <code>fault</code> 
element.</li></ul></li><li>Classes representi
 ng XML types (in the <code>org.apache.hello_world_soap_http.types</code> 
package) - in the HelloWorld example, the only generated types are the various 
wrappers for the request and reply messages. Some of these data types are 
useful for the asynchronous invocation model.</li></ul><h2 
id="DevelopingaConsumer-ImplementingaCXFClient">Implementing a CXF 
Client</h2><p>This section describes how to write the code for a simple Java 
client, based on the WSDL contract <a shape="rect" 
href="developing-a-consumer.html">above</a>. To implement the client, you need 
to use the following stub classes:</p><ul><li>Service class (that is, 
<code>SOAPService</code>).</li><li>Service endpoint interface (that is, 
<code>Greeter</code>).</li></ul><h4 
id="DevelopingaConsumer-Generatedserviceclass">Generated service 
class</h4><p>The below shows the typical outline for a generated service class, 
<code>ServiceName</code>, which extends the <code>javax.xml.ws.Service</code> 
base class.</p><p><span class="conflu
 ence-anchor-link" id="DevelopingaConsumer-Example2"></span></p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeHeader 
panelHeader pdl" style="border-bottom-width: 1px;"><b>Outline of a Generated 
Service Class</b></div><div class="codeContent panelContent pdl">
+    </code> target namespace. All of the XML types defined in this target 
namespace (that is, everything defined in the <code>wsdl:types</code> element 
of the HelloWorld contract) map to Java classes in the corresponding Java 
package.</li></ul><p>The stub files generated by the wsdl2java command fall 
into the following categories:</p><ul><li>Classes representing WSDL entities 
(in the <code>org.apache.hello_world_soap_http</code> package) - the following 
classes are generated to represent WSDL entities:<ul><li><code>Greeter</code> 
is a Java interface that represents the Greeter WSDL port type. In JAX-WS 
terminology, this Java interface is a service endpoint 
interface.</li><li><code>SOAPService</code> is a Java class that represents the 
SOAPService WSDL <code>service</code> element.</li><li><code>PingMeFault</code> 
is a Java exception class (extending <code>java.lang.Exception</code>) that 
represents the pingMeFault WSDL <code>fault</code> 
element.</li></ul></li><li>Classes representi
 ng XML types (in the <code>org.apache.hello_world_soap_http.types</code> 
package) - in the HelloWorld example, the only generated types are the various 
wrappers for the request and reply messages. Some of these data types are 
useful for the asynchronous invocation model.</li></ul><h2 
id="DevelopingaConsumer-ImplementingaCXFClient">Implementing a CXF 
Client</h2><p>This section describes how to write the code for a simple Java 
client, based on the WSDL contract <a shape="rect" 
href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=84803638";>above</a>.
 To implement the client, you need to use the following stub 
classes:</p><ul><li>Service class (that is, 
<code>SOAPService</code>).</li><li>Service endpoint interface (that is, 
<code>Greeter</code>).</li></ul><h4 
id="DevelopingaConsumer-Generatedserviceclass">Generated service 
class</h4><p>The below shows the typical outline for a generated service class, 
<code>ServiceName</code>, which extends the <code>javax.xml.ws.Servi
 ce</code> base class.</p><p><span class="confluence-anchor-link" 
id="DevelopingaConsumer-Example2"></span></p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>Outline of a Generated Service 
Class</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default">public class 
ServiceName extends javax.xml.ws.Service {
   ...
   public ServiceName(URL wsdlLocation, QName serviceName) { }
@@ -304,7 +304,7 @@ Apache CXF -- Developing a Consumer
 </pre>
 </div></div><p>The <code>ServiceName</code> class defines the following 
methods:</p><ul><li>Constructor methods - the following forms of constructor 
are defined:<ul><li><code>
           <em>ServiceName</em>(URL <em>wsdlLocation</em>, QName 
<em>serviceName</em>)</code> constructs a service object based on the data in 
the <em>serviceName</em> service in the WSDL contract that is obtainable from 
<em>wsdlLocation</em>.</li><li><code>
-          <em>ServiceName</em>()</code> is the default constructor, which 
constructs a service object based on the service name and WSDL contract that 
were provided at the time the stub code was generated (for example, when 
running the CXF wsdl2java command). Using this constructor presupposes that the 
WSDL contract remains available at its original 
location.</li></ul></li><li><code>get_PortName_()</code> methods - for every 
<em>PortName</em> port defined on the <em>ServiceName</em> service, CXF 
generates a corresponding <code>get_PortName_()</code> method in Java. 
Therefore, a <code>wsdl:service</code> element that defines multiple ports will 
generate a service class with multiple <code>get_PortName_()</code> 
methods.</li></ul><h4 id="DevelopingaConsumer-Serviceendpointinterface">Service 
endpoint interface</h4><p>For every port type defined in the original WSDL 
contract, you can generate a corresponding service endpoint interface in Java. 
A service endpoint interface is the Java ma
 pping of a WSDL port type. Each operation defined in the original WSDL port 
type maps to a corresponding method in the service endpoint interface. The 
operation's parameters are mapped as follows:</p><ol><li>The input parameters 
are mapped to method arguments.</li><li>The first output parameter is mapped to 
a return value.</li><li>If there is more than one output parameter, the second 
and subsequent output parameters map to method arguments (moreover, the values 
of these arguments must be passed using Holder types).</li></ol><p>For example, 
the below shows the Greeter service endpoint interface, which is generated from 
the Greeter port type defined in <a shape="rect" 
href="developing-a-consumer.html">#Example1</a>. For simplicity, <a 
shape="rect" href="developing-a-consumer.html">#Example3</a> omits the standard 
JAXB and JAX-WS annotations.</p><p><span class="confluence-anchor-link" 
id="DevelopingaConsumer-Example3"></span></p><div class="code panel pdl" 
style="border-width: 1px;"><
 div class="codeHeader panelHeader pdl" style="border-bottom-width: 
1px;"><b>The Greeter Service Endpoint Interface</b></div><div 
class="codeContent panelContent pdl">
+          <em>ServiceName</em>()</code> is the default constructor, which 
constructs a service object based on the service name and WSDL contract that 
were provided at the time the stub code was generated (for example, when 
running the CXF wsdl2java command). Using this constructor presupposes that the 
WSDL contract remains available at its original 
location.</li></ul></li><li><code>get_PortName_()</code> methods - for every 
<em>PortName</em> port defined on the <em>ServiceName</em> service, CXF 
generates a corresponding <code>get_PortName_()</code> method in Java. 
Therefore, a <code>wsdl:service</code> element that defines multiple ports will 
generate a service class with multiple <code>get_PortName_()</code> 
methods.</li></ul><h4 id="DevelopingaConsumer-Serviceendpointinterface">Service 
endpoint interface</h4><p>For every port type defined in the original WSDL 
contract, you can generate a corresponding service endpoint interface in Java. 
A service endpoint interface is the Java ma
 pping of a WSDL port type. Each operation defined in the original WSDL port 
type maps to a corresponding method in the service endpoint interface. The 
operation's parameters are mapped as follows:</p><ol><li>The input parameters 
are mapped to method arguments.</li><li>The first output parameter is mapped to 
a return value.</li><li>If there is more than one output parameter, the second 
and subsequent output parameters map to method arguments (moreover, the values 
of these arguments must be passed using Holder types).</li></ol><p>For example, 
the below shows the Greeter service endpoint interface, which is generated from 
the Greeter port type defined in <a shape="rect" 
href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=84803638";>#Example1</a>.
 For simplicity, <a shape="rect" 
href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=84803638";>#Example3</a>
 omits the standard JAXB and JAX-WS annotations.</p><p><span 
class="confluence-anchor-link" id="Dev
 elopingaConsumer-Example3"></span></p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>The Greeter Service Endpoint 
Interface</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default">/* Generated by 
WSDLToJava Compiler. */
 
 package org.objectweb.hello_world_soap_http;
@@ -403,7 +403,7 @@ java.util.Map&lt;String, Object&gt; resp
   ((javax.xml.ws.BindingProvider)port).getResponseContext();
 PropertyType propValue = (PropertyType) 
responseContext.get(ContextPropertyName);
 </pre>
-</div></div><p>The response context is of type, <code>java.util.Map&lt;String, 
Object&gt;</code>, which is a hash map that has keys of type 
<code>String</code> and values of an arbitrary type. Use 
<code>java.util.Map.get()</code> to access an entry in the hash map of response 
context properties.</p><h4 id="DevelopingaConsumer-Supportedcontexts">Supported 
contexts</h4><p>CXF supports the following context properties:</p><div 
class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" 
rowspan="1" class="confluenceTh"><p>Context Property Name</p></th><th 
colspan="1" rowspan="1" class="confluenceTh"><p>Context Property 
Type</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.cxf.ws.addressing.JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES</code></p></td><td
 colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.cxf.ws.addressing.AddressingProperties</code></p></td></tr></tbody></table></div><h2
 id="DevelopingaConsumer-Asynchrono
 usInvocationModel">Asynchronous Invocation Model</h2><p>In addition to the 
usual synchronous mode of invocation, CXF also supports two forms of 
asynchronous invocation, as follows:</p><ul><li><strong>Polling 
approach</strong> - in this case, to invoke the remote operation, you call a 
special method that has no output parameters, but returns a 
<code>javax.xml.ws.Response</code> instance. The <code>Response</code> object 
(which inherits from the <code>javax.util.concurrency.Future</code> interface) 
can be polled to check whether or not a response message has 
arrived.</li><li><strong>Callback approach</strong> - in this case, to invoke 
the remote operation, you call another special method that takes a reference to 
a callback object (of <code>javax.xml.ws.AsyncHandler</code> type) as one of 
its parameters. Whenever the response message arrives at the client, the CXF 
runtime calls back on the <code>AsyncHandler</code> object to give it the 
contents of the response message.</li></ul><p>Bo
 th of these asynchronous invocation approaches are described here and 
illustrated by code examples.</p><h4 
id="DevelopingaConsumer-Contractforasynchronousexample">Contract for 
asynchronous example</h4><p>The following example shows the WSDL contract that 
is used for the asynchronous example. The contract defines a single port type, 
<code>GreeterAsync</code>, which contains a single operation, 
<code>greetMeSometime</code>.</p><p><span class="confluence-anchor-link" 
id="DevelopingaConsumer-Example6"></span></p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>HelloWorld WSDL Contract for Asynchronous 
Example</b></div><div class="codeContent panelContent pdl">
+</div></div><p>The response context is of type, <code>java.util.Map&lt;String, 
Object&gt;</code>, which is a hash map that has keys of type 
<code>String</code> and values of an arbitrary type. Use 
<code>java.util.Map.get()</code> to access an entry in the hash map of response 
context properties.</p><h4 id="DevelopingaConsumer-Supportedcontexts">Supported 
contexts</h4><p>CXF supports the following context properties:</p><div 
class="table-wrap"><table class="wrapped confluenceTable"><tbody><tr><th 
colspan="1" rowspan="1" class="confluenceTh"><p>Context Property 
Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Context 
Property Type</p></th></tr><tr><td colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.cxf.ws.addressing.JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES</code></p></td><td
 colspan="1" rowspan="1" 
class="confluenceTd"><p><code>org.apache.cxf.ws.addressing.AddressingProperties</code></p></td></tr></tbody></table></div><h2
 id="DevelopingaConsumer-As
 ynchronousInvocationModel">Asynchronous Invocation Model</h2><p>In addition to 
the usual synchronous mode of invocation, CXF also supports two forms of 
asynchronous invocation, as follows:</p><ul><li><strong>Polling 
approach</strong> - in this case, to invoke the remote operation, you call a 
special method that has no output parameters, but returns a 
<code>javax.xml.ws.Response</code> instance. The <code>Response</code> object 
(which inherits from the <code>javax.util.concurrency.Future</code> interface) 
can be polled to check whether or not a response message has 
arrived.</li><li><strong>Callback approach</strong> - in this case, to invoke 
the remote operation, you call another special method that takes a reference to 
a callback object (of <code>javax.xml.ws.AsyncHandler</code> type) as one of 
its parameters. Whenever the response message arrives at the client, the CXF 
runtime calls back on the <code>AsyncHandler</code> object to give it the 
contents of the response message.</li></
 ul><p>Both of these asynchronous invocation approaches are described here and 
illustrated by code examples.</p><h4 
id="DevelopingaConsumer-Contractforasynchronousexample">Contract for 
asynchronous example</h4><p>The following example shows the WSDL contract that 
is used for the asynchronous example. The contract defines a single port type, 
<code>GreeterAsync</code>, which contains a single operation, 
<code>greetMeSometime</code>.</p><p><span class="confluence-anchor-link" 
id="DevelopingaConsumer-Example6"></span></p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" 
style="border-bottom-width: 1px;"><b>HelloWorld WSDL Contract for Asynchronous 
Example</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default">&lt;wsdl:definitions 
xmlns="http://schemas.xmlsoap.org/wsdl/";
            xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
            xmlns:tns="http://apache.org/hello_world_async_soap_http";
@@ -537,7 +537,7 @@ public final class Client {
   }
 }
 </pre>
-</div></div><p>The <code>greetMeSometimeAsync()</code> method invokes the 
<code>greetMeSometimes</code> operation, transmitting the input parameters to 
the remote service and returning a reference to a 
<code>javax.xml.ws.Response&lt;GreetMeSometimeResponse&gt;</code> object. The 
<code>Response</code> class is defined by extending the standard 
<code>java.util.concurrency.Future&lt;T&gt;</code> interface, which is 
specifically designed for polling the outcome of work performed by a concurrent 
thread. There are essentially two basic approaches to polling using the 
<code>Response</code> object:</p><ul><li><p><strong>Non-blocking 
polling</strong> - before attempting to get the result, check whether the 
response has arrived by calling the non-blocking<br clear="none"> 
<code>Response&lt;T&gt;.isDone()</code> method. For example:</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
+</div></div><p>The <code>greetMeSometimeAsync()</code> method invokes the 
<code>greetMeSometimes</code> operation, transmitting the input parameters to 
the remote service and returning a reference to a 
<code>javax.xml.ws.Response&lt;GreetMeSometimeResponse&gt;</code> object. The 
<code>Response</code> class is defined by extending the standard 
<code>java.util.concurrency.Future&lt;T&gt;</code> interface, which is 
specifically designed for polling the outcome of work performed by a concurrent 
thread. There are essentially two basic approaches to polling using the 
<code>Response</code> object:</p><ul><li><p><strong>Non-blocking 
polling</strong> - before attempting to get the result, check whether the 
response has arrived by calling the non-blocking<br 
clear="none"><code>Response&lt;T&gt;.isDone()</code> method. For 
example:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: 
Default">Response&lt;GreetMeSometimeResponse&gt; greetMeSomeTimeResp = ...;
 
 if (greetMeSomeTimeResp.isDone()) {
@@ -584,7 +584,7 @@ public class TestAsyncHandler implements
   }
 }
 </pre>
-</div></div><p>The implementation of <code>handleResponse()</code> shown in <a 
shape="rect" href="developing-a-consumer.html">#Example11</a> simply gets the 
response data and stores it in a member variable, <code>reply</code>. The extra 
<code>getResponse()</code> method is just a convenience method that extracts 
the sole output parameter (that is, <code>responseType</code>) from the 
response.</p><p><a shape="rect" 
href="developing-a-consumer.html">#Example12</a> illustrates the callback 
approach to making an asynchronous operation call. Using this approach, the 
client invokes the operation by calling the special Java method, 
<code>_OperationName_Async()</code>, that returns a 
<code>java.util.concurrency.Future&lt;?&gt;</code> object and takes an extra 
parameter of <code>AsyncHandler&lt;T&gt;</code>.</p><p><span 
class="confluence-anchor-link" 
id="DevelopingaConsumer-Example12"></span></p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeHeader panelHeader pdl" st
 yle="border-bottom-width: 1px;"><b>Callback Approach for an Asynchronous 
Operation Call</b></div><div class="codeContent panelContent pdl">
+</div></div><p>The implementation of <code>handleResponse()</code> shown in <a 
shape="rect" 
href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=84803638";>#Example11</a>
 simply gets the response data and stores it in a member variable, 
<code>reply</code>. The extra <code>getResponse()</code> method is just a 
convenience method that extracts the sole output parameter (that is, 
<code>responseType</code>) from the response.</p><p><a shape="rect" 
href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=84803638";>#Example12</a>
 illustrates the callback approach to making an asynchronous operation call. 
Using this approach, the client invokes the operation by calling the special 
Java method, <code>_OperationName_Async()</code>, that returns a 
<code>java.util.concurrency.Future&lt;?&gt;</code> object and takes an extra 
parameter of <code>AsyncHandler&lt;T&gt;</code>.</p><p><span 
class="confluence-anchor-link" id="DevelopingaConsumer-Example12"></span></p><di
 v class="code panel pdl" style="border-width: 1px;"><div class="codeHeader 
panelHeader pdl" style="border-bottom-width: 1px;"><b>Callback Approach for an 
Asynchronous Operation Call</b></div><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default">package demo.hw.client;
 
 import java.io.File;
@@ -618,7 +618,7 @@ public final class Client {
   }
 }
 </pre>
-</div></div><p>The <code>Future&lt;?&gt;</code> object returned by 
<code>greetMeSometimeAsync()</code> can be used only to test whether or not a 
response has arrived yet - for example, by calling 
<code>response.isDone()</code>. The value of the response is only made 
available to the callback object, <code>testAsyncHandler</code>.</p></div>
+</div></div><p>The <code>Future&lt;?&gt;</code> object returned by 
<code>greetMeSometimeAsync()</code> can be used only to test whether or not a 
response has arrived yet - for example, by calling 
<code>response.isDone()</code>. The value of the response is only made 
available to the callback object, <code>testAsyncHandler</code>.</p><div 
class="confluence-information-macro confluence-information-macro-warning"><span 
class="aui-icon aui-icon-small aui-iconfont-error 
confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>Please be careful when using 
asynchronous consumers along with reactive / non-blocking libraries. There is 
certain amount of intialization code (usually, on the first asynchronous 
invocation) which may cause unnecessary blocking.</p></div></div></div>
            </div>
            <!-- Content -->
          </td>


Reply via email to