Author: buildbot
Date: Fri Apr  6 13:56:41 2018
New Revision: 1027960

Log:
Production update by buildbot for cxf

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

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

Modified: websites/production/cxf/content/docs/jax-rs-advanced-features.html
==============================================================================
--- websites/production/cxf/content/docs/jax-rs-advanced-features.html 
(original)
+++ websites/production/cxf/content/docs/jax-rs-advanced-features.html Fri Apr  
6 13:56:41 2018
@@ -32,8 +32,8 @@
 <link type="text/css" rel="stylesheet" 
href="/resources/highlighter/styles/shThemeCXF.css">
 
 <script src='/resources/highlighter/scripts/shCore.js'></script>
-<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
 <script src='/resources/highlighter/scripts/shBrushJava.js'></script>
+<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
 <script>
   SyntaxHighlighter.defaults['toolbar'] = false;
   SyntaxHighlighter.all();
@@ -117,28 +117,28 @@ Apache CXF -- JAX-RS Advanced Features
          <td height="100%">
            <!-- Content -->
            <div class="wiki-content">
-<div 
id="ConfluenceContent"><p>&#160;</p><p>&#160;</p><p>&#160;</p><p>&#160;</p><p>&#160;<span
 style="font-size:2em;font-weight:bold">JAX-RS : Advanced Features</span>
+<div id="ConfluenceContent"><p><span 
style="font-size:2em;font-weight:bold">JAX-RS : Advanced Features</span>
 
 
-&#160;</p><p>&#160;</p><p>&#160;</p><p>&#160;</p><p>&#160;</p><p><style 
type="text/css">/*<![CDATA[*/
-div.rbtoc1508777363208 {padding: 0px;}
-div.rbtoc1508777363208 ul {list-style: disc;margin-left: 0px;}
-div.rbtoc1508777363208 li {margin-left: 0px;padding-left: 0px;}
+&#160;</p><p><style type="text/css">/*<![CDATA[*/
+div.rbtoc1523022963075 {padding: 0px;}
+div.rbtoc1523022963075 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1523022963075 li {margin-left: 0px;padding-left: 0px;}
 
-/*]]>*/</style></p><div class="toc-macro rbtoc1508777363208">
+/*]]>*/</style></p><div class="toc-macro rbtoc1523022963075">
 <ul class="toc-indentation"><li><a shape="rect" 
href="#JAX-RSAdvancedFeatures-JMSSupport">JMS Support</a>
 <ul class="toc-indentation"><li><a shape="rect" 
href="#JAX-RSAdvancedFeatures-Endpoints">Endpoints</a></li><li><a shape="rect" 
href="#JAX-RSAdvancedFeatures-Client">Client</a></li></ul>
 </li><li><a shape="rect" 
href="#JAX-RSAdvancedFeatures-AdvancedSearch">Advanced Search</a></li><li><a 
shape="rect" href="#JAX-RSAdvancedFeatures-Onewayinvocations">Oneway 
invocations</a></li><li><a shape="rect" 
href="#JAX-RSAdvancedFeatures-SupportforContinuations">Support for 
Continuations</a></li><li><a shape="rect" 
href="#JAX-RSAdvancedFeatures-Server-sidecaching">Server-side 
caching</a></li><li><a shape="rect" 
href="#JAX-RSAdvancedFeatures-RESTfulserviceswithoutannotations">RESTful 
services without annotations</a>
 <ul class="toc-indentation"><li><a shape="rect" 
href="#JAX-RSAdvancedFeatures-Configuration">Configuration</a></li></ul>
 </li></ul>
