You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2013/06/24 19:10:57 UTC

svn commit: r867253 [20/46] - in /websites/production/cxf/content: ./ 2008/04/28/ 2008/06/20/ 2009/02/10/ 2009/08/04/ cache/ docs/ docs/cxf-architecture.thumbs/ docs/cxf-dependency-graphs.thumbs/ docs/logbrowser-configuration.thumbs/ docs/logbrowser-so...

Modified: websites/production/cxf/content/docs/jax-rs-client-api.html
==============================================================================
--- websites/production/cxf/content/docs/jax-rs-client-api.html (original)
+++ websites/production/cxf/content/docs/jax-rs-client-api.html Mon Jun 24 17:10:51 2013
@@ -25,6 +25,18 @@
 <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
 <meta name="keywords" content="business integration, EAI, SOA, Service Oriented Architecture, web services, SOAP, JBI, JMS, WSDL, XML, EDI, Electronic Data Interchange, standards support, integration standards, application integration, middleware, software, solutions, services, CXF, open source">
 <meta name="description" content="Apache CXF, Services Framework - JAX-RS Client API">
+
+  <link href='http://cxf.apache.org/resources/highlighter/styles/shCore.css' rel='stylesheet' type='text/css' />
+  <link href='http://cxf.apache.org/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet' type='text/css' />
+  <script src='http://cxf.apache.org/resources/highlighter/scripts/shCore.js' type='text/javascript'></script>
+  <script src='http://cxf.apache.org/resources/highlighter/scripts/shBrushJava.js' type='text/javascript'></script>
+  <script src='http://cxf.apache.org/resources/highlighter/scripts/shBrushXml.js' type='text/javascript'></script>
+  
+  <script type="text/javascript">
+  SyntaxHighlighter.defaults['toolbar'] = false;
+  SyntaxHighlighter.all();
+  </script>
+ 
     <title>
 Apache CXF -- JAX-RS Client API
     </title>
@@ -42,19 +54,15 @@ Apache CXF -- JAX-RS Client API
     <td id="cell-1-0">&nbsp;</td>
     <td id="cell-1-1">&nbsp;</td>
     <td id="cell-1-2">
-      <div style="padding: 5px;">
-        <div id="banner">
-          <!-- Banner -->
-<div id="banner-content">
+      <!-- Banner -->
+<div class="banner" id="banner"><p>
 <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="left" colspan="1" nowrap>
 <a shape="rect" href="http://cxf.apache.org/" title="Apache CXF"><span style="font-weight: bold; font-size: 170%; color: white">Apache CXF</span></a>
 </td><td align="right" colspan="1" nowrap>
 <a shape="rect" href="http://www.apache.org/" title="The Apache Sofware Foundation"><img border="0" alt="ASF Logo" src="http://cxf.apache.org/images/asf-logo.png"></a>
 </td></tr></table>
-</div>
-          <!-- Banner -->
-        </div>
-      </div>
+</p></div>
+      <!-- Banner -->
       <div id="top-menu">
         <table border="0" cellpadding="1" cellspacing="0" width="100%">
           <tr>
@@ -94,7 +102,7 @@ Apache CXF -- JAX-RS Client API
 
 
 <hr>
-<ul class="alternate" type="square"><li>Search
+<ul class="alternate" type="square"><li>Search<br clear="none">
 
 <form enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" action="http://www.google.com/cse">
   <div>
@@ -147,46 +155,46 @@ Specifically, JAX-RS 2.0 client filters,
 <p>For example, given these class definitions:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-@Path(<span class="code-quote">"/bookstore"</span>)
-<span class="code-keyword">public</span> <span class="code-keyword">interface</span> BookStore {
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+@Path("/bookstore")
+public interface BookStore {
    @GET
    Books getAllBooks();
    
-   @Path(<span class="code-quote">"{id}"</span>)
-   BookResource getBookSubresource(@PathParam(<span class="code-quote">"id"</span>) <span class="code-object">long</span> id) <span class="code-keyword">throws</span> NoBookFoundException;
+   @Path("{id}")
+   BookResource getBookSubresource(@PathParam("id") long id) throws NoBookFoundException;
 }
 
-<span class="code-keyword">public</span> class BookStoreImpl <span class="code-keyword">implements</span> BookStore {
-   <span class="code-keyword">public</span> Books getAllBooks() {}
+public class BookStoreImpl implements BookStore {
+   public Books getAllBooks() {}
    
-   <span class="code-keyword">public</span> Book getBookSubresource(<span class="code-object">long</span> id) <span class="code-keyword">throws</span> NoBookFoundException {}
+   public Book getBookSubresource(long id) throws NoBookFoundException {}
 }
 
-<span class="code-keyword">public</span> <span class="code-keyword">interface</span> BookResource {
+public interface BookResource {
    @GET
    Book getBook();
 }
 
-<span class="code-keyword">public</span> class BookResourceImpl <span class="code-keyword">implements</span> BookResource {
+public class BookResourceImpl implements BookResource {
    Book getBook() {}
 }
 
-</pre>
+]]></script>
 </div></div>
 
 <p>the following client code retrieves a Book with id '1' and a collection of books: </p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-BookStore store = JAXRSClientFactory.create(<span class="code-quote">"http:<span class="code-comment">//bookstore.com"</span>, BookStore.class);
-</span><span class="code-comment">// (1) remote GET call to http://bookstore.com/bookstore
-</span>Books books = store.getAllBooks();
-<span class="code-comment">// (2) no remote call
-</span>BookResource subresource = store.getBookSubresource(1);
-<span class="code-comment">// {3} remote GET call to http://bookstore.com/bookstore/1
-</span>Book b = subresource.getBook();
-</pre>
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+BookStore store = JAXRSClientFactory.create("http://bookstore.com", BookStore.class);
+// (1) remote GET call to http://bookstore.com/bookstore
+Books books = store.getAllBooks();
+// (2) no remote call
+BookResource subresource = store.getBookSubresource(1);
+// {3} remote GET call to http://bookstore.com/bookstore/1
+Book b = subresource.getBook();
+]]></script>
 </div></div>     
 
 <p>When proxies are created, initially or when subresource methods are invoked, the current URI is updated with corresponding @Path, @PathParam, @QueryParam or @MatrixParam values, while @HttpHeader and @CookieParam values contribute to the current set of HTTP headers. Same happens before the remote invocation is done. </p>
