cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r992315 - in /websites/production/cxf/content: cache/docs.pageCache docs/jaxrsclientspringboot.html
Date Fri, 08 Jul 2016 10:47:42 GMT
Author: buildbot
Date: Fri Jul  8 10:47:42 2016
New Revision: 992315

Log:
Production update by buildbot for cxf

Modified:
    websites/production/cxf/content/cache/docs.pageCache
    websites/production/cxf/content/docs/jaxrsclientspringboot.html

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

Modified: websites/production/cxf/content/docs/jaxrsclientspringboot.html
==============================================================================
--- websites/production/cxf/content/docs/jaxrsclientspringboot.html (original)
+++ websites/production/cxf/content/docs/jaxrsclientspringboot.html Fri Jul  8 10:47:42 2016
@@ -118,16 +118,12 @@ Apache CXF -- JAXRSClientSpringBoot
            <!-- Content -->
            <div class="wiki-content">
 <div id="ConfluenceContent"><p><style type="text/css">/*<![CDATA[*/
-div.rbtoc1467910017386 {padding: 0px;}
-div.rbtoc1467910017386 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1467910017386 li {margin-left: 0px;padding-left: 0px;}
-
-/*]]>*/</style></p><div class="toc-macro rbtoc1467910017386">
-<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSClientSpringBoot-Introduction">Introduction</a></li><li><a
shape="rect" href="#JAXRSClientSpringBoot-Setup">Setup</a></li><li><a
shape="rect" href="#JAXRSClientSpringBoot-EnablingWebClients">Enabling WebClients</a>
-<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSClientSpringBoot-Configuration">Configuration</a></li></ul>
-</li><li><a shape="rect" href="#JAXRSClientSpringBoot-EnablingProxyClients">Enabling
ProxyClients</a>
-<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSClientSpringBoot-Configuration.1">Configuration</a></li></ul>
-</li></ul>
+div.rbtoc1467974826174 {padding: 0px;}
+div.rbtoc1467974826174 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1467974826174 li {margin-left: 0px;padding-left: 0px;}
+
+/*]]>*/</style></p><div class="toc-macro rbtoc1467974826174">
+<ul class="toc-indentation"><li><a shape="rect" href="#JAXRSClientSpringBoot-Introduction">Introduction</a></li><li><a
shape="rect" href="#JAXRSClientSpringBoot-Setup">Setup</a></li><li><a
shape="rect" href="#JAXRSClientSpringBoot-EnablingWebClients">Enabling WebClients</a></li><li><a
shape="rect" href="#JAXRSClientSpringBoot-EnablingProxyClients">Enabling ProxyClients</a></li><li><a
shape="rect" href="#JAXRSClientSpringBoot-Configuration">Configuration</a></li></ul>
 </div><h1 id="JAXRSClientSpringBoot-Introduction">Introduction</h1><p>This
page describes how <a shape="rect" href="jax-rs-client-api.html">CXF JAX-RS Client</a>
code can be used inside SpringBoot applications.</p><p>Please see a&#160;<a
shape="rect" href="http://cxf.apache.org/docs/springboot.html#SpringBoot-SpringBootCXFJAX-RSStarter">CXF
JAX-RS starter</a> section on how to enable JAX-RS endpoints.</p><h1 id="JAXRSClientSpringBoot-Setup">Setup</h1><p>If
your SpringBoot Application depends on a <a shape="rect" href="http://cxf.apache.org/docs/springboot.html#SpringBoot-SpringBootCXFJAX-RSStarter">CXF
JAX-RS starter</a> then no more dependencies are required.</p><p>If you'd
like to run JAX-RS clients in a pure client-side&#160;SpringBoot Application then the
following Maven pom should suffice in many cases:</p><div class="code panel pdl"
style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <pre class="brush: xml; gutter: false; theme: Default" style="font-size:12px;">&lt;?xml
version="1.0" encoding="UTF-8"?&gt;
 &lt;project xmlns="http://maven.apache.org/POM/4.0.0" 
