Modified: websites/production/cxf/content/docs/http-binding.html ============================================================================== --- websites/production/cxf/content/docs/http-binding.html (original) +++ websites/production/cxf/content/docs/http-binding.html Wed Sep 13 15:05:52 2017 @@ -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/shBrushJava.js'></script> <script src='/resources/highlighter/scripts/shBrushXml.js'></script> +<script src='/resources/highlighter/scripts/shBrushJava.js'></script> <script> SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); @@ -125,7 +125,7 @@ Apache CXF -- HTTP Binding <h1 id="HTTPBinding-Conventionbasedservices">Convention based services</h1> <p>If you have a simple CRUD based Java class, CXF can try to build up a set of resources automatically for you with no annotations or configuration. This is best explained through an example. Lets take a look at a typical CRUD class:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> import javax.jws.WebService; @WebService @@ -148,7 +148,7 @@ public interface PeopleService { <p>That's straightforward enough. We see "get", we map it to a GET operation. Then people is extracted from the operation name and turned into a simple URI. Accessing <a shape="rect" class="external-link" href="http://server/people" rel="nofollow">http://server/people</a> would result in a document like so:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> <getPeople> <Person>...</Person> <Person>...</Person> @@ -177,7 +177,7 @@ public interface PeopleService { <h2 id="HTTPBinding-Configuringtheservice">Configuring the service</h2> <p>You can create a service which uses the HTTP binding by using JaxWsFactoryBean:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean(); sf.setServiceClass(PeopleService.class); sf.getServiceFactory().setWrapped(true); @@ -201,7 +201,7 @@ Server svr = sf.create(); <p>Lets say I want to build an HTTP service that shares and manipulates customer data. The first thing I might want to do is create a URI that returns a document of all the customers in my database. With the JRA annotations this would be done like so:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> @Get @HttpResource(location="/customers") Collection<Customer> getCustomers(); @@ -213,7 +213,7 @@ Collection<Customer> getCustomers( <p>Now lets say I want to pull down a specific customer, from /customers/ID:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> @Get @HttpResource(location="/customers/{id}") Customer getCustomers(GetCustomer getCustomer); @@ -222,7 +222,7 @@ Customer getCustomers(GetCustomer getCus <p>The major new concept in this example is URI templates. The GetCustomer object has a single property named "id":</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> public class GetCustomer { String getId() { .. } void setId(String id) { .. } @@ -231,7 +231,7 @@ public class GetCustomer { <p>The URI parameters get mapped to the XML document according to its schema and the WSDL 2 rules. So if you access the URL /customers/123 CXF will actually synthesize an incoming XML document like this:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> <getCustomer><id>123</id></getCustomer> </pre> </div></div> @@ -239,7 +239,7 @@ public class GetCustomer { <p>The databinding layer will then convert this into the GetCustomer object. Lets move on to a more complex example - a PUT operation which updates the customer:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> @Put @HttpResource(location="/customers/{id}") Customer updateCustomer(Customer customer); @@ -251,7 +251,7 @@ Customer updateCustomer(Customer custome <p>For a final example, lets look at adding a customer:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> @Post @HttpResource(location="/customers") void addCustomer(Customer customer); @@ -264,7 +264,7 @@ void addCustomer(Customer customer); <p>To use multiple arguments, the @WebParam annotation has to be used to map the parameters of the url to the service parameters.<br clear="none"> For example:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> @Get @HttpResource(location="/customers/{first}/{last}") void findCustomer(@WebParam(name="first") String firstName, @WebParam(name="last") String lastName); @@ -274,7 +274,7 @@ void findCustomer(@WebParam(name="first" <h2 id="HTTPBinding-ConfiguringtheService">Configuring the Service</h2> <p>Configuration for JRA style services is exactly the same as the convention based services. However, in this example, the service is not in "wrapped" mode. So the configuration is slightly different as we don't need to explicitly set the wrapped setting:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean(); sf.setServiceClass(CustomerService.class); sf.setBindingFactory(new HttpBindingInfoFactoryBean()); @@ -290,7 +290,7 @@ Server svr = sf.create(); <h2 id="HTTPBinding-ConfiguringtheserviceincontainerwithSpringconfigurationfile.">Configuring the service in container with Spring configuration file.</h2> <h3 id="HTTPBinding-web.xml">web.xml</h3> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app @@ -327,7 +327,7 @@ Server svr = sf.create(); <h3 id="HTTPBinding-beans.xml">beans.xml</h3> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" @@ -362,14 +362,14 @@ Server svr = sf.create(); <h1 id="HTTPBinding-Wrappedvs.UnwrappedMode">Wrapped vs. Unwrapped Mode</h1> <p>In REST style services we can only send and receive one XML element. Wrapping is the process of wrapping the XML requests/responses with the operation names to allow multiple parameters to your operation. For instance, say we had an operation "Customer findCustomer(String name, String company)". It would not be valid to create an XML POST request like this:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> <name>Dan</name> <company>Acme Inc</company> </pre> </div></div> <p>That has two root XML elements, which isn't allowed. Instead we would have to "wrap" the POST with the operation name:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> <findCustomers> <name>Dan</name> <company>Acme Inc</company> @@ -378,7 +378,7 @@ Server svr = sf.create(); </div></div> <p>You may be wondering why don't we always turn on wrapping? Well wrapping creates uglier XML. Take this operation for instance: Collection<Customer> getCustomers(). The resulting XML would be:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> <getCustomersResponse> <Customers> <Customer>..</Customer>
Modified: websites/production/cxf/content/docs/interceptors.html ============================================================================== --- websites/production/cxf/content/docs/interceptors.html (original) +++ websites/production/cxf/content/docs/interceptors.html Wed Sep 13 15:05:52 2017 @@ -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/shBrushJava.js'></script> <script src='/resources/highlighter/scripts/shBrushXml.js'></script> +<script src='/resources/highlighter/scripts/shBrushJava.js'></script> <script> SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); @@ -118,7 +118,7 @@ Apache CXF -- Interceptors <!-- Content --> <div class="wiki-content"> <div id="ConfluenceContent"><h1 id="Interceptors-InterceptorsandPhases">Interceptors and Phases</h1><p>Interceptors are the fundamental processing unit inside CXF. When a service is invoked, an InterceptorChain is created and invoked. Each interceptor gets a chance to do what they want with the message. This can include reading it, transforming it, processing headers, validating the message, etc.</p><p>Interceptors are used with both CXF clients and CXF servers. When a CXF client invokes a CXF server, there is an outgoing interceptor chain for the client and an incoming chain for the server. When the server sends the response back to the client, there is an outgoing chain for the server and an incoming one for the client. Additionally, in the case of <a shape="rect" class="external-link" href="http://java.sun.com/j2ee/1.4/docs/api/javax/xml/soap/SOAPFault.html" rel="nofollow">SOAPFaults</a>, a CXF web service will create a separate outbound error handling chain and the client will c reate an inbound error handling chain.</p><p>Some examples of interceptors inside CXF include:</p><ul><li>SoapActionInterceptor - Processes the SOAPAction header and selects an operation if it's set.</li><li>StaxInInterceptor - Creates a Stax XMLStreamReader from the transport input stream.</li><li>Attachment(In/Out)Interceptor - Turns a multipart/related message into a series of attachments.</li></ul><p>InterceptorChains are divided up into Phases. The phase that each interceptor runs in is declared in the interceptor's constructor. Each phase may contain many interceptors. On the incoming chains, you'll have the following phases:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Phase</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Functions</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>RECEIVE</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Transport level process ing</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>(PRE/USER/POST)_STREAM</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Stream level processing/transformations</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>READ</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>This is where header reading typically occurs.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>(PRE/USER/POST)_PROTOCOL</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Protocol processing, such as JAX-WS SOAP handlers</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>UNMARSHAL</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Unmarshalling of the request</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>(PRE/USER/POST)_LOGICAL</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Processing of the umarshalled request</p></td></tr><tr><td colspan="1" rowspan="1" class="confl uenceTd"><p>PRE_INVOKE</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Pre invocation actions</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>INVOKE</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Invocation of the service</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>POST_INVOKE</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Invocation of the outgoing chain if there is one</p></td></tr></tbody></table></div><p>On the outgoing chain there are the following phases:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Phase</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Functions</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>SETUP</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Any set up for the following phases</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>(PRE/USER/ POST)_LOGICAL</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Processing of objects about to marshalled</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>PREPARE_SEND</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Opening of the connection</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>PRE_STREAM</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>PRE_PROTOCOL</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Misc protocol actions.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>WRITE</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Writing of the protocol message, such as the SOAP Envelope.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>MARSHAL</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Marshalling of the objects</p></td></tr><tr><td colspan="1" rowspan=" 1" class="confluenceTd"><p>(USER/POST)_PROTOCOL</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Processing of the protocol message.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>(USER/POST)_STREAM</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Processing of the byte level message</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>SEND</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr></tbody></table></div><p>After the SEND phase, there are a bunch of "*_ENDING" phases that are symmetrical to the above phases to allow the interceptors to cleanup and close anything that they had opened or started in the above phases:</p><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Phase</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Functions</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>SEND_ENDING< /p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>POST_STREAM_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>USER_STREAM_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>POST_PROTOCOL_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>USER_PROTOCOL_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>MARSHAL_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>WRITE_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></t d></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>PRE_PROTOCOL_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>PRE_STREAM_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>PREPARE_SEND_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>POST_LOGICAL_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>USER_LOGICAL_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>PRE_LOGICAL_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p> </p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>S ETUP_ENDING</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Usually results in all the streams being closed and the final data being sent on the wire.</p></td></tr></tbody></table></div><h1 id="Interceptors-InterceptorProviders">InterceptorProviders</h1><p>Several different components inside CXF may provide interceptors to an InterceptorChain. These implement the InterceptorProvider interface:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">public interface InterceptorProvider { +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public interface InterceptorProvider { List<Interceptor> getInInterceptors(); @@ -130,11 +130,11 @@ Apache CXF -- Interceptors } </pre> </div></div><p>To add an interceptor to an interceptor chain, you'll want to add it to one of the Interceptor Providers.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">MyInterceptor interceptor = new MyInterceptor(); +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">MyInterceptor interceptor = new MyInterceptor(); provider.getInInterceptors().add(interceptor); </pre> </div></div><p>Some InterceptorProviders inside CXF are:</p><ul><li>Client</li><li>Endpoint</li><li>Service</li><li>Bus</li><li>Binding</li></ul><h1 id="Interceptors-WritingandconfiguringanInterceptor">Writing and configuring an Interceptor</h1><p>The CXF distribution is shipped with a demo called <a shape="rect" class="external-link" href="http://svn.apache.org/viewvc/cxf/trunk/distribution/src/main/release/samples/configuration_interceptor/">configuration_interceptor </a> which shows how to develop a user interceptor and configure the interceptor into its interceptor chain.</p><h2 id="Interceptors-WritinganInterceptor">Writing an Interceptor</h2><p>Writing an interceptor is relatively simple. Your interceptor needs to extend from either the AbstractPhaseInterceptor or one of its <a shape="rect" class="external-link" href="http://tinyurl.com/3bkho8" rel="nofollow">many subclasses</a> such as AbstractSoapInterceptor. Extending from AbstractPhaseInterceptor allows your interceptor to access the methods of the <a shape="rect" class="external-link" href="http://tinyurl.com/24gj28" rel="nofollow">Message</a> interface. For example, AttachmentInInterceptor is used in CXF to turn a multipart/related message into a series of attachments. It looks like below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">import java.io.IOException; +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">import java.io.IOException; import org.apache.cxf.attachment.AttachmentDeserializer; import org.apache.cxf.message.Message; @@ -163,7 +163,7 @@ public class AttachmentInInterceptor ext } </pre> </div></div><p>Extending from sub-classes of AbstractPhaseInterceptor allows your interceptor to access more specific information than those in the Message interface. One of the sub-classes of AbstractPhaseInterceptor is <a shape="rect" class="external-link" href="http://tinyurl.com/2xqyg6" rel="nofollow">AbstractSoapInterceptor</a>. Extending from this class allows your interceptor to access the SOAP header and version information of the <a shape="rect" class="external-link" href="http://tinyurl.com/2gxj2c" rel="nofollow">SoapMessage class</a>. For example, SoapActionInInterceptor is used in CXF to parse the SOAP action, as a simplified version of it shows below:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">import java.util.Collection; +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">import java.util.Collection; import java.util.List; import java.util.Map; @@ -236,7 +236,7 @@ public class SoapActionInInterceptor ext } </pre> </div></div><p>Note that you will need to specify the phase that the interceptor will be included in. This is done in the interceptor's constructor:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">public class MyInterceptor extends AbstractSoapInterceptor { +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class MyInterceptor extends AbstractSoapInterceptor { public MyInterceptor() { super(Phase.USER_PROTOCOL); } @@ -244,7 +244,7 @@ public class SoapActionInInterceptor ext } </pre> </div></div><p>You can also express that you would like the interceptor to run before/after certain other interceptors defined in the same phase:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">public class MyInterceptor extends AbstractSoapInterceptor { +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">public class MyInterceptor extends AbstractSoapInterceptor { public MyInterceptor() { super(Phase.USER_PROTOCOL); @@ -258,7 +258,7 @@ public class SoapActionInInterceptor ext } </pre> </div></div><p>You can add your interceptors into the interceptor chain either programmatically or through configuration.</p><h2 id="Interceptors-Addinginterceptorsprogrammatically">Adding interceptors programmatically</h2><p>To add this to your server, you'll want to get access to the Server object (see <a shape="rect" href="server-service-and-client-factorybeans.html">here</a> for more info):</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">import org.apache.cxf.endpoint.Server; +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">import org.apache.cxf.endpoint.Server; import org.apache.cxf.frontend.ServerFactoryBean; ... @@ -268,7 +268,7 @@ Server server = serverFactoryBean.create server.getEndpoint().getInInterceptor().add(myInterceptor); </pre> </div></div><p>On the Client side the process is very similar:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">import org.apache.cxf.endpoint.Client; +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">import org.apache.cxf.endpoint.Client; import org.apache.cxf.frontend.ClientProxy; ... @@ -284,7 +284,7 @@ cxfClient.getInInterceptors().add(myInte client.doSomething(); </pre> </div></div><p>You can also use annotation to add the interceptors from the SEI or service class. When CXF create the server or client, CXF will add the interceptor according with the annotation.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">@org.apache.cxf.interceptor.InInterceptors (interceptors = {"com.example.Test1Interceptor" }) +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;">@org.apache.cxf.interceptor.InInterceptors (interceptors = {"com.example.Test1Interceptor" }) @org.apache.cxf.interceptor.InFaultInterceptors (interceptors = {"com.example.Test2Interceptor" }) @org.apache.cxf.interceptor.OutInterceptors (interceptors = {"com.example.Test1Interceptor" }) @org.apache.cxf.interceptor.InFaultInterceptors (interceptors = {"com.example.Test2Interceptor","com.example.Test3Intercetpor" }) @@ -298,7 +298,7 @@ public class SayHiImplementation impleme } </pre> </div></div><h2 id="Interceptors-Addinginterceptorsthroughconfiguration">Adding interceptors through configuration</h2><p>The <a shape="rect" href="configuration.html">configuration file</a> page provides examples on using configuration files to add interceptors.</p><p>Adding MyInterceptor to the bus:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"><beans xmlns="http://www.springframework.org/schema/beans" +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation=" @@ -321,7 +321,7 @@ http://cxf.apache.org/core http://cxf.ap </pre> </div></div><p>For embedded Jetty-based web services, the configuration file can be declared by starting the service with the -Dcxf.config.file=server.xml option. See the <a shape="rect" class="external-link" href="http://tinyurl.com/2c9fuf" rel="nofollow">server configuration</a> section on the configuration file page for information on specifying the file for servlet WAR file-based web service implementations.</p><p>Adding MyInterceptor to your client:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"><beans xmlns="http://www.springframework.org/schema/beans" +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:http="http://cxf.apache.org/transports/http/configuration" xsi:schemaLocation="http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd Modified: websites/production/cxf/content/docs/invokers.html ============================================================================== --- websites/production/cxf/content/docs/invokers.html (original) +++ websites/production/cxf/content/docs/invokers.html Wed Sep 13 15:05:52 2017 @@ -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/shBrushJava.js'></script> <script src='/resources/highlighter/scripts/shBrushBash.js'></script> +<script src='/resources/highlighter/scripts/shBrushJava.js'></script> <script> SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); @@ -121,7 +121,7 @@ Apache CXF -- Invokers <p>CXF does provide a number of bundled invokers to handle simple cases. One of these simple cases is when it is desirable to have a singleton for the service object. In this case, you would like to provide a single object instance that should be used for all service invocations. The provided BeanInvoker covers this functionality, and would be used as follows:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> Service service = ...; service.setInvoker(new BeanInvoker(new MyCustomBean(someParams))); </pre> @@ -129,7 +129,7 @@ service.setInvoker(new BeanInvoker(new M <p>You can access the underlying Service object in two ways. If you've created your service using a ServerFactoryBean, this will yield a Server object which can be used to gain access to the Service:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> ServerFactoryBean factory = new ServerFactoryBean(); .... Server server = factory.create() @@ -138,7 +138,7 @@ Service service = server.getEndpoint().g </div></div> <p>If you've created a JAX-WS Endpoint object, you can access the Service like this:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> EndpointImpl endpoint = (EndpointImpl) Endpoint.publish("http://host/service", new MyService()); .... Server server = endpoint.getServer(); @@ -150,7 +150,7 @@ Service service = server.getEndpoint().g <p>The invoker implementation is as follows:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> public class EJBInvoker extends AbstractInvoker { private EJBHome home; @@ -183,14 +183,14 @@ public class EJBInvoker extends Abstract </div></div> <p>Invokers, once defined, need to be registered with the Service. Once a handle onto a Service object has been obtained, the example invoker above can be registered on the binding like this:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> Service ejbService = ....; ejbService.setInvoker(new EJBInvoker(ejbHome)); </pre> </div></div> <p>If you are using an EJB3 container you can use the following invoker, which is just a simplified version of the above:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> public class EJB3Invoker extends AbstractInvoker { private Object ejb; @@ -208,7 +208,7 @@ public class EJB3Invoker extends Abstrac <h2 id="Invokers-Executors">Executors</h2> <p>In addition to providing your own Invokers, you can also supply Executors for your service. Executors are a way to control scheduling for your service. To supply your own executor for a service just do:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> Service service = ....; // look up the service from CXF, or create it service.setExecutor(new MyExecutor()); </pre> Modified: websites/production/cxf/content/docs/java-to-ws.html ============================================================================== --- websites/production/cxf/content/docs/java-to-ws.html (original) +++ websites/production/cxf/content/docs/java-to-ws.html Wed Sep 13 15:05:52 2017 @@ -163,7 +163,7 @@ Apache CXF -- Java to WS <p>The java2ws command can be wrapped inside an Ant target as shown below:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> <?xml version="1.0"?> <project name="cxf java2ws" basedir="."> <property name="cxf.home" location ="/usr/myapps/cxf-trunk"/> Modified: websites/production/cxf/content/docs/java-to-wsdl.html ============================================================================== --- websites/production/cxf/content/docs/java-to-wsdl.html (original) +++ websites/production/cxf/content/docs/java-to-wsdl.html Wed Sep 13 15:05:52 2017 @@ -32,9 +32,9 @@ <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/shBrushJava.js'></script> -<script src='/resources/highlighter/scripts/shBrushXml.js'></script> <script src='/resources/highlighter/scripts/shBrushBash.js'></script> +<script src='/resources/highlighter/scripts/shBrushXml.js'></script> +<script src='/resources/highlighter/scripts/shBrushJava.js'></script> <script> SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); @@ -120,7 +120,7 @@ Apache CXF -- Java to WSDL <div class="wiki-content"> <div id="ConfluenceContent"><h2 id="JavatoWSDL-Synopsis">Synopsis</h2> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> java2wsdl [-?|-help|-h][-o <output-file>][-cp <class-path>][-soap12][-t <target-namespace>][-servicenam <seservice-name>][-v][-verbose|-quiet][-s <source-directory>] [-classdir <compile-classes-directory>][-portname <port-name>][-createxsdimports][-d <output-directory>] { classname } </pre> @@ -157,7 +157,7 @@ java2wsdl [-?|-help|-h][-o <output-fi <p>The java2wsdl command can be wrapped inside an Ant target as shown below:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> <?xml version="1.0"?> <project name="cxf java2wsdl" basedir="."> <property name="cxf.home" location ="/usr/myapps/cxf-2.0.1"/> Modified: websites/production/cxf/content/docs/javascript-client-code.html ============================================================================== --- websites/production/cxf/content/docs/javascript-client-code.html (original) +++ websites/production/cxf/content/docs/javascript-client-code.html Wed Sep 13 15:05:52 2017 @@ -132,7 +132,7 @@ Apache CXF -- JavaScript Client Code <p>The Schema code generates one object for each 'bean' used in your service. This code is organized by XML Schema. The code for each schema starts with a comment like:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> // // Definitions for schema: http://apache.org/hello_world_soap_http/types // file:/home/benson/cxf/trunk/distribution/src/main/release/samples/js_browser_client/wsdl/hello_world.wsdl#types1 @@ -145,7 +145,7 @@ Apache CXF -- JavaScript Client Code <p>A typical JavaScript class for a type looks like:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> function apache_org_hello_world_soap_http_types_sayHiResponse () { this._responseType = ''; } @@ -167,7 +167,7 @@ apache_org_hello_world_soap_http_types_s <p>The code for a service starts with a comment, followed by a constructor for the per-service object:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> // Javascript for {http://apache.org/hello_world_soap_http}Greeter function apache_org_hello_world_soap_http_Greeter () { @@ -222,7 +222,7 @@ fault information as a third parameter t <p>The present author finds that, at least for JAX-WS, BARE has a lot to recommend it, as it avoids surprising interactions between JAX-WS and JAXB. </p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> function errorCallback(httpStatus, httpStatusText) { @@ -257,7 +257,7 @@ function compliantTest(url) <p>The following function calls a Document/Literal/Bare method. The bare parameter element is declared as:</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> <element name="acceptAny1"> <complexType> <sequence> @@ -287,7 +287,7 @@ defined in the WSDL's schemas. To constr <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> function testAny1ToServerChalk(url) { var service = new cxf_apache_org_jstest_any_AcceptAny(); @@ -322,7 +322,7 @@ org_apache_cxf_any_holder. However, the 'false'. CXF may be enhanced to support passing non-described elements to JavaScript at a later time. </p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> function testAny1ToServerRaw(url) { var service = new cxf_apache_org_jstest_any_AcceptAny(); Modified: websites/production/cxf/content/docs/javascript-client-samples.html ============================================================================== --- websites/production/cxf/content/docs/javascript-client-samples.html (original) +++ websites/production/cxf/content/docs/javascript-client-samples.html Wed Sep 13 15:05:52 2017 @@ -119,7 +119,7 @@ Apache CXF -- JavaScript Client Samples <div id="ConfluenceContent"><p>So far, there is one sample in the distribution. This sample, called js_browser_client_simple, provides an HTML user interface to the tiny hello_world service also present in the wsdl_first sample. The HTML page for the sample is here. This gives a flavor of an HTML page invoking a web service via the CXF JavaScript client generator.</p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> <!-- Generate and retrieve a JavaScript client for the server. --> <script type="text/javascript" src="/SoapContext/SoapPort?js"></script> <script type="text/javascript"> Modified: websites/production/cxf/content/docs/javascript.html ============================================================================== --- websites/production/cxf/content/docs/javascript.html (original) +++ websites/production/cxf/content/docs/javascript.html Wed Sep 13 15:05:52 2017 @@ -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/shBrushJava.js'></script> <script src='/resources/highlighter/scripts/shBrushBash.js'></script> +<script src='/resources/highlighter/scripts/shBrushJava.js'></script> <script> SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); @@ -149,7 +149,7 @@ Apache CXF -- JavaScript <p><span class="confluence-anchor-link" id="JavaScript-ex1"></span></p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Example 1:JavaScript Metadata</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> var WebServiceProvider1 = { 'wsdlLocation': 'file:./wsdl/hello_world.wsdl', 'serviceName': 'SOAPService1', @@ -167,7 +167,7 @@ var WebServiceProvider1 = { <p><span class="confluence-anchor-link" id="JavaScript-ex2"></span></p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Example 2:JavaScript Service Implementation</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> WebServiceProvider.invoke = function(document) { var ns4 = "http://apache.org/hello_world_soap_http/types"; var list = document.getElementsByTagNameNS(ns4, "requestType"); @@ -191,7 +191,7 @@ WebServiceProvider.invoke = function(doc <p><span class="confluence-anchor-link" id="JavaScript-ex3"></span></p> <div class="code panel pdl" style="border-width: 1px;"><div class="codeHeader panelHeader pdl" style="border-bottom-width: 1px;"><b>Example 3:E4X Service Implementation</b></div><div class="codeContent panelContent pdl"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> var SOAP_ENV = new Namespace('SOAP-ENV', 'http://schemas.xmlsoap.org/soap/envelope/'); var xs = new Namespace('xs', 'http://www.w3.org/2001/XMLSchema'); 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 Wed Sep 13 15:05:52 2017 @@ -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/shBrushJava.js'></script> <script src='/resources/highlighter/scripts/shBrushXml.js'></script> +<script src='/resources/highlighter/scripts/shBrushJava.js'></script> <script> SyntaxHighlighter.defaults['toolbar'] = false; SyntaxHighlighter.all(); @@ -121,25 +121,25 @@ Apache CXF -- JAX-RS Advanced Features  </p><p> </p><p> </p><p> </p><p> </p><p><style type="text/css">/*<![CDATA[*/ -div.rbtoc1505311237001 {padding: 0px;} -div.rbtoc1505311237001 ul {list-style: disc;margin-left: 0px;} -div.rbtoc1505311237001 li {margin-left: 0px;padding-left: 0px;} +div.rbtoc1505314929247 {padding: 0px;} +div.rbtoc1505314929247 ul {list-style: disc;margin-left: 0px;} +div.rbtoc1505314929247 li {margin-left: 0px;padding-left: 0px;} -/*]]>*/</style></p><div class="toc-macro rbtoc1505311237001"> +/*]]>*/</style></p><div class="toc-macro rbtoc1505314929247"> <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"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"><jaxrs:server serviceName="s:BookService" transportId="http://cxf.apache.org/transports/jms" address="/"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><jaxrs:server serviceName="s:BookService" transportId="http://cxf.apache.org/transports/jms" address="/"> <jaxrs:serviceBeans> <bean class="org.apache.cxf.systest.jaxrs.JMSBookStore"/> </jaxrs:serviceBeans> </jaxrs:server> </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"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">// setup the the client +<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" + "&replyToName=dynamicQueues/test.jmstransport.response" @@ -152,7 +152,7 @@ assertEquals("Get a wrong response code. 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"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"><context-param> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><context-param> <param-name>webAppRootKey</param-name> <param-value>ehcache-cxf</param-value> </context-param> @@ -171,7 +171,7 @@ assertEquals("Get a wrong book id.", 123 </filter-mapping> </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: bash; gutter: false; theme: Confluence" style="font-size:12px;"><ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../main/config/ehcache.xsd" updateCheck="false" monitoring="autodetect" @@ -194,7 +194,7 @@ assertEquals("Get a wrong book id.", 123 </ehcache> </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"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;"><model xmlns="http://cxf.apache.org/jaxrs"> +<pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"><model xmlns="http://cxf.apache.org/jaxrs"> <resource name="org.apache.cxf.systest.jaxrs.BookStoreNoAnnotations" path="bookstore" produces="application/json" consumes="application/json"> <operation name="getBook" verb="GET" path="/books/{id}" produces="application/xml"> @@ -216,7 +216,7 @@ assertEquals("Get a wrong book id.", 123 </model> </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"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); +<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"; sf.setModelRef(modelRef); @@ -228,14 +228,14 @@ sf.setModelRef(modelRef); 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"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">JAXRSClientFactoryBean cf = new JAXRSClientFactoryBean(); +<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"> -<pre class="brush: bash; gutter: false; theme: Confluence" style="font-size:12px;">public class JAXRSUserModelServlet extends CXFNonSpringJaxrsServlet { +<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 {