@@ -204,11 +212,11 @@ BookStore store = JAXRSClientFactory.cre
 <p>Proxies end up implementing not only the interface requested at proxy creation time but also a <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/client/Client.java">Client</a> interface. In many cases one does not need to explicitly specify commonly used HTTP headers such as Content-Type or Accept as this information will likely be available from @Consumes or @Produces annotations. At the same time you may explicitly set either of these headers, or indeed some other header. You can use a simple <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/client/WebClient.java">WebClient</a> utility method for converting a proxy to a base client:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-BookStore proxy = JAXRSClientFactory.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>, BookStore.class);
-</span>WebClient.client(proxy).accept(<span class="code-quote">"text/xml"</span>);
-<span class="code-comment">// <span class="code-keyword">continue</span> using the proxy    </span>
-</pre>
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+BookStore proxy = JAXRSClientFactory.create("http://books", BookStore.class);
+WebClient.client(proxy).accept("text/xml");
+// continue using the proxy    
+]]></script>
 </div></div>
 
 <p>You can also check a current set of headers, current and base URIs and a client Response.</p>
@@ -218,22 +226,22 @@ BookStore proxy = JAXRSClientFactory.cre
 <p>Using proxies is just one way to consume a service. Proxies hide away the details of how URIs are being composed while HTTP-centric WebClients provide for an explicit URI creation. Both proxies and http clients rely on the same base information such as headers and the current URI so at any moment of time you can create a WebClient instance out of the existing proxy:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-BookStore proxy = JAXRSClientFactory.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>, BookStore.class);
-</span>Client client = WebClient.client(proxy);
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+BookStore proxy = JAXRSClientFactory.create("http://books", BookStore.class);
+Client client = WebClient.client(proxy);
 WebClient httpClient = WebClient.fromClient(client);
-<span class="code-comment">// <span class="code-keyword">continue</span> using the http client    </span>
-</pre>
+// continue using the http client    
+]]></script>
 </div></div>
 
 <p>At any moment of time you can convert an http client into a proxy too:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-BookStore proxy1 = JAXRSClientFactory.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>, BookStore.class);
-</span>Client client = WebClient.client(proxy1);
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+BookStore proxy1 = JAXRSClientFactory.create("http://books", BookStore.class);
+Client client = WebClient.client(proxy1);
 BookStore proxy2 = JAXRSClientFactory.fromClient(client, BookStore.class);
-</pre>
+]]></script>
 </div></div>
 
 <h2><a shape="rect" name="JAX-RSClientAPI-Handlingexceptions"></a>Handling exceptions</h2>
@@ -244,15 +252,15 @@ One approach is to register a <a shape="
 <p>If no ResponseExceptionMapper is available when a remote invocation failed then an instance of javax.ws.rs.WebApplicationException will be thrown (Note org.apache.cxf.jaxrs.client.ServerWebApplicationException is used to represent the server exceptions before CXF 2.7.0.). At this point of time you can check the actual Response and proceed from there:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-BookStore proxy = JAXRSClientFactory.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>, BookStore.class);
-</span><span class="code-keyword">try</span> {
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+BookStore proxy = JAXRSClientFactory.create("http://books", BookStore.class);
+try {
     proxy.getBook();
-} <span class="code-keyword">catch</span>(WebApplicationException ex) {
+} catch(WebApplicationException ex) {
   Response r = ex.getResponse();
-  <span class="code-object">String</span> message = ex.getMessage();
+  String message = ex.getMessage();
 }
-</pre>
+]]></script>
 </div></div>
 <p>javax.ws.rs.ProcessingException will be thrown if the exception has occurred for one of two reasons: </p>
 <ul class="alternate" type="square"><li>the remote invocation succeeded but no proper MessageBodyReader has been found on the client side; in this case the Response object representing the result of the invocation will still be available</li><li>the remote invocation has failed for whatever reasons on the client side, example, no MessageBodyWriter is available.</li></ul>
@@ -265,29 +273,29 @@ BookStore proxy = JAXRSClientFactory.cre
 <p>When creating a proxy with JAXRSClientFactory, you can pass a Spring configuration location as one of the arguments. Or you can create a default bus using Spring configuration and all proxies will pick it up:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-SpringBusFactory bf = <span class="code-keyword">new</span> SpringBusFactory();
-Bus bus = bf.createBus(<span class="code-quote">"org/apache/cxf/systest/jaxrs/security/jaxrs-https.xml"</span>);
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+SpringBusFactory bf = new SpringBusFactory();
+Bus bus = bf.createBus("org/apache/cxf/systest/jaxrs/security/jaxrs-https.xml");
 BusFactory.setDefaultBus(bus);
-<span class="code-comment">// BookStore proxy will get the configuration from Spring
-</span>BookStore proxy = JAXRSClientFactory.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>, BookStore.class);</span>
-</pre>
+// BookStore proxy will get the configuration from Spring
+BookStore proxy = JAXRSClientFactory.create("http://books", BookStore.class);
+]]></script>
 </div></div> 
 
 <h2><a shape="rect" name="JAX-RSClientAPI-Injectingproxies"></a>Injecting proxies</h2>
 
 <p>For injecting proxies via a spring context, use the jaxrs:client element like:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">