-</div><h1 id="JAX-RSAdvancedFeatures-JMSSupport">JMS Support</h1><p>CXF has 
been designed such that multiple transports can be supported for a given 
endpoint. CXF JAX-RS endpoint and proxies can optionally <br clear="none"> 
support the JMS transport.</p><h2 
id="JAX-RSAdvancedFeatures-Endpoints">Endpoints</h2><p>If you would like your 
JAXRS endpoint be capable of serving not only HTTP but also JMS requests then 
you need to specify a JMS transportId, example:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div><h1 id="JAX-RSAdvancedFeatures-JMSSupport">JMS Support</h1><p>CXF has 
been designed such that multiple transports can be supported for a given 
endpoint. CXF JAX-RS endpoint and proxies can optionally support the JMS 
transport.</p><h2 id="JAX-RSAdvancedFeatures-Endpoints">Endpoints</h2><p>If you 
would like your JAXRS endpoint be capable of serving not only HTTP but also JMS 
requests then you need to specify a JMS transportId, example:</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;">&lt;jaxrs:server serviceName="s:BookService" 
transportId="http://cxf.apache.org/transports/jms"; address="/"&gt;
  &lt;jaxrs:serviceBeans&gt;
    &lt;bean class="org.apache.cxf.systest.jaxrs.JMSBookStore"/&gt;
  &lt;/jaxrs:serviceBeans&gt;
 &lt;/jaxrs:server&gt;
 </pre>
-</div></div><p>Additionally, JMS queue or topic <a shape="rect" 
href="http://cxf.apache.org/docs/using-the-jmsconfigfeature.html";>configuration</a>
 needs to be done, for example, please see this <a shape="rect" 
class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/jms_server_config.xml";>beans.xml</a>.
 Please note how a serviceName attribute is used to specify a service QName for 
