cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From build...@apache.org
Subject svn commit: r906526 - in /websites/production/cxf/content: cache/docs.pageCache docs/jax-rs-basics.html
Date Tue, 22 Apr 2014 16:47:18 GMT
Author: buildbot
Date: Tue Apr 22 16:47:17 2014
New Revision: 906526

Log:
Production update by buildbot for cxf

Modified:
    websites/production/cxf/content/cache/docs.pageCache
    websites/production/cxf/content/docs/jax-rs-basics.html

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

Modified: websites/production/cxf/content/docs/jax-rs-basics.html
==============================================================================
--- websites/production/cxf/content/docs/jax-rs-basics.html (original)
+++ websites/production/cxf/content/docs/jax-rs-basics.html Tue Apr 22 16:47:17 2014
@@ -118,17 +118,19 @@ Apache CXF -- JAX-RS Basics
          <td height="100%">
            <!-- Content -->
            <div class="wiki-content">
-<div id="ConfluenceContent"><p><span style="font-size:2em;font-weight:bold">
JAX-RS : Understanding the Basics </span></p><p></p><p>&#160;</p><p><style
type="text/css">/*<![CDATA[*/
-div.rbtoc1396468202782 {padding: 0px;}
-div.rbtoc1396468202782 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1396468202782 li {margin-left: 0px;padding-left: 0px;}
+<div id="ConfluenceContent"><span style="font-size:2em;font-weight:bold"> JAX-RS
: Understanding the Basics </span><p>&#160;</p><p>&#160;</p><p><style
type="text/css">/*<![CDATA[*/
+div.rbtoc1398185207084 {padding: 0px;}
+div.rbtoc1398185207084 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1398185207084 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style></p><div class="toc-macro rbtoc1396468202782">
+/*]]>*/</style></p><div class="toc-macro rbtoc1398185207084">
 <ul class="toc-indentation"><li><a shape="rect" href="#JAX-RSBasics-WhatisNewinJAX-RS2.0">What
is New in JAX-RS 2.0</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#JAX-RSBasics-Filters">Filters</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#JAX-RSBasics-Server">Server</a></li><li><a
shape="rect" href="#JAX-RSBasics-Client">Client</a></li></ul>
 </li><li><a shape="rect" href="#JAX-RSBasics-Interceptors">Interceptors</a></li><li><a
shape="rect" href="#JAX-RSBasics-DynamicFeatures">Dynamic Features</a></li><li><a
shape="rect" href="#JAX-RSBasics-Exceptions">Exceptions</a></li><li><a
shape="rect" href="#JAX-RSBasics-Suspendedinvocations">Suspended invocations</a></li><li><a
shape="rect" href="#JAX-RSBasics-Parameterconverters">Parameter converters</a></li><li><a
shape="rect" href="#JAX-RSBasics-Beanparameters">Bean parameters</a></li><li><a
shape="rect" href="#JAX-RSBasics-ResourceInfo">ResourceInfo</a></li><li><a
shape="rect" href="#JAX-RSBasics-Injectionintosubresources">Injection into subresources</a></li><li><a
shape="rect" href="#JAX-RSBasics-Updatestothematchingalgorithm">Updates to the matching
algorithm</a></li><li><a shape="rect" href="#JAX-RSBasics-Link">Link</a></li><li><a
shape="rect" href="#JAX-RSBasics-ClientAPI">Client API</a></li></ul>
-</li><li><a shape="rect" href="#JAX-RSBasics-Resourceclass">Resource class</a></li><li><a
shape="rect" href="#JAX-RSBasics-@Path">@Path</a></li><li><a shape="rect"
href="#JAX-RSBasics-HTTPMethod">HTTP Method</a></li><li><a shape="rect"
href="#JAX-RSBasics-Returntypes">Return types</a></li><li><a shape="rect"
href="#JAX-RSBasics-Exceptionhandling">Exception handling</a>
+</li><li><a shape="rect" href="#JAX-RSBasics-Resourceclass">Resource class</a></li><li><a
shape="rect" href="#JAX-RSBasics-@Path">@Path</a></li><li><a shape="rect"
href="#JAX-RSBasics-HTTPMethod">HTTP Method</a></li><li><a shape="rect"
href="#JAX-RSBasics-Returntypes">Return types</a></li><li><a shape="rect"
href="#JAX-RSBasics-ResponseStreaming">Response Streaming&#160;</a>
+<ul class="toc-indentation"><li><a shape="rect" href="#JAX-RSBasics-JAX-RSStreamingOutput">JAX-RS
StreamingOutput</a></li><li><a shape="rect" href="#JAX-RSBasics-CXFStreamingResponse">CXF
StreamingResponse</a></li></ul>
+</li><li><a shape="rect" href="#JAX-RSBasics-Exceptionhandling">Exception
handling</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#JAX-RSBasics-MappingexceptionsthrownfromCXFinterceptors">Mapping
exceptions thrown from CXF interceptors</a></li><li><a shape="rect" href="#JAX-RSBasics-CustomizingdefaultWebApplicationExceptionmapper">Customizing
default WebApplicationException mapper</a></li></ul>
 </li><li><a shape="rect" href="#JAX-RSBasics-DealingwithParameters">Dealing