-  &lt;jaxrs:client id=<span class="code-quote">"restClient"</span>
-         address=<span class="code-quote">"http://localhost:${testutil.ports.BookServerRestSoap}/test/services/rest"</span>
-         serviceClass=<span class="code-quote">"org.apache.cxf.systest.jaxrs.BookStoreJaxrsJaxws"</span>
-         inheritHeaders=<span class="code-quote">"true"</span>&gt;
-         <span class="code-tag">&lt;jaxrs:headers&gt;</span>
-             <span class="code-tag">&lt;entry key=<span class="code-quote">"Accept"</span> value=<span class="code-quote">"text/xml"</span>/&gt;</span>
-         <span class="code-tag">&lt;/jaxrs:headers&gt;</span>
-  <span class="code-tag">&lt;/jaxrs:client&gt;</span>  
-</pre>
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
+  &lt;jaxrs:client id="restClient"
+         address="http://localhost:${testutil.ports.BookServerRestSoap}/test/services/rest"
+         serviceClass="org.apache.cxf.systest.jaxrs.BookStoreJaxrsJaxws"
+         inheritHeaders="true"&gt;
+         &lt;jaxrs:headers&gt;
+             &lt;entry key="Accept" value="text/xml"/&gt;
+         &lt;/jaxrs:headers&gt;
+  &lt;/jaxrs:client&gt;  
+]]></script>
 </div></div>
 
 <p>See this <a shape="rect" class="external-link" href="http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml">bean</a> for a full example of how jaxrs:client can be used to inject a proxy </p>
@@ -301,19 +309,19 @@ BusFactory.setDefaultBus(bus);
 <p>When a proxy method returning a JAX-RS Response is invoked, the returned Response.getEntity() will return a response InputStream by default. Starting with CXF 2.3.2 one can register an org.apache.cxf.jaxrs.client.ResponseReader provider and cast the Response.getEntity() to more specific application classes:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-ResponseReader reader = <span class="code-keyword">new</span> ResponseReader();
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+ResponseReader reader = new ResponseReader();
 reader.setEntityClass(Book.class);
         
-BookStore bs = JAXRSClientFactory.create(<span class="code-quote">"http:<span class="code-comment">//localhost:8080/books"</span>, BookStore.class,
-</span>                                         Collections.singletonList(reader));
-Response r1 = bs.getBook(<span class="code-quote">"123"</span>);
+BookStore bs = JAXRSClientFactory.create("http://localhost:8080/books", BookStore.class,
+                                         Collections.singletonList(reader));
+Response r1 = bs.getBook("123");
 Book book = (Book)r1.getEntity();
 
 reader.setEntityClass(Author.class);
-Response r2 = bs.getBookAuthor(<span class="code-quote">"123"</span>);
+Response r2 = bs.getBookAuthor("123");
 Author book = (Author)r2.getEntity();
-</pre>
+]]></script>
 </div></div>
 
 <h2><a shape="rect" name="JAX-RSClientAPI-Workingwithusermodels"></a>Working with user models</h2>
@@ -321,9 +329,9 @@ Author book = (Author)r2.getEntity();
 <p>Proxies can be created with the external user model being applied to a proxy class, for example:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-JAXRSClientFactory.createFromModel(<span class="code-quote">"http:<span class="code-comment">//books"</span>, BookNoAnnotations.class, <span class="code-quote">"classpath:/resources/model.xml"</span>, <span class="code-keyword">null</span>);</span>
-</pre>
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+JAXRSClientFactory.createFromModel("http://books", BookNoAnnotations.class, "classpath:/resources/model.xml", null);
+]]></script>
 </div></div>
 
 <p>BookNoAnnotations is either an interface or concrete class with no JAX-RS annotations. Both client proxies and server endpoints can 'turn' it into a RESTful resource by applying an external user model.</p>
@@ -333,40 +341,40 @@ JAXRSClientFactory.createFromModel(<span
 <p>HTTP centric clients are <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/client/WebClient.java">WebClient</a> instances which also implement the <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/client/Client.java">Client</a> interface. In addition to setting various Client request properties, you can also make an explicit HTTP invocation with an HTTP verb being the name of a given operation :</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-WebClient client = WebClient.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>);
-</span>Book book = client.path(<span class="code-quote">"bookstore/books"</span>).accept(<span class="code-quote">"text/xml"</span>).get(Book.class);
-</pre>
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+WebClient client = WebClient.create("http://books");
+Book book = client.path("bookstore/books").accept("text/xml").get(Book.class);
+]]></script>
 </div></div>
 
 <p>You can choose to get an explicit JAX-RS Response instead and check the response code, headers or entity body if any:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-WebClient client = WebClient.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>);
-</span>client.path(<span class="code-quote">"bookstore/books"</span>);
-client.type(<span class="code-quote">"text/xml"</span>).accept(<span class="code-quote">"text/xml"</span>)
-Response r = client.post(<span class="code-keyword">new</span> Book());
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+WebClient client = WebClient.create("http://books");
+client.path("bookstore/books");
+client.type("text/xml").accept("text/xml")
+Response r = client.post(new Book());
 Book b = r.readEntity(Book.class);
-</pre>
+]]></script>
 </div></div>
 
 <p>WebClient lets you get back to a base URI or to a previous path segment and move forward, it can be handy for getting a number of individual entries from a service with ids embedded in path segments :</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-WebClient client = WebClient.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>);
-</span>List&lt;Book&gt; books = getBooks(client, 1L, 2L, 3L)
-
-<span class="code-keyword">private</span> List&lt;Book&gt; getBooks(WebClient client, <span class="code-object">Long</span> ...ids) {
-   List&lt;Book&gt; books = <span class="code-keyword">new</span> ArrayList&lt;Book&gt;(); 
-   <span class="code-keyword">for</span> (<span class="code-object">Long</span> id : ids) {
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+WebClient client = WebClient.create("http://books");
+List&lt;Book&gt; books = getBooks(client, 1L, 2L, 3L)
+
+private List&lt;Book&gt; getBooks(WebClient client, Long ...ids) {
+   List&lt;Book&gt; books = new ArrayList&lt;Book&gt;(); 
+   for (Long id : ids) {
        books.add(client.path(id).get(Book.class));
        client.back(); 
    } 
-   <span class="code-keyword">return</span> books;
+   return books;
 }
-</pre>
+]]></script>
 </div></div>
 
 <p>The above code will send requests like "GET <a shape="rect" class="external-link" href="http://books/1" rel="nofollow">http://books/1</a>", "GET <a shape="rect" class="external-link" href="http://books/2" rel="nofollow">http://books/2</a>", etc. </p>