@@ -170,7 +166,7 @@ div.rbtoc1467910017386 li {margin-left:
     &lt;/build&gt;
 &lt;/project&gt;
 </pre>
-</div></div><h1 id="JAXRSClientSpringBoot-EnablingWebClients">Enabling
WebClients</h1><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+</div></div><h1 id="JAXRSClientSpringBoot-EnablingWebClients">Enabling
WebClients</h1><p><a shape="rect" href="http://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-CXFWebClientAPI">WebClient</a>
can be auto-wired with the help of <strong>EnableJaxRsWebClient</strong> annotation.</p><p>JAX-RS
providers (annotated with @Provider) and marked as Spring Components are added to WebClient.
The providers which are not marked as Spring Components can also be optionally auto-discovered.
WebClient can also be configured with optional headers such as Accept and Content-Type and
made thread-safe.</p><p>&#160;</p><div class="code panel pdl" style="border-width:
1px;"><div class="codeContent panelContent pdl">
 <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">package
sample.rs.client;
 
 import org.apache.cxf.jaxrs.client.WebClient;
@@ -201,7 +197,7 @@ public class SpringBootClientApplication
     }
     
 }</pre>
-</div></div><p>&#160;</p><h2 id="JAXRSClientSpringBoot-Configuration">Configuration</h2><p>&#160;</p><h1
id="JAXRSClientSpringBoot-EnablingProxyClients">Enabling ProxyClients</h1><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
+</div></div><p>&#160;</p><h1 id="JAXRSClientSpringBoot-EnablingProxyClients">Enabling
ProxyClients</h1><p><a shape="rect" href="http://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-Proxy-basedAPI">Proxy
Clients</a> can be auto-wired with the help of <strong>EnableJaxRsProxyClient</strong>
annotation.</p><p>It creates a proxy from the auto-discovered service class interface.</p><p>JAX-RS
providers (annotated with @Provider) and marked as Spring Components are added to proxy clients.
The providers which are not marked as Spring Components can also be optionally auto-discovered.
Proxy can also be configured with optional headers such as Accept and Content-Type (if JAX-RS
@Produces and/or @Consumes are missing or need to be overridden) and made thread-safe.</p><div
class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent
pdl">
 <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">package
sample.rs.client;
 
 import org.apache.cxf.jaxrs.client.spring.EnableJaxRsProxyClient;
@@ -233,7 +229,47 @@ public class SpringBootClientApplication
     }
 }
 </pre>
-</div></div><p>&#160;</p><h2 id="JAXRSClientSpringBoot-Configuration.1">Configuration</h2></div>
+</div></div><p>&#160;</p><p>If you prefer to specify a
proxy service interface directly in the client code you can drop EnableJaxRsProxyClient annotation
and provide a simple JaxRsProxyClientConfiguration extension instead:</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">package
sample.rs.client;
+
+import org.apache.cxf.jaxrs.client.spring.JaxRsProxyClientConfiguration;
+
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import sample.rs.service.HelloService;
+
+@SpringBootApplication
+public class SpringBootClientApplication {
+    
+    public static void main(String[] args) {
+        SpringApplication.run(SpringBootClientApplication.class, args);
+    }
+ 
+    @Bean
+    CommandLineRunner initProxyClientRunner(final HelloService client) {
+      
+      return new CommandLineRunner() {
+
+        @Override
+        public void run(String... runArgs) throws Exception {
+            System.out.println(client.sayHello("ApacheCxfProxyUser"));
+        }
+      };
+    }
+    
+    @Configuration
+    static class HeloServiceConfiguration extends JaxRsProxyClientConfiguration {
+        @Override
+        protected Class&lt;?&gt; getServiceClass() {
+            return HelloService.class;
+        }
+    }
+}</pre>
+</div></div><p>&#160;</p><h1 id="JAXRSClientSpringBoot-Configuration">Configuration</h1><p>The
configuration properties apply to both WebClient and Proxy configurations.</p><p><strong>cxf.jaxrs.client.address</strong>
is a required property which identifies a target address.</p><p><strong>cxf.jaxrs.client.thread-safe</strong>
property can be set to true to make the clients thread-safe.</p><p><strong>cxf.jaxrs.client.headers.accept</strong>
property can be used to set HTTP Accept header.</p><p><strong>cxf.jaxrs.client.headers.content-type</strong>
property can be used to set HTTP Content-Type header.</p><p><strong>cxf.jaxrs.client.classes-scan-packages</strong>
property can be used to auto-discover JAX-RS service class interfaces (for proxies) and providers
for proxies and web clients.</p></div>
            </div>
            <!-- Content -->
          </td>



Mime
View raw message