a jaxrs endpoint (default is {<a shape="rect" class="external-link" 
href="http://reverse.package.name"; 
rel="nofollow">http://reverse.package.name</a>}ServiceClassName), this service 
name is <br clear="none"> used to configure a jms destination.</p><p>Here is 
the actual <a shape="rect" class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSJmsTest.java";>test</a>.</p><p>Here
 are JMS properties which can help with matching a required method on the JAXRS 
endp
 oint :</p><ul class="alternate"><li>"Content-Type" : default is 
"text/xml"</li><li>"Accept" : default is 
"<strong>/</strong>"</li><li>"OnewayMessage" : default is 
"false"</li><li>"org.apache.cxf.message.Message.REQUEST_URI" : default is 
"/"</li><li>"org.apache.cxf.message.Message.HTTP_REQUEST_METHOD" : default is 
"POST"</li></ul><p>If JMS messages are sent to topic destinations then one has 
to either set a "OnewayMessage" property or ensure that target JAXRS methods 
are annotated with org.apache.cxf.jaxrs.ext.Oneway.</p><p>As far as REQUEST_URI 
is concerned, it is initially matched against a jaxrs:server/@address. So if 
REQUEST_URI is not set or set to "/" then jaxrs:server/@address has to be set 
to "/". If REQUEST_URI is set to "/bar/foo" and<br clear="none"> 
jaxrs:server/@address is set to "/bar" then it will be '/foo' which will be 
used to find a root resource class and its method.</p><p>By referencing a bean 
such as 'org.apache.cxf.systest.jaxrs.JMSBookStore' from multiple jaxrs
  endpoints you can ensure that both HTTP and JMS requests are handled by the 
same service bean. In such cases you may want to use a CXF JAXRS specific <a 
shape="rect" class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ProtocolHeaders.java";>ProtocolHeaders</a>
 context which will let you get either HTTP or JMS headers.</p><h2 
id="JAX-RSAdvancedFeatures-Client">Client</h2><p>Starting from CXF 2.5.5 and 
CXF 2.6.2 it is possible to use the client proxies to invoke on JMS endpoints. 
All one needs to do is to provide a JMS endpoint address and then continue 
working with the proxy as usual. For example:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>Additionally, JMS queue or topic <a shape="rect" 
href="http://cxf.apache.org/docs/using-the-jmsconfigfeature.html";>configuration</a>
 needs to be done, for example, please see this <a shape="rect" 
class="external-link" 
href="https://github.com/apache/cxf/blob/master/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/jms_server_config.xml";
 rel="nofollow">beans.xml</a>. Please note how a serviceName attribute is used 
to specify a service QName for a jaxrs endpoint (default is {<a shape="rect" 
class="external-link" href="http://reverse.package.name"; 
rel="nofollow">http://reverse.package.name</a>}ServiceClassName), this service 
name is used to configure a jms destination.</p><p>Here is the actual <a 
shape="rect" class="external-link" 
href="https://github.com/apache/cxf/blob/master/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jms/JAXRSJmsTest.java";
 rel="nofollow">test</a>.</p><p>Here are JMS properties which can help with 
matching a required method o
 n the JAXRS endpoint :</p><ul class="alternate"><li>"Content-Type" : default 
is "text/xml"</li><li>"Accept" : default is 
"<strong>/</strong>"</li><li>"OnewayMessage" : default is 
"false"</li><li>"org.apache.cxf.message.Message.REQUEST_URI" : default is 
"/"</li><li>"org.apache.cxf.message.Message.HTTP_REQUEST_METHOD" : default is 
"POST"</li></ul><p>If JMS messages are sent to topic destinations then one has 
to either set a "OnewayMessage" property or ensure that target JAXRS methods 
are annotated with org.apache.cxf.jaxrs.ext.Oneway.</p><p>As far as REQUEST_URI 
is concerned, it is initially matched against a jaxrs:server/@address. So if 
REQUEST_URI is not set or set to "/" then jaxrs:server/@address has to be set 
to "/". If REQUEST_URI is set to "/bar/foo" and<br clear="none"> 
jaxrs:server/@address is set to "/bar" then it will be '/foo' which will be 
used to find a root resource class and its method.</p><p>By referencing a bean 
such as 'org.apache.cxf.systest.jaxrs.JMSBookStore' fro
 m multiple jaxrs endpoints you can ensure that both HTTP and JMS requests are 
handled by the same service bean. In such cases you may want to use a CXF JAXRS 
specific <a shape="rect" class="external-link" 
href="https://github.com/apache/cxf/blob/master/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ProtocolHeaders.java";
 rel="nofollow">ProtocolHeaders</a> context which will let you get either HTTP 
or JMS headers.</p><h2 
id="JAX-RSAdvancedFeatures-Client">Client</h2><p>Starting from CXF 2.5.5 and 
CXF 2.6.2 it is possible to use the client proxies to invoke on JMS endpoints. 
All one needs to do is to provide a JMS endpoint address and then continue 
working with the proxy as usual. 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" 
style="font-size:12px;">// setup the the client
 String endpointAddressUrlEncoded = 
"jms:jndi:dynamicQueues/test.jmstransport.text"
              + 
"?jndiInitialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory"
@@ -151,24 +151,24 @@ Book book = client.getBook("123");
 assertEquals("Get a wrong response code.", 200, 
WebClient.client(client).getResponse().getStatus());
 assertEquals("Get a wrong book id.", 123, book.getId());
 </pre>
-</div></div><p>The client runtime will set up the JMS properties described in 
the previous section according to JAX-RS and other annotations (such as 
org.apache.cxf.jaxrs.ext.Oneway) available in JMSBookStore resource 
class.</p><h1 id="JAX-RSAdvancedFeatures-AdvancedSearch">Advanced 
Search</h1><p>Please see <a shape="rect" href="jax-rs-search.html">JAX-RS 
Search</a> for more information</p><h1 
id="JAX-RSAdvancedFeatures-Onewayinvocations">Oneway 
invocations</h1><p>Resource methods with an org.apache.cxf.jaxrs.ext.Oneway 
annotation will be invoked oneway with the original request returning 202 HTTP 
status. HTTP or JMS clients can also add a "OnewayRequest" header if adding 
Oneway annotations is not an option.</p><h1 
id="JAX-RSAdvancedFeatures-SupportforContinuations">Support for 
Continuations</h1><p>Please see <a shape="rect" class="external-link" 
href="http://sberyozkin.blogspot.com/2008/12/continuations-in-cxf.html"; 
rel="nofollow">this blog entry</a> describing how JAXRS (and indee
 d) JAXWS services can rely on the CXF Continuations API.</p><p>Please see the 
<a shape="rect" href="continuations.html">Continuations</a> page for more 
information.</p><h1 id="JAX-RSAdvancedFeatures-Server-sidecaching">Server-side 
caching</h1><p><a shape="rect" class="external-link" 
href="http://ehcache.org/documentation/web_caching.html"; 
rel="nofollow">Ehcache-Web</a> and other similar frameworks can be used to 
provide an advanced support for<br clear="none"> the server-side 
caching.</p><p>For example, the only thing you need to do to interpose 
Ehcache-Web on top of CXF JAX-RS endpoints is to add the following declarations 
to the web.xml, assuming the name of the war is 'ehcache-cxf':</p><div 
class="code panel pdl" style="border-width: 1px;"><div class="codeContent 
panelContent pdl">
+</div></div><p>The client runtime will set up the JMS properties described in 
the previous section according to JAX-RS and other annotations (such as 
org.apache.cxf.jaxrs.ext.Oneway) available in JMSBookStore resource 
class.</p><h1 id="JAX-RSAdvancedFeatures-AdvancedSearch">Advanced 
Search</h1><p>Please see <a shape="rect" href="jax-rs-search.html">JAX-RS 
Search</a> for more information</p><h1 
id="JAX-RSAdvancedFeatures-Onewayinvocations">Oneway 
invocations</h1><p>Resource methods with an org.apache.cxf.jaxrs.ext.Oneway 
annotation will be invoked oneway with the original request returning 202 HTTP 
status. HTTP or JMS clients can also add a "OnewayRequest" header if adding 
Oneway annotations is not an option.</p><h1 
id="JAX-RSAdvancedFeatures-SupportforContinuations">Support for 
Continuations</h1><p>Please see <a shape="rect" class="external-link" 
href="http://sberyozkin.blogspot.com/2008/12/continuations-in-cxf.html"; 
rel="nofollow">this blog entry</a> describing how JAX-RS (and inde
 ed) JAX-WS services can rely on the CXF Continuations API.</p><p>Please see 
the <a shape="rect" href="continuations.html">Continuations</a> page for more 
information.</p><h1 id="JAX-RSAdvancedFeatures-Server-sidecaching">Server-side 
caching</h1><p><a shape="rect" class="external-link" 
href="http://ehcache.org/documentation/web_caching.html"; 
rel="nofollow">Ehcache-Web</a> and other similar frameworks can be used to 
provide an advanced support for the server-side caching.</p><p>For example, the 
only thing you need to do to interpose Ehcache-Web on top of CXF JAX-RS 
endpoints is to add the following declarations to the web.xml, assuming the 
name of the war is 'ehcache-cxf':</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;">&lt;context-param&gt;
-        &lt;param-name&gt;webAppRootKey&lt;/param-name&gt;
-        &lt;param-value&gt;ehcache-cxf&lt;/param-value&gt;
-    &lt;/context-param&gt;
+    &lt;param-name&gt;webAppRootKey&lt;/param-name&gt;
+    &lt;param-value&gt;ehcache-cxf&lt;/param-value&gt;
+&lt;/context-param&gt;
 &lt;filter&gt;
-        &lt;filter-name&gt;SimplePageCachingFilter&lt;/filter-name&gt;
-        
&lt;filter-class&gt;net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter&lt;/filter-class&gt;
-        &lt;init-param&gt;
-            &lt;param-name&gt;varyHeader&lt;/param-name&gt;
-            &lt;param-value&gt;true&lt;/param-value&gt;
-        &lt;/init-param&gt;
-    &lt;/filter&gt;
+    &lt;filter-name&gt;SimplePageCachingFilter&lt;/filter-name&gt;
+    
&lt;filter-class&gt;net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter&lt;/filter-class&gt;
+    &lt;init-param&gt;
+        &lt;param-name&gt;varyHeader&lt;/param-name&gt;
+        &lt;param-value&gt;true&lt;/param-value&gt;
+    &lt;/init-param&gt;
+&lt;/filter&gt;
     
-    &lt;filter-mapping&gt;
-        &lt;filter-name&gt;SimplePageCachingFilter&lt;/filter-name&gt;
-        &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
-    &lt;/filter-mapping&gt;
+&lt;filter-mapping&gt;
+    &lt;filter-name&gt;SimplePageCachingFilter&lt;/filter-name&gt;
+    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
+&lt;/filter-mapping&gt;
 </pre>
 </div></div><p>Please see the <a shape="rect" class="external-link" 
href="http://ehcache.org/documentation/web_caching.html"; 
rel="nofollow">Ehcache-Web</a> page for more information on how to configure 
it, here is one example:</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;">&lt;ehcache 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
@@ -193,7 +193,7 @@ assertEquals("Get a wrong book id.", 123
         memoryStoreEvictionPolicy="LFU" /&gt;
 &lt;/ehcache&gt;
 </pre>
-</div></div><p>This configuration has to be saved in ehcache-web.xml file and 
available as a class-path resource starting from the root.</p><h1 
id="JAX-RSAdvancedFeatures-RESTfulserviceswithoutannotations">RESTful services 
without annotations</h1><p>One of the latest CXF JAX-RS extensions allows users 
to provide external models with the information which the runtime typically 
gets from JAX-RS annotations like @Path, @PathParam, @Consumes, @Produces, 
etc.<br clear="none"> There might be a number of cases when it can be 
advantageous to describe how a given resource can be exposed as a RESTful 
service without actually modifying this resource. For example, when new dynamic 
interface implementations are registered, when no source code can be modified, 
when the cost of future updates (for ex, modifying the value of @Path 
annotations) is considered to be expensive, etc.</p><p>User model schema type 
is described in the <a shape="rect" class="external-link" 
href="http://svn.apache.org/repos/
 
asf/cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs-common.xsd">jaxrs.xsd</a>.</p><p>The
 top-level 'model' element can have 'resource' children elements. A 'resource' 
element describes a resource class which can be either a root resource class or 
a sub-resource one and it can have attributes describing 'path', 'produces' and 
'consumes' values and it has a 'name' attribute which identifies a 
fully-qualified resource class. <br clear="none"> A 'resource' element can have 
a number of 'operation' elements pointing to resource methods (with its 'name' 
attribute) and can have 'path', 'produces', 'consumes' and 'verb' (HTTP method) 
values. An 'operation' element which has no 'verb' attribute is treated as a 
sub-resource locator - a corresponding resource class has to be available in 
the model with its 'name' attribute matching the return type's name of this 
operation.<br clear="none"> Every operation can have a number of 'param' 
elements. A 'param' element should have its 'nam
 e' attribute matching a corresponding parameter name in the class resource 
method. Its 'type' can have the following values : 'PATH', 'QUERY', 'CONTEXT', 
'HEADER', 'MATRIX', 'COOKIE', 'FORM' or 'REQUEST_BODY'. Parameters 
corresponding to response types do not have to be described. It can also have 
'defaultValue' and 'encoded' values being set.</p><p>Starting from CXF 
2.3.2-SNAPSHOT a "oneway" attribute can also be applied to individual 
operations.</p><p>Here is an example :</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+</div></div><p>This configuration has to be saved in ehcache-web.xml file and 
available as a class-path resource starting from the root.</p><h1 
id="JAX-RSAdvancedFeatures-RESTfulserviceswithoutannotations">RESTful services 
without annotations</h1><p>One of the latest CXF JAX-RS extensions allows users 
to provide external models with the information which the runtime typically 
gets from JAX-RS annotations like @Path, @PathParam, @Consumes, @Produces, 
etc.<br clear="none"> There might be a number of cases when it can be 
advantageous to describe how a given resource can be exposed as a RESTful 
service without actually modifying this resource. For example, when new dynamic 
interface implementations are registered, when no source code can be modified, 
when the cost of future updates (for ex, modifying the value of @Path 
annotations) is considered to be expensive, etc.</p><p>User model schema type 
is described in the <a shape="rect" class="external-link" 
href="https://github.com/apache/cx
 f/blob/master/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs-common.xsd" 
rel="nofollow">jaxrs.xsd</a>.</p><p>The top-level 'model' element can have 
'resource' children elements. A 'resource' element describes a resource class 
which can be either a root resource class or a sub-resource one and it can have 
attributes describing 'path', 'produces' and 'consumes' values and it has a 
'name' attribute which identifies a fully-qualified resource class. <br 
clear="none"> A 'resource' element can have a number of 'operation' elements 
pointing to resource methods (with its 'name' attribute) and can have 'path', 
'produces', 'consumes' and 'verb' (HTTP method) values. An 'operation' element 
which has no 'verb' attribute is treated as a sub-resource locator - a 
corresponding resource class has to be available in the model with its 'name' 
attribute matching the return type's name of this operation.<br clear="none"> 
Every operation can have a number of 'param' elements. A 'param' element shoul
 d have its 'name' attribute matching a corresponding parameter name in the 
class resource method. Its 'type' can have the following values : 'PATH', 
'QUERY', 'CONTEXT', 'HEADER', 'MATRIX', 'COOKIE', 'FORM' or 'REQUEST_BODY'. 
Parameters corresponding to response types do not have to be described. It can 
also have 'defaultValue' and 'encoded' values being set.</p><p>Starting from 
CXF 2.3.2-SNAPSHOT a "oneway" attribute can also be applied to individual 
operations.</p><p>Here is an example :</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;">&lt;model xmlns="http://cxf.apache.org/jaxrs"&gt;
   &lt;resource name="org.apache.cxf.systest.jaxrs.BookStoreNoAnnotations" 
path="bookstore"
     produces="application/json" consumes="application/json"&gt;
@@ -215,7 +215,7 @@ assertEquals("Get a wrong book id.", 123
   &lt;/resource&gt;
 &lt;/model&gt;
 </pre>
-</div></div><p>This model describes two resources, BookStoreNoAnnotations and 
ChapterNoAnnotations. The BookStoreNoAnnotations resource has three resource 
operations, 'getBook', 'getBookChapter' and 'updateBook'. Note that the 
'getBookChapter' operation element (described in the model) has no 'verb' 
attribute so runtime will identify it as a subresource locator.<br 
clear="none"> The runtime will introspect the <a shape="rect" 
class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreNoAnnotations.java";>org.apache.cxf.systest.jaxrs.BookStoreNoAnnotations</a>
 class and check the return types for both 'getBook' and 'getBookChapter' 
methods. BookStoreNoAnnotations.getBookChapter() method's return type is <a 
shape="rect" class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ChapterNoAnnotations.java";>org.apache.cxf.systest.jaxrs.ChapterN
 oAnnotations</a> so the model will be checked if it contains the resource 
element with the 'name' attribute equal to 
'org.apache.cxf.systest.jaxrs.ChapterNoAnnotations'. After this resource has 
been found, the ChapterNoAnnotations class is recognized as a sub-resource and 
then its 'getItself' method is checked.</p><p>Additionally the 
BookStoreNoAnnotations resource declares that all its resource methods produce 
'application/json' mediaTypes, while its 'getBook' method overrides its with 
its own 'produces' value. BookStoreNoAnnotations resource also has a 'consumes' 
attribute which requires all of the resource methods (such as 'updateBook') to 
consume "application/json" formats. The ChapterNoAnnotations 'updateChapter' 
resource operation requires 'application/xml' formats.</p><p>You can use a 
comma-seperated list of media type values if needed, for example, 
produces("application/xml;charset=utf-8,application/json") or 
consumes("application/xml;charset=utf-8,application/json").</p><p>
 Please also see this <a shape="rect" class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources2.xml";>model
 file</a> for an example. Providing this file will let all implementations of 
the interface described in this model instance be exposed as RESTful services 
supported by the JAX-RS runtime.</p><h2 
id="JAX-RSAdvancedFeatures-Configuration">Configuration</h2><p>A user model can 
be referenced in a number of ways. It can be embedded in a jaxrs:server 
endpoint definition or linked to through a jaxrs:server modelRef attribute as a 
classpath resource.</p><p>Please see this <a shape="rect" class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml";>bean</a>
 Spring configuration file, look at jaxrs server beans with 'bookservice6' and 
'bookservice7' names.</p><p>Note that when registering a model from Spring you 
do not need to decla
 re a jaxrs server serviceBeans section - the runtime will instantiate the 
beans itself. If you do need to inject certain properties into your service 
bean from Spring then you do need to declare a service bean too. In this case 
this bean will be instantiated twice - once by the runtime during the model 
introspection and once by Spring, however in the end it will be the bean 
created by Spring that will be used, the one created by the runtime will be 
removed.<br clear="none"> You can avoid this double instantiation by having 
your model describing the interfaces which the actual root resource beans will 
implement. In this case only Spring will create a bean and the runtime will 
apply the model description to this injected bean. Note that if Spring 
proxifies your bean (for example by applying transaction aspects to it) then 
the model does have to describe an interface for a match between the model and 
the injected bean proxy to succeed.</p><p>Please have a look at <a shape="rect" 
class=
 "external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml";>this
 Spring bean</a>. The jaxrs endpoint with id 'bookservice2' will have 
BookStoreWithNoAnnotations created twice but it will be the Spring created 
BookStoreWithNoAnnotations bean that will serve as a resource class instance. 
The jaxrs endpoint with id 'bookservice3' will have 
BookStoreWithNoAnnotationsImpl class instantiated only by Spring, with the 
model describing BookStoreWithNoAnnotationsInterface only that this class 
implements.</p><p>You can also register a model programmatically, for example 
:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
+</div></div><p>This model describes two resources, BookStoreNoAnnotations and 
ChapterNoAnnotations. The BookStoreNoAnnotations resource has three resource 
operations, 'getBook', 'getBookChapter' and 'updateBook'. Note that the 
'getBookChapter' operation element (described in the model) has no 'verb' 
attribute so runtime will identify it as a subresource locator.<br 
clear="none"> The runtime will introspect the <a shape="rect" 
class="external-link" 
href="https://github.com/apache/cxf/blob/master/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreNoAnnotations.java";
 rel="nofollow">org.apache.cxf.systest.jaxrs.BookStoreNoAnnotations</a> class 
and check the return types for both 'getBook' and 'getBookChapter' methods. 
BookStoreNoAnnotations.getBookChapter() method's return type is <a shape="rect" 
class="external-link" 
href="https://github.com/apache/cxf/blob/master/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ChapterNoAnnotations.java";
 rel="nofollow">org.apa
 che.cxf.systest.jaxrs.ChapterNoAnnotations</a> so the model will be checked if 
it contains the resource element with the 'name' attribute equal to 
'org.apache.cxf.systest.jaxrs.ChapterNoAnnotations'. After this resource has 
been found, the ChapterNoAnnotations class is recognized as a sub-resource and 
then its 'getItself' method is checked.</p><p>Additionally the 
BookStoreNoAnnotations resource declares that all its resource methods produce 
'application/json' mediaTypes, while its 'getBook' method overrides its with 
its own 'produces' value. BookStoreNoAnnotations resource also has a 'consumes' 
attribute which requires all of the resource methods (such as 'updateBook') to 
consume "application/json" formats. The ChapterNoAnnotations 'updateChapter' 
resource operation requires 'application/xml' formats.</p><p>You can use a 
comma-separated list of media type values if needed, for example, 
produces("application/xml;charset=utf-8,application/json") or 
consumes("application/xml;charset=ut
 f-8,application/json").</p><p>Please also see this <a shape="rect" 
class="external-link" 
href="https://github.com/apache/cxf/blob/master/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/resources/resources2.xml";
 rel="nofollow">model file</a> for an example. Providing this file will let all 
implementations of the interface described in this model instance be exposed as 
RESTful services supported by the JAX-RS runtime.</p><h2 
id="JAX-RSAdvancedFeatures-Configuration">Configuration</h2><p>A user model can 
be referenced in a number of ways. It can be embedded in a jaxrs:server 
endpoint definition or linked to through a jaxrs:server modelRef attribute as a 
classpath resource.</p><p>Please see this <a shape="rect" class="external-link" 
href="https://github.com/apache/cxf/blob/master/systests/jaxrs/src/test/resources/jaxrs/WEB-INF/beans.xml";
 rel="nofollow">bean</a> Spring configuration file, look at jaxrs server beans 
with 'bookservice6' and 'bookservice7' names.</p><p>Note that w
 hen registering a model from Spring you do not need to declare a jaxrs server 
serviceBeans section - the runtime will instantiate the beans itself. If you do 
need to inject certain properties into your service bean from Spring then you 
do need to declare a service bean too. In this case this bean will be 
instantiated twice - once by the runtime during the model introspection and 
once by Spring, however in the end it will be the bean created by Spring that 
will be used, the one created by the runtime will be removed.<br clear="none"> 
You can avoid this double instantiation by having your model describing the 
interfaces which the actual root resource beans will implement. In this case 
only Spring will create a bean and the runtime will apply the model description 
to this injected bean. Note that if Spring proxifies your bean (for example by 
applying transaction aspects to it) then the model does have to describe an 
interface for a match between the model and the injected bean proxy to
  succeed.</p><p>Please have a look at <a shape="rect" class="external-link" 
href="https://github.com/apache/cxf/blob/master/systests/jaxrs/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml";
 rel="nofollow">this Spring bean</a>. The jaxrs endpoint with id 'bookservice2' 
will have BookStoreWithNoAnnotations created twice but it will be the Spring 
created BookStoreWithNoAnnotations bean that will serve as a resource class 
instance. The jaxrs endpoint with id 'bookservice3' will have 
BookStoreWithNoAnnotationsImpl class instantiated only by Spring, with the 
model describing BookStoreWithNoAnnotationsInterface only that this class 
implements.</p><p>You can also register a model programmatically, 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" 
style="font-size:12px;">JAXRSServerFactoryBean sf = new 
JAXRSServerFactoryBean();
             sf.setAddress("http://localhost:9080/";);
 String modelRef = 
"classpath:/org/apache/cxf/systest/jaxrs/resources/resources2.xml";
@@ -227,34 +227,33 @@ sf.setModelRef(modelRef);
 // register an actual bean only if the model describes interfaces
 sf.setServiceBeans(new BookStoreNoAnnotationsImpl());
 </pre>
-</div></div><p>Please also see <a shape="rect" class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java";>this
 system test</a> for the example of how model beans like UserResource can be 
created and registered programmatically.</p><p>Similarly, you can register a 
user model on the client side, either from jaxrs:client or programmatically, 
example :</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
+</div></div><p>Please also see <a shape="rect" class="external-link" 
href="https://github.com/apache/cxf/blob/master/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerUserResourceTest.java";
 rel="nofollow">this system test</a> for the example of how model beans like 
UserResource can be created and registered programmatically.</p><p>Similarly, 
you can register a user model on the client side, either from jaxrs:client or 
programmatically, example :</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;">JAXRSClientFactoryBean cf = new 
JAXRSClientFactoryBean();
 cf.setAddress("http://localhost:9080/";);
 String modelRef = 
"classpath:/org/apache/cxf/systest/jaxrs/resources/resources2.xml";
 sf.setModelRef(modelRef);
 BookStoreNoAnnotations proxy = cf.create(BookStoreNoAnnotations.class);
 </pre>
-</div></div><p>At the moment it is only possible to register a user model with 
CXFNonSpringJAXRSServlet using the latest 2.2.3-SNAPSHOT like the way it is 
done in this <a shape="rect" class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml";>web.xml</a>.
 See CXFServlet3 and CXFServlet4 servlet declarations. Note that CXFServlet4 
registers a model containing interfaces so it also registers a 
BookStoreNoAnnotationsImpl service class.</p><p>The workaround is to create a 
custom servlet :</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
+</div></div><p>At the moment it is only possible to register a user model with 
CXFNonSpringJAXRSServlet using the latest 2.2.3-SNAPSHOT like the way it is 
done in this <a shape="rect" class="external-link" 
href="https://github.com/apache/cxf/blob/master/systests/jaxrs/src/test/resources/jaxrs_non_spring/WEB-INF/web.xml";
 rel="nofollow">web.xml</a>. See CXFServlet3 and CXFServlet4 servlet 
declarations. Note that CXFServlet4 registers a model containing interfaces so 
it also registers a BookStoreNoAnnotationsImpl service class.</p><p>The 
workaround is to create a custom servlet :</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;">public class JAXRSUserModelServlet extends 
CXFNonSpringJaxrsServlet  {
 
-@Override
-public void loadBus(ServletConfig servletConfig) throws ServletException {
-
-super.loadBus(servletConfig);
-
-JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
-String address = servletConfig.getInitParameter(SERVICE_ADDRESS_PARAM); 
//jaxrs.address
-if (address == null) {
-address = "/";
-}
-sf.setAddress(address);
-
-// modelRef needs to start from 'classpath:', ex 
'classpath:/WEB-INF/models/model1.xml
-String modelRef = servletConfig.getInitParameter("user.model");
-sf.setModelRef(modelRef);
-sf.create();
-}
-</pre>
+    @Override
+    public void loadBus(ServletConfig servletConfig) throws ServletException {
+        super.loadBus(servletConfig);
+
+        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
+        String address = 
servletConfig.getInitParameter(SERVICE_ADDRESS_PARAM); //jaxrs.address
+        if (address == null) {
+            address = "/";
+        }
+        sf.setAddress(address);
+
+        // modelRef needs to start from 'classpath:', ex 
'classpath:/WEB-INF/models/model1.xml
+        String modelRef = servletConfig.getInitParameter("user.model");
+        sf.setModelRef(modelRef);
+        sf.create();
+    }
+} </pre>
 </div></div></div>
            </div>
            <!-- Content -->


Reply via email to