@@ -374,11 +382,11 @@ WebClient client = WebClient.create(<spa
 <p>If the request URI can be parameterized then you may want to use the following code:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-Book book = WebClient.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>).path(<span class="code-quote">"{year}/{id}"</span>, 2010, 123).get(Book.class);
-</span><span class="code-comment">// as opposed to
-</span><span class="code-comment">// WebClient.create(<span class="code-quote">"http://books"</span>).path(2010).path(123).get(Book.class);</span>
-</pre>
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+Book book = WebClient.create("http://books").path("{year}/{id}", 2010, 123).get(Book.class);
+// as opposed to
+// WebClient.create("http://books").path(2010).path(123).get(Book.class);
+]]></script>
 </div></div>
 
 
@@ -394,12 +402,12 @@ Book book = WebClient.create(<span class
 <p>Example :</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
 
-Collection&lt;? <span class="code-keyword">extends</span> Book&gt; books = WebClient.getCollection(Book.class);
-Collection&lt;? <span class="code-keyword">extends</span> Book&gt; books = WebClient.postAndGetCollection(<span class="code-keyword">new</span> ArrayList&lt;Book&gt;(), Book.class);
+Collection&lt;? extends Book&gt; books = WebClient.getCollection(Book.class);
+Collection&lt;? extends Book&gt; books = WebClient.postAndGetCollection(new ArrayList&lt;Book&gt;(), Book.class);
 
-</pre>
+]]></script>
 </div></div>
 
 <h2><a shape="rect" name="JAX-RSClientAPI-Handlingexceptions"></a>Handling exceptions</h2>
@@ -411,38 +419,38 @@ Collection&lt;? <span class="code-keywor
 
 <p>Like proxies, HTTP clients can be created using a number of WebClient static utility methods: you can pass a location to a Spring configuration bean if needed or you can set up a default bus as shown above. For example:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">
-&lt;bean id=<span class="code-quote">"myJsonProvider"</span> 
-class=<span class="code-quote">"org.apache.cxf.jaxrs.provider.JSONProvider"</span> &gt; 
-        <span class="code-tag">&lt;property name=<span class="code-quote">"supportUnwrapped"</span> value=<span class="code-quote">"true"</span> /&gt;</span> 
-        <span class="code-tag">&lt;property name=<span class="code-quote">"wrapperName"</span> value=<span class="code-quote">"nodeName"</span> /&gt;</span> 
-    <span class="code-tag">&lt;/bean&gt;</span> 
-
-<span class="code-tag">&lt;util:list id=<span class="code-quote">"webClientProviders"</span>&gt;</span> 
-    <span class="code-tag">&lt;ref bean=<span class="code-quote">"myJsonProvider"</span>/&gt;</span> 
-<span class="code-tag">&lt;/util:list&gt;</span> 
-
-&lt;bean id=<span class="code-quote">"myWebClient"</span> class=<span class="code-quote">"org.apache.cxf.jaxrs.client.WebClient"</span> 
-factory-method=<span class="code-quote">"create"</span>&gt; 
-        &lt;constructor-arg type=<span class="code-quote">"java.lang.String"</span> 
-value=<span class="code-quote">"http://some.base.url.that.responds/"</span> /&gt; 
-        <span class="code-tag">&lt;constructor-arg ref=<span class="code-quote">"webClientProviders"</span> /&gt;</span> 
-<span class="code-tag">&lt;/bean&gt;</span> 
-</pre>
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
+&lt;bean id="myJsonProvider" 
+class="org.apache.cxf.jaxrs.provider.JSONProvider" &gt; 
+        &lt;property name="supportUnwrapped" value="true" /&gt; 
+        &lt;property name="wrapperName" value="nodeName" /&gt; 
+    &lt;/bean&gt; 
+
+&lt;util:list id="webClientProviders"&gt; 
+    &lt;ref bean="myJsonProvider"/&gt; 
+&lt;/util:list&gt; 
+
+&lt;bean id="myWebClient" class="org.apache.cxf.jaxrs.client.WebClient" 
+factory-method="create"&gt; 
+        &lt;constructor-arg type="java.lang.String" 
+value="http://some.base.url.that.responds/" /&gt; 
+        &lt;constructor-arg ref="webClientProviders" /&gt; 
+&lt;/bean&gt; 
+]]></script>
 </div></div> 
 
 <p>Note, starting from CXF 2.7.5 it is possible to set-up WebClient instances the same way as proxies, using jaxrs:client:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">
-&lt;jaxrs:client id=<span class="code-quote">"webClient"</span>
-         address=<span class="code-quote">"https://localhost:${port}/services/rest"</span>
-         serviceClass=<span class="code-quote">"org.apache.cxf.jaxrs.client.WebClient"</span>&gt;
-         <span class="code-tag">&lt;jaxrs:headers&gt;</span>
-             <span class="code-tag">&lt;entry key=<span class="code-quote">"Accept"</span> value=<span class="code-quote">"text/xml"</span>/&gt;</span>
-         <span class="code-tag">&lt;/jaxrs:headers&gt;</span>
-  <span class="code-tag">&lt;/jaxrs:client&gt;</span>
-</pre>
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
+&lt;jaxrs:client id="webClient"
+         address="https://localhost:${port}/services/rest"
+         serviceClass="org.apache.cxf.jaxrs.client.WebClient"&gt;
+         &lt;jaxrs:headers&gt;
+             &lt;entry key="Accept" value="text/xml"/&gt;
+         &lt;/jaxrs:headers&gt;
+  &lt;/jaxrs:client&gt;
+]]></script>
 </div></div>
 
 <p>The only limitation of using this option is that some of jaxrs:client attributes ("inheritHeaders", "modelRef") and elements ("model") are not really applicable to WebClient.</p>
@@ -452,13 +460,13 @@ value=<span class="code-quote">"http://s
 <p>XML-centric clients are WebClients using an <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/xml/XMLSource.java">XMLSource</a> utility class. XMLSource has a number of methods facilitating the retrieval of JAXB beans, individual properties or links with the help of XPath expressions. For example:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-WebClient wc = WebClient.create(<span class="code-quote">"http:<span class="code-comment">//aggregated/data"</span>);
-</span>XMLSource source = wc.get(XMLSource.class);
-source.setBuffering(<span class="code-keyword">true</span>);
-Book b1 = source.getNode(<span class="code-quote">"/books/book[position() = 1]"</span>, Book.class);
-Book b2 = source.getNode(<span class="code-quote">"/books/book[position() = 2]"</span>, Book.class);
-</pre>
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+WebClient wc = WebClient.create("http://aggregated/data");
+XMLSource source = wc.get(XMLSource.class);
+source.setBuffering(true);
+Book b1 = source.getNode("/books/book[position() = 1]", Book.class);
+Book b2 = source.getNode("/books/book[position() = 2]", Book.class);
+]]></script>
 </div></div>
 
 <p>Note that an XMLSource instance can be set to buffer the input stream thus allowing for executing multiple XPath queries.<br clear="none">
@@ -472,10 +480,10 @@ XMlSource can also help with getting the
 
 <p>A single client doing multiple invocations without changing the current URI or headers is thread-safe. The only limitation in this case applies to proxies, in that they can not get "out of band" headers without synchronizing, ex :</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-<span class="code-comment">// get some response headers passed to us 'out of band', which is not thread-safe <span class="code-keyword">for</span> a plain proxy: 
-</span><span class="code-object">String</span> bookHeader = WebClient.toClient(injectedBookStoreProxy).getHeaders().getFirst(<span class="code-quote">"BookHeader"</span>); 
-</pre>
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+// get some response headers passed to us 'out of band', which is not thread-safe for a plain proxy: 
+String bookHeader = WebClient.toClient(injectedBookStoreProxy).getHeaders().getFirst("BookHeader"); 
+]]></script>
 </div></div>  
 
 <p>Final option is to use a 'threadSafe' boolean property when creating proxies or web clients (either from Spring or programmatically), 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/JAXRSMultithreadedClientTest.java">test</a> for more details. Thread-safe clients created this way keep their state in a thread-local storage. </p>
@@ -483,16 +491,16 @@ XMlSource can also help with getting the
 <p>If a number of incoming threads is limited then one option is just do nothing, while the other option is to reset the thread local state :</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-<span class="code-keyword">try</span> { 
-   webClient.path(<span class="code-quote">"bar"</span>) 
-   webClient.header(<span class="code-quote">"bar"</span>, baz); 
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+try { 
+   webClient.path("bar") 
+   webClient.header("bar", baz); 
    webClient.invoke(...); 
-} <span class="code-keyword">finally</span> { 
-   <span class="code-comment">// <span class="code-keyword">if</span> using a proxy: WebClient.client(proxy).reset(); 
-</span>   webClient.reset(); 
+} finally { 
+   // if using a proxy: WebClient.client(proxy).reset(); 
+   webClient.reset(); 
 } 
-</pre>
+]]></script>
 </div></div>
 
 <p>Yet another option is to use JAXRSClientFactoryBean and a 'secondsToKeepState' property for creating thread-safe clients - this will instruct clients to clean-up the thread-local state periodically.</p>
@@ -505,14 +513,14 @@ XMlSource can also help with getting the
 <p>Sometimes, you may want to configure a client instance after it is been created. For example, one may want to configure HTTPConduit programmatically, as opposed to setting its properties using Spring. ClientConfiguration represents a client-specific configuration state and can be accessed like this :</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-Book proxy = JAXRSClientFactory.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>, Book.class);
-</span>ClientConfiguration config = WebClient.getConfig(proxy);
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+Book proxy = JAXRSClientFactory.create("http://books", Book.class);
+ClientConfiguration config = WebClient.getConfig(proxy);
 HTTPConduit conduit1 = (HTTPConduit)config.getConduit();
 
-WebClient webclient = WebClient.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>);
-</span>HTTPConduit conduit2 = (HTTPConduit)WebClient.getConfig(webclient).getConduit();
-</pre>
+WebClient webclient = WebClient.create("http://books");
+HTTPConduit conduit2 = (HTTPConduit)WebClient.getConfig(webclient).getConduit();
+]]></script>
 </div></div>
 
 
@@ -521,17 +529,17 @@ WebClient webclient = WebClient.create(<
 <p>Example :</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-JAXRSClientFactoryBean sf = <span class="code-keyword">new</span> JAXRSClientFactoryBean();
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+JAXRSClientFactoryBean sf = new JAXRSClientFactoryBean();
 sf.setResourceClass(CustomerService.class);
-sf.setAddress(<span class="code-quote">"http:<span class="code-comment">//localhost:9000/"</span>);
-</span>BindingFactoryManager manager = sf.getBus().getExtension(BindingFactoryManager.class);
-JAXRSBindingFactory factory = <span class="code-keyword">new</span> JAXRSBindingFactory();
+sf.setAddress("http://localhost:9000/");
+BindingFactoryManager manager = sf.getBus().getExtension(BindingFactoryManager.class);
+JAXRSBindingFactory factory = new JAXRSBindingFactory();
 factory.setBus(sf.getBus());
 manager.registerBindingFactory(JAXRSBindingFactory.JAXRS_BINDING_ID, factory);
 CustomerService service = sf.create(CustomerService.class);
 WebClient wc = sf.createWebClient();
-</pre>
+]]></script>
 </div></div> 
 
 