with Parameters</a>
 <ul class="toc-indentation"><li><a shape="rect" href="#JAX-RSBasics-Parameterbeans">Parameter
beans</a></li></ul>
@@ -252,7 +254,34 @@ import java.lang.annotation.Target;
 public @interface PATCH { 
 }
 ]]></script>
-</div></div><h1 id="JAX-RSBasics-Returntypes">Return types</h1><p>Either
javax.ws.rs.core.Response or custom type can be returned. javax.ws.rs.core.Response can be
used to set the HTTP response code, headers and entity. JAX-RS MessageBodyWriters (see below)
are in charge of serializing the response entities, those which are returned directly or as
part of javax.ws.rs.core.Response.</p><h1 id="JAX-RSBasics-Exceptionhandling">Exception
handling</h1><p>One can either throw an unchecked WebApplicationException or return
Response with a proper error code set.<br clear="none"> The former option may be a better
one when no JAX-RS types can be added to method signatures.</p><p>For example
:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent
panelContent pdl">
+</div></div><h1 id="JAX-RSBasics-Returntypes">Return types</h1><p>Either
javax.ws.rs.core.Response or custom type can be returned. javax.ws.rs.core.Response can be
used to set the HTTP response code, headers and entity. JAX-RS MessageBodyWriters (see below)
are in charge of serializing the response entities, those which are returned directly or as
part of javax.ws.rs.core.Response.</p><h1 id="JAX-RSBasics-ResponseStreaming">Response
Streaming&#160;</h1><h2 id="JAX-RSBasics-JAX-RSStreamingOutput">JAX-RS StreamingOutput</h2><p><a
shape="rect" class="external-link" href="https://jax-rs-spec.java.net/nonav/2.0/apidocs/javax/ws/rs/core/StreamingOutput.html"
rel="nofollow">StreamingOutput</a> can be used to stream the data to the client,
for example:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@GET
+@Path(&quot;/books/pdf&quot;)
+@Produces(&quot;application/pdf&quot;)
+public StreamingOutput getPdf() {
+    return new StreamingOutput() {
+        public void write(final OutputStream os) {
+           // read chunks of data from PDF and write to OutputStream
+        }  
+    };
+}
+]]></script>
+</div></div><h2 id="JAX-RSBasics-CXFStreamingResponse">CXF StreamingResponse</h2><p>CXF
3.0.0 introduces <a shape="rect" class="external-link" href="https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/StreamingResponse.java">StreamingResponse</a>
extension. It can be used with the WebSocket transport or as a possible replacement for the
code working with StreamingOutput.</p><p><a shape="rect" class="external-link"
href="https://jax-rs-spec.java.net/nonav/2.0/apidocs/javax/ws/rs/core/StreamingOutput.html"
rel="nofollow">F</a>or example, consider that a number of resources need to be returned
as they become available:</p><div class="code panel pdl" style="border-width: 1px;"><div
class="codeContent panelContent pdl">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@GET
+@Path(&quot;/books&quot;)
+@Produces(&quot;application/xml&quot;)
+public StreamingResponse&lt;Book&gt; getBooks() {
+    return new StreamingResponse&lt;Book&gt;() {
+        public void writeTo(final Writer&lt;Book&gt; writer) {
+           writer.getEntityStream().write(&quot;&lt;Books&gt;&quot;.getBytes());
+           writer.write(new Book(&quot;CXF&quot;));
+           writer.write(new Book(&quot;JAX-RS&quot;));
+           writer.getEntityStream().write(&quot;&lt;/Books&gt;&quot;.getBytes());
+        }  
+    };
+}
+]]></script>
+</div></div><h1 id="JAX-RSBasics-Exceptionhandling">Exception handling</h1><p>One
can either throw an unchecked WebApplicationException or return Response with a proper error
code set.<br clear="none"> The former option may be a better one when no JAX-RS types
can be added to method signatures.</p><p>For example :</p><div class="code
panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
 <script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[@Path(&quot;/customerservice/&quot;)
 public class CustomerService {
 



Mime
View raw message