@@ -542,9 +550,9 @@ WebClient wc = sf.createWebClient();
 <p>It is possible to have an HTTPConduit configuration which will apply to all clients using different request URIs or only to those with using a specific URI. For example:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">
-<span class="code-tag">&lt;http:conduit name=<span class="code-quote">"http://books:9095/bookstore.*"</span>/&gt;</span> 
-</pre>
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
+&lt;http:conduit name="http://books:9095/bookstore.*"/&gt; 
+]]></script>
 </div></div>
 
 <p>This configuration will affect all proxies and WebClients which have requestURIs starting from 'http://books:9095/bookstore'. Note the trailing '.*' suffix in the name of the http:conduit element.</p>
@@ -554,9 +562,9 @@ WebClient wc = sf.createWebClient();
 <p>Alternatively you can just do:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">
-<span class="code-tag">&lt;http:conduit name=<span class="code-quote">"*.http-conduit"</span>/&gt;</span> 
-</pre>
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
+&lt;http:conduit name="*.http-conduit"/&gt; 
+]]></script>
 </div></div>
 
 <p>This configuration will affect all the clients, irrespective of the URIs being dealt with.</p>
@@ -564,9 +572,9 @@ WebClient wc = sf.createWebClient();
 <p>If you work with proxies then you can have the proxy-specific configuration using the expanded QName notation:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">
-<span class="code-tag">&lt;http:conduit name=<span class="code-quote">"{http://foo.bar}BookService.http-conduit"</span>/&gt;</span> 
-</pre>
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
+&lt;http:conduit name="{http://foo.bar}BookService.http-conduit"/&gt; 
+]]></script>
 </div></div>
 
 <p>In this example, 'foo.bar' is a reverse package name of the BookService proxy class.</p>
@@ -574,9 +582,9 @@ WebClient wc = sf.createWebClient();
 <p>Similarly, for WebClients you can do:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">
-<span class="code-tag">&lt;http:conduit name=<span class="code-quote">"{http://localhost:8080}WebClient.http-conduit"</span>/&gt;</span> 
-</pre>
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
+&lt;http:conduit name="{http://localhost:8080}WebClient.http-conduit"/&gt; 
+]]></script>
 </div></div>
 
 <p>In this example, 'http://localhost:8080' is the base service URI.</p>
@@ -590,28 +598,28 @@ WebClient wc = sf.createWebClient();
 <p>Proxies and HTTP-centric clients can have the HTTP Authorization header set up explicitly:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
 
-<span class="code-comment">// Replace 'user' and 'password' by the actual values
-</span><span class="code-object">String</span> authorizationHeader = <span class="code-quote">"Basic "</span> 
-    + org.apache.cxf.common.util.Base64Utility.encode(<span class="code-quote">"user:password"</span>.getBytes());
+// Replace 'user' and 'password' by the actual values
+String authorizationHeader = "Basic " 
+    + org.apache.cxf.common.util.Base64Utility.encode("user:password".getBytes());
 
-<span class="code-comment">// proxies
-</span>WebClient.client(proxy).header(<span class="code-quote">"Authorization"</span>, authorizationHeader);
+// proxies
+WebClient.client(proxy).header("Authorization", authorizationHeader);
 
-<span class="code-comment">// web clients
-</span>webClient.header(<span class="code-quote">"Authorization"</span>, authorizationHeader);
+// web clients
+webClient.header("Authorization", authorizationHeader);
 
-</pre>
+]]></script>
 </div></div>
 
 <p>or by providing a username and password pair at client creation time, for example:</p>
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
-BookStore proxy = JAXRSClientFactory.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>, BookStore.class, <span class="code-quote">"username"</span>, <span class="code-quote">"password"</span>, <span class="code-quote">"classpath:/config/https.xml"</span>);
-</span>
-WebClient client = WebClient.create(<span class="code-quote">"http:<span class="code-comment">//books"</span>, <span class="code-quote">"username"</span>, <span class="code-quote">"password"</span>, <span class="code-quote">"classpath:/config/https.xml"</span>);</span>
-</pre>
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+BookStore proxy = JAXRSClientFactory.create("http://books", BookStore.class, "username", "password", "classpath:/config/https.xml");
+
+WebClient client = WebClient.create("http://books", "username", "password", "classpath:/config/https.xml");
+]]></script>
 </div></div>
 
 <p>When injecting clients from Spring, one can add 'username' and 'password' values as attributes to jaxrs:client elements or add them to WebClient factory create methods.</p></div>

Modified: websites/production/cxf/content/docs/jax-rs-cors.html
==============================================================================
--- websites/production/cxf/content/docs/jax-rs-cors.html (original)
+++ websites/production/cxf/content/docs/jax-rs-cors.html Mon Jun 24 17:10:51 2013
@@ -25,6 +25,18 @@
 <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
 <meta name="keywords" content="business integration, EAI, SOA, Service Oriented Architecture, web services, SOAP, JBI, JMS, WSDL, XML, EDI, Electronic Data Interchange, standards support, integration standards, application integration, middleware, software, solutions, services, CXF, open source">
 <meta name="description" content="Apache CXF, Services Framework - JAX-RS CORS">
+
+  <link href='http://cxf.apache.org/resources/highlighter/styles/shCore.css' rel='stylesheet' type='text/css' />
+  <link href='http://cxf.apache.org/resources/highlighter/styles/shThemeCXF.css' rel='stylesheet' type='text/css' />
+  <script src='http://cxf.apache.org/resources/highlighter/scripts/shCore.js' type='text/javascript'></script>
+  <script src='http://cxf.apache.org/resources/highlighter/scripts/shBrushJava.js' type='text/javascript'></script>
+  <script src='http://cxf.apache.org/resources/highlighter/scripts/shBrushXml.js' type='text/javascript'></script>
+  
+  <script type="text/javascript">
+  SyntaxHighlighter.defaults['toolbar'] = false;
+  SyntaxHighlighter.all();
+  </script>
+ 
     <title>
 Apache CXF -- JAX-RS CORS
     </title>
@@ -42,19 +54,15 @@ Apache CXF -- JAX-RS CORS
     <td id="cell-1-0">&nbsp;</td>
     <td id="cell-1-1">&nbsp;</td>
     <td id="cell-1-2">
-      <div style="padding: 5px;">
-        <div id="banner">
-          <!-- Banner -->
-<div id="banner-content">
+      <!-- Banner -->
+<div class="banner" id="banner"><p>
 <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="left" colspan="1" nowrap>
 <a shape="rect" href="http://cxf.apache.org/" title="Apache CXF"><span style="font-weight: bold; font-size: 170%; color: white">Apache CXF</span></a>
 </td><td align="right" colspan="1" nowrap>
 <a shape="rect" href="http://www.apache.org/" title="The Apache Sofware Foundation"><img border="0" alt="ASF Logo" src="http://cxf.apache.org/images/asf-logo.png"></a>
 </td></tr></table>
-</div>
-          <!-- Banner -->
-        </div>
-      </div>
+</p></div>
+      <!-- Banner -->
       <div id="top-menu">
         <table border="0" cellpadding="1" cellspacing="0" width="100%">
           <tr>
@@ -94,7 +102,7 @@ Apache CXF -- JAX-RS CORS
 
 
 <hr>
-<ul class="alternate" type="square"><li>Search
+<ul class="alternate" type="square"><li>Search<br clear="none">
 
 <form enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" action="http://www.google.com/cse">
   <div>
@@ -140,13 +148,13 @@ Apache CXF -- JAX-RS CORS
 <h1><a shape="rect" name="JAX-RSCORS-Mavendependencies"></a>Maven dependencies</h1>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">
-<span class="code-tag">&lt;dependency&gt;</span>
-  <span class="code-tag">&lt;groupId&gt;</span>org.apache.cxf<span class="code-tag">&lt;/groupId&gt;</span>
-  <span class="code-tag">&lt;artifactId&gt;</span>cxf-rt-rs-security-cors<span class="code-tag">&lt;/artifactId&gt;</span>
-  <span class="code-tag">&lt;version&gt;</span>2.6.1<span class="code-tag">&lt;/version&gt;</span>
-<span class="code-tag">&lt;/dependency&gt;</span>
-</pre>
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
+&lt;dependency&gt;
+  &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
+  &lt;artifactId&gt;cxf-rt-rs-security-cors&lt;/artifactId&gt;
+  &lt;version&gt;2.6.1&lt;/version&gt;
+&lt;/dependency&gt;
+]]></script>
 </div></div>
 
 <h1><a shape="rect" name="JAX-RSCORS-Examples"></a>Examples</h1>
@@ -156,115 +164,115 @@ Apache CXF -- JAX-RS CORS
 <p>Note that an origin is restricted to "http://area51.mil:31415" by the 'allowOrigins' property, which may contain multiple URI values. A boolean 'allowAllOrigins' property can be used instead (to simplify the testing or when it is deemed it is secure enough within a given environment to allow for all the origins).  </p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-java">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
 @CrossOriginResourceSharing(
         allowOrigins = {
-           <span class="code-quote">"http:<span class="code-comment">//area51.mil:31415"</span>
-</span>        }, 
-        allowCredentials = <span class="code-keyword">true</span>, 
+           "http://area51.mil:31415"
+        }, 
+        allowCredentials = true, 
         maxAge = 1, 
         allowHeaders = {
-           <span class="code-quote">"X-custom-1"</span>, <span class="code-quote">"X-custom-2"</span>
+           "X-custom-1", "X-custom-2"
         }, 
         exposeHeaders = {
-           <span class="code-quote">"X-custom-3"</span>, <span class="code-quote">"X-custom-4"</span>
+           "X-custom-3", "X-custom-4"
         }
 )
-<span class="code-keyword">public</span> class AnnotatedCorsServer {
+public class AnnotatedCorsServer {
     @Context
-    <span class="code-keyword">private</span> HttpHeaders headers;
+    private HttpHeaders headers;
 
     @GET
-    @Produces(<span class="code-quote">"text/plain"</span>)
-    @Path(<span class="code-quote">"/simpleGet/{echo}"</span>)
-    <span class="code-keyword">public</span> <span class="code-object">String</span> simpleGet(@PathParam(<span class="code-quote">"echo"</span>) <span class="code-object">String</span> echo) {
-        <span class="code-keyword">return</span> echo;
+    @Produces("text/plain")
+    @Path("/simpleGet/{echo}")
+    public String simpleGet(@PathParam("echo") String echo) {
+        return echo;
     }
     
     @POST
-    @Produces(<span class="code-quote">"application/json"</span>)
-    @Consumes(<span class="code-quote">"application/json"</span>)
-    @Path(<span class="code-quote">"/unannotatedPost"</span>)
-    <span class="code-keyword">public</span> Response postSomething() {
-        <span class="code-keyword">return</span> Response.ok().build();
+    @Produces("application/json")
+    @Consumes("application/json")
+    @Path("/unannotatedPost")
+    public Response postSomething() {
+        return Response.ok().build();
     }
 
     @DELETE
-    @Path(<span class="code-quote">"/delete"</span>)
-    <span class="code-keyword">public</span> Response deleteSomething() {
-        <span class="code-keyword">return</span> Response.ok().build();
+    @Path("/delete")
+    public Response deleteSomething() {
+        return Response.ok().build();
     }
 
-    <span class="code-comment">// This method will <span class="code-keyword">do</span> a preflight check itself
-</span>    @OPTIONS
-    @Path(<span class="code-quote">"/"</span>)
+    // This method will do a preflight check itself
+    @OPTIONS
+    @Path("/")
     @LocalPreflight
-    <span class="code-keyword">public</span> Response options() {
-        <span class="code-object">String</span> origin = headers.getRequestHeader(<span class="code-quote">"Origin"</span>).get(0);
-        <span class="code-keyword">if</span> (<span class="code-quote">"http:<span class="code-comment">//area51.mil:3333"</span>.equals(origin)) {
-</span>            <span class="code-keyword">return</span> Response.ok()
-                           .header(CorsHeaderConstants.HEADER_AC_ALLOW_METHODS, <span class="code-quote">"DELETE PUT"</span>)
-                           .header(CorsHeaderConstants.HEADER_AC_ALLOW_CREDENTIALS, <span class="code-quote">"<span class="code-keyword">false</span>"</span>)
-                           .header(CorsHeaderConstants.HEADER_AC_ALLOW_ORIGIN, <span class="code-quote">"http:<span class="code-comment">//area51.mil:3333"</span>)
-</span>                           .build();
-        } <span class="code-keyword">else</span> {
-            <span class="code-keyword">return</span> Response.ok().build();
+    public Response options() {
+        String origin = headers.getRequestHeader("Origin").get(0);
+        if ("http://area51.mil:3333".equals(origin)) {
+            return Response.ok()
+                           .header(CorsHeaderConstants.HEADER_AC_ALLOW_METHODS, "DELETE PUT")
+                           .header(CorsHeaderConstants.HEADER_AC_ALLOW_CREDENTIALS, "false")
+                           .header(CorsHeaderConstants.HEADER_AC_ALLOW_ORIGIN, "http://area51.mil:3333")
+                           .build();
+        } else {
+            return Response.ok().build();
         }
     }
 
     @GET
     @CrossOriginResourceSharing(
-         allowOrigins = { <span class="code-quote">"http:<span class="code-comment">//area51.mil:31415"</span> }, 
-</span>         allowCredentials = <span class="code-keyword">true</span>, 
-         exposeHeaders = { <span class="code-quote">"X-custom-3"</span>, <span class="code-quote">"X-custom-4"</span> }
+         allowOrigins = { "http://area51.mil:31415" }, 
+         allowCredentials = true, 
+         exposeHeaders = { "X-custom-3", "X-custom-4" }
     )
-    @Produces(<span class="code-quote">"text/plain"</span>)
-    @Path(<span class="code-quote">"/annotatedGet/{echo}"</span>)
-    <span class="code-keyword">public</span> <span class="code-object">String</span> annotatedGet(@PathParam(<span class="code-quote">"echo"</span>) <span class="code-object">String</span> echo) {
-        <span class="code-keyword">return</span> echo;
+    @Produces("text/plain")
+    @Path("/annotatedGet/{echo}")
+    public String annotatedGet(@PathParam("echo") String echo) {
+        return echo;
     }
 
     /**
      * A method annotated to test preflight.
      * 
      * @param input
-     * @<span class="code-keyword">return</span>
+     * @return
      */
     @PUT
-    @Consumes(<span class="code-quote">"text/plain"</span>)
-    @Produces(<span class="code-quote">"text/plain"</span>)
-    @Path(<span class="code-quote">"/annotatedPut"</span>)
-    <span class="code-keyword">public</span> <span class="code-object">String</span> annotatedPut(<span class="code-object">String</span> input) {
-        <span class="code-keyword">return</span> input;
+    @Consumes("text/plain")
+    @Produces("text/plain")
+    @Path("/annotatedPut")
+    public String annotatedPut(String input) {
+        return input;
     }
 }
 
-</pre>
+]]></script>
 </div></div>
 
 <p>The server configuration fragment:</p>
 
 <div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
-<pre class="code-xml">
+<script class="theme: Default; brush: xml; gutter: false" type="syntaxhighlighter"><![CDATA[
 
-<span class="code-tag">&lt;beans&gt;</span>
-        <span class="code-tag">&lt;bean id=<span class="code-quote">"cors-filter"</span> class=<span class="code-quote">"org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter"</span>/&gt;</span>
+&lt;beans&gt;
+        &lt;bean id="cors-filter" class="org.apache.cxf.rs.security.cors.CrossOriginResourceSharingFilter"/&gt;
 
-	<span class="code-tag">&lt;jaxrs:server id=<span class="code-quote">"service"</span> address=<span class="code-quote">"/rest"</span>&gt;</span>
-		<span class="code-tag">&lt;jaxrs:serviceBeans&gt;</span>
-			<span class="code-tag">&lt;ref bean=<span class="code-quote">"cors-server"</span> /&gt;</span>
-		<span class="code-tag">&lt;/jaxrs:serviceBeans&gt;</span>
-		<span class="code-tag">&lt;jaxrs:providers&gt;</span>
-			<span class="code-tag">&lt;ref bean=<span class="code-quote">"cors-filter"</span> /&gt;</span>
-		<span class="code-tag">&lt;/jaxrs:providers&gt;</span>
-	<span class="code-tag">&lt;/jaxrs:server&gt;</span>
+	&lt;jaxrs:server id="service" address="/rest"&gt;
+		&lt;jaxrs:serviceBeans&gt;
+			&lt;ref bean="cors-server" /&gt;
+		&lt;/jaxrs:serviceBeans&gt;
+		&lt;jaxrs:providers&gt;
+			&lt;ref bean="cors-filter" /&gt;
+		&lt;/jaxrs:providers&gt;
+	&lt;/jaxrs:server&gt;
 
-        &lt;bean id=<span class="code-quote">"cors-server"</span> scope=<span class="code-quote">"prototype"</span> 
-	      class=<span class="code-quote">"org.apache.cxf.systest.jaxrs.cors.AnnotatedCorsServer"</span> /&gt; 
+        &lt;bean id="cors-server" scope="prototype" 
+	      class="org.apache.cxf.systest.jaxrs.cors.AnnotatedCorsServer" /&gt; 
 
-<span class="code-tag">&lt;/beans&gt;</span>
+&lt;/beans&gt;
 
-</pre>
+]]></script>
 </div></div></div>
            </div>
            <!-- Content -->