Author: buildbot
Date: Mon Nov 28 22:47:04 2016
New Revision: 1001797

Log:
Production update by buildbot for cxf

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

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

Modified: websites/production/cxf/content/docs/validationfeature.html
==============================================================================
--- websites/production/cxf/content/docs/validationfeature.html (original)
+++ websites/production/cxf/content/docs/validationfeature.html Mon Nov 28 
22:47:04 2016
@@ -0,0 +1,362 @@
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd";>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+  <head>
+
+<link type="text/css" rel="stylesheet" href="/resources/site.css">
+<script src='/resources/space.js'></script>
+
+<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 - 
ValidationFeature">
+
+
+<link type="text/css" rel="stylesheet" 
href="/resources/highlighter/styles/shCoreCXF.css">
+<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>
+  SyntaxHighlighter.defaults['toolbar'] = false;
+  SyntaxHighlighter.all();
+</script>
+
+
+    <title>
+Apache CXF -- ValidationFeature
+    </title>
+  </head>
+<body onload="init()">
+
+
+<table width="100%" cellpadding="0" cellspacing="0">
+  <tr>
+    <td id="cell-0-0" colspan="2">&nbsp;</td>
+    <td id="cell-0-1">&nbsp;</td>
+    <td id="cell-0-2" colspan="2">&nbsp;</td>
+  </tr>
+  <tr>
+    <td id="cell-1-0">&nbsp;</td>
+    <td id="cell-1-1">&nbsp;</td>
+    <td id="cell-1-2">
+      <!-- Banner -->
+<div class="banner" id="banner"><div><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></div>
+      <!-- Banner -->
+      <div id="top-menu">
+        <table border="0" cellpadding="1" cellspacing="0" width="100%">
+          <tr>
+            <td>
+              <div align="left">
+                <!-- Breadcrumbs -->
+<a href="index.html">Index</a>&nbsp;&gt;&nbsp;<a 
href="configuration.html">Configuration</a>&nbsp;&gt;&nbsp;<a 
href="featureslist.html">FeaturesList</a>&nbsp;&gt;&nbsp;<a 
href="validationfeature.html">ValidationFeature</a>
+                <!-- Breadcrumbs -->
+              </div>
+            </td>
+            <td>
+              <div align="right">
+                <!-- Quicklinks -->
+<div id="quicklinks"><p><a shape="rect" 
href="http://cxf.apache.org/download.html";>Download</a> | <a shape="rect" 
href="http://cxf.apache.org/docs/index.html";>Documentation</a></p></div>
+                <!-- Quicklinks -->
+              </div>
+            </td>
+          </tr>
+        </table>
+      </div>
+    </td>
+    <td id="cell-1-3">&nbsp;</td>
+    <td id="cell-1-4">&nbsp;</td>
+  </tr>
+  <tr>
+    <td id="cell-2-0" colspan="2">&nbsp;</td>
+    <td id="cell-2-1">
+      <table>
+        <tr valign="top">
+          <td height="100%">
+            <div id="wrapper-menu-page-right">
+              <div id="wrapper-menu-page-top">
+                <div id="wrapper-menu-page-bottom">
+                  <div id="menu-page">
+                    <!-- NavigationBar -->
+<div id="navigation"><ul class="alternate"><li><a shape="rect" 
href="overview.html">Overview</a></li><li><a shape="rect" 
href="how-tos.html">How-Tos</a></li><li><a shape="rect" 
href="frontends.html">Frontends</a></li><li><a shape="rect" 
href="databindings.html">DataBindings</a></li><li><a shape="rect" 
href="transports.html">Transports</a></li><li><a shape="rect" 
href="configuration.html">Configuration</a></li><li><a shape="rect" 
href="debugging-and-logging.html">Debugging and Logging</a></li><li><a 
shape="rect" href="tools.html">Tools</a></li><li><a shape="rect" 
href="restful-services.html">RESTful Services</a></li><li><a shape="rect" 
href="wsdl-bindings.html">WSDL Bindings</a></li><li><a shape="rect" 
href="service-routing.html">Service Routing</a></li><li><a shape="rect" 
href="dynamic-languages.html">Dynamic Languages</a></li><li><a shape="rect" 
href="ws-support.html">WS-* Support</a></li><li><a shape="rect" 
href="advanced-integration.html">Advanced Integration</a></li><li><a shape
 ="rect" href="deployment.html">Deployment</a></li><li><a shape="rect" 
href="schemas-and-namespaces.html">Use of Schemas and 
Namespaces</a></li></ul><hr><ul 
class="alternate"><li><p>Search</p></li></ul><form 
enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" 
action="http://www.google.com/cse";>
+  <div>
+    <input type="hidden" name="cx" value="002890367768291051730:o99qiwa09y4">
+    <input type="hidden" name="ie" value="UTF-8">
+    <input type="text" name="q" size="21">
+    <input type="submit" name="sa" value="Search">
+  </div>
+</form>
+<script type="text/javascript" 
src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en";></script><hr><ul
 class="alternate"><li><a shape="rect" 
href="http://cxf.apache.org/javadoc/latest/";>API 3.1.x (Javadoc)</a></li><li><a 
shape="rect" href="http://cxf.apache.org/javadoc/latest-3.0.x/";>API 3.0.x 
(Javadoc)</a></li><li><a shape="rect" href="http://cxf.apache.org/";>CXF 
Website</a></li></ul></div>
+                    <!-- NavigationBar -->
+                  </div>
+              </div>
+            </div>
+          </div>
+         </td>
+         <td height="100%">
+           <!-- Content -->
+           <div class="wiki-content">
+<div id="ConfluenceContent"><h1 
id="ValidationFeature-BeanValidationFeature">Bean Validation 
Feature</h1><p>&#160;</p><p><style type="text/css">/*<![CDATA[*/
+div.rbtoc1480373191673 {padding: 0px;}
+div.rbtoc1480373191673 ul {list-style: disc;margin-left: 0px;}
+div.rbtoc1480373191673 li {margin-left: 0px;padding-left: 0px;}
+
+/*]]>*/</style></p><div class="toc-macro rbtoc1480373191673">
+<ul class="toc-indentation"><li><a shape="rect" 
href="#ValidationFeature-BeanValidationFeature">Bean Validation 
Feature</a></li><li><a shape="rect" 
href="#ValidationFeature-Introduction">Introduction</a></li><li><a shape="rect" 
href="#ValidationFeature-Dependencies">Dependencies</a>
+<ul class="toc-indentation"><li><a shape="rect" 
href="#ValidationFeature-UsingHibernateValidatorasbeanvalidationprovider">Using 
Hibernate Validator as bean validation provider</a></li><li><a shape="rect" 
href="#ValidationFeature-UsingApacheBValasbeanvalidationprovider">Using Apache 
BVal as bean validation provider</a></li></ul>
+</li><li><a shape="rect" 
href="#ValidationFeature-CommonBeanValidation1.1Interceptors">Common Bean 
Validation 1.1 Interceptors</a>
+<ul class="toc-indentation"><li><a shape="rect" 
href="#ValidationFeature-Configuration">Configuration</a></li></ul>
+</li><li><a shape="rect" 
href="#ValidationFeature-BeanValidation1.1andJAX-RS2.0">Bean Validation 1.1 and 
JAX-RS 2.0</a>
+<ul class="toc-indentation"><li><a shape="rect" 
href="#ValidationFeature-Server">Server</a>
+<ul class="toc-indentation"><li><a shape="rect" 
href="#ValidationFeature-Validationofnon-singletonserviceobjects">Validation of 
non-singleton service objects</a></li><li><a shape="rect" 
href="#ValidationFeature-ConfiguringBeanValidation1.1usingJAXRSServerFactoryBean">Configuring
 Bean Validation 1.1 using JAXRSServerFactoryBean</a></li><li><a shape="rect" 
href="#ValidationFeature-ConfiguringBeanValidation1.1usingSpringbeandefinitionsXML">Configuring
 Bean Validation 1.1 using Spring bean definitions XML</a></li><li><a 
shape="rect" 
href="#ValidationFeature-ValidationExceptionsandHTTPstatuscodes">Validation 
Exceptions and HTTP status codes</a></li></ul>
+</li><li><a shape="rect" href="#ValidationFeature-ClientProxies">Client 
Proxies</a></li></ul>
+</li><li><a shape="rect" 
href="#ValidationFeature-CustomizingValidationProvider">Customizing Validation 
Provider</a></li><li><a shape="rect" 
href="#ValidationFeature-Examples">Examples</a>
+<ul class="toc-indentation"><li><a shape="rect" 
href="#ValidationFeature-Validatingsimpleinputparameters">Validating simple 
input parameters</a></li><li><a shape="rect" 
href="#ValidationFeature-Validatingcomplexinputparameters">Validating complex 
input parameters</a></li><li><a shape="rect" 
href="#ValidationFeature-Validatingreturnvalues(non-Response)">Validating 
return values (non-Response)</a></li><li><a shape="rect" 
href="#ValidationFeature-Validatingreturnvalues(Response)">Validating return 
values (Response)</a></li></ul>
+</li><li><a shape="rect" 
href="#ValidationFeature-BeanValidationandSchemaValidation">Bean Validation and 
Schema Validation</a></li></ul>
+</div><h1 id="ValidationFeature-Introduction">Introduction</h1><p>Bean 
Validation 1.1 (JSR-349), an evolution of Bean Validation 1.0 (JSR-303), 
introduces declarative constraints (based on Java annotations) to define the 
expectations for:</p><ul class="alternate"><li>properties of Java 
Beans</li><li>method and constructor parameters</li><li>method return 
values</li></ul><p>For example:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" 
style="font-size:12px;">public class Person {
+    @NotNull private String firstName;
+    @NotNull private String lastName;
+    @Valid @NotNull private Person boss;
+
+    public @NotNull String saveItem( @Valid @NotNull Person person, @Max( 23 ) 
BigDecimal age ) {
+        // ...
+    }
+}
+</pre>
+</div></div><p>Bean Validation API has been part of JPA 2.0 (JSR-317) and has 
proven to be successful and very useful, helping developers to delegate routine 
validation tasks to the solid, very extensible framework. It is very easy to 
create own constraints, including complex cross-field ones.</p><h1 
id="ValidationFeature-Dependencies">Dependencies</h1><p>Bean Validation support 
in Apache CXF is implementation-independent and is built solely using Bean 
Validation API. The required dependencies are:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default" 
style="font-size:12px;">&lt;dependency&gt;
+    &lt;groupId&gt;javax.validation&lt;/groupId&gt;
+    &lt;artifactId&gt;validation-api&lt;/artifactId&gt;
+    &lt;version&gt;1.1.0.Final&lt;/version&gt;
+&lt;/dependency&gt;
+&lt;dependency&gt;
+    &lt;groupId&gt;javax.el&lt;/groupId&gt;
+    &lt;artifactId&gt;javax.el-api&lt;/artifactId&gt;
+    &lt;!-- use 3.0-b02 version for Java 6 --&gt;
+    &lt;version&gt;3.0.0&lt;/version&gt;
+&lt;/dependency&gt;
+&lt;dependency&gt;
+    &lt;groupId&gt;org.glassfish&lt;/groupId&gt;
+    &lt;artifactId&gt;javax.el&lt;/artifactId&gt;
+    &lt;!-- use 3.0-b01 version for Java 6 --&gt;
+    &lt;version&gt;3.0.0/version&gt;
+&lt;/dependency&gt;
+</pre>
+</div></div><p>A couple of API implementations is available. Please note that 
if no implementation is detected on the runtime class-path then the constraints 
validation won't have any effect.</p><h2 
id="ValidationFeature-UsingHibernateValidatorasbeanvalidationprovider">Using 
Hibernate Validator as bean validation provider</h2><p><a shape="rect" 
class="external-link" 
href="http://www.hibernate.org/subprojects/validator.html"; 
rel="nofollow">http://www.hibernate.org/subprojects/validator.html</a></p><p>Hibernate
 Validator is a mature and feature-rich validation provider with the full Bean 
Validation 1.1 support (as of version 5.x.x which is the reference 
implementation for JSR 349 - Bean Validation 1.1 API). Add the following 
dependency:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default" 
style="font-size:12px;">&lt;dependency&gt;
+    &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
+    &lt;artifactId&gt;hibernate-validator&lt;/artifactId&gt;
+    &lt;version&gt;5.0.2.Final&lt;/version&gt;
+&lt;/dependency&gt;
+</pre>
+</div></div><p>Hibernate Validator uses Java Expression Language 3.0 in order 
to provide better validation messages support.</p><h2 
id="ValidationFeature-UsingApacheBValasbeanvalidationprovider">Using Apache 
BVal as bean validation provider</h2><p><a shape="rect" class="external-link" 
href="http://bval.apache.org/";>http://bval.apache.org/</a></p><p>Current stable 
version of Apache BVal (0.5) doesn't support Bean Validation 1.1 but the 
upcoming 1.1.0 will have it fully implemented (at the moment 
1.1.0-alpha-SNAPSHOT could be used).</p><div class="preformatted panel" 
style="border-width: 1px;"><div class="preformattedContent panelContent">
+<pre>&lt;dependency&gt;
+    &lt;groupId&gt;org.apache.bval&lt;/groupId&gt;
+    &lt;artifactId&gt;bval-jsr&lt;/artifactId&gt;
+    &lt;version&gt;1.1.0-alpha-SNAPSHOT&lt;/version&gt;
+&lt;/dependency&gt;
+</pre>
+</div></div><h1 
id="ValidationFeature-CommonBeanValidation1.1Interceptors">Common Bean 
Validation 1.1 Interceptors</h1><p>JAX-RS and JAX-WS frontends can rely on the 
following common interceptors to get Bean Validation 1.1 done:</p><ul 
class="alternate"><li><a shape="rect" class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/core/src/main/java/org/apache/cxf/validation/BeanValidationInInterceptor.java";>org.apache.cxf.validation.BeanValidationInInterceptor</a>:
 validates resource method parameters against validation constraints, raises 
javax.validation.ConstraintViolationException if any violations are 
encountered</li></ul><ul class="alternate"><li><a shape="rect" 
class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/core/src/main/java/org/apache/cxf/validation/BeanValidationOutInterceptor.java";>org.apache.cxf.validation.BeanValidationOutInterceptor</a>:
 validates resource method response values against validation constraints, 
raises <a shape="rect" c
 lass="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/core/src/main/java/org/apache/cxf/validation/ResponseConstraintViolationException";>org.apache.cxf.validation.ResponseConstraintViolationException</a>
 if any violations are encountered.</li></ul><p>Both interceptors depend on <a 
shape="rect" class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/core/src/main/java/org/apache/cxf/validation/BeanValidationProvider.java";>org.apache.cxf.validation.BeanValidationProvider</a>
 which abstracts away Bean Validation 1.1 API and provides useful utility 
methods. This provider can be directly injected into the interceptors as a 
'provider' property. Injecting the provider is optional, the interceptors will 
create a default provider instance if it has not been injected.</p><p>CXF 
exception handlers can check if a caught javax.validation.ValidationException 
is an instance of CXF-specific ResponseConstraintViolationException in order to 
find whether the failure occurr
 ed during the return value validation or not.</p><p>The provider can be 
initialized with javax.validation.ParameterNameProvider or <a shape="rect" 
class="external-link" 
href="http://svn.apache.org/repos/asf/cxf/trunk/core/src/main/java/org/apache/cxf/validation/ValidationConfiguration.java";>ValidationConfiguration</a>
 in order to customize the way Bean Validation 1.1 implementation does its 
work.</p><p>Note that interceptors will only be effective if the current 
service object is a singleton. They will make a best effort of getting hold of 
a reference to the current service object, which can also be injected directly 
as a 'serviceObject' property.</p><p>Custom interceptors can customize the 
default processing (for example, see the section on Bean Validation 1.1 in 
JAX-RS 2.0). Typical customization is to have one of the input parameters or 
the response value unwrapped before it can be validated.</p><p><a shape="rect" 
class="external-link" href="http://svn.apache.org/repos/asf/cxf/tr
 
unk/core/src/main/java/org/apache/cxf/validation/BeanValidationFeature.java">org.apache.cxf.validation.BeanValidationFeature</a>
 can be used to register both in and out validation interceptors.</p><h2 
id="ValidationFeature-Configuration">Configuration</h2><p>The following 
snippets show how to get Bean Validation 1.1 interceptors activated for both 
JAX-RS and JAX-WS services using Spring:</p><div class="code panel pdl" 
style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" 
style="font-size:12px;">// Interface implemented by both JAX-RS and JAX-WS 
services:
+@WebService(targetNamespace = "http://bookworld.com";)
+@Path("/")
+public interface BookWorld {
+
+    @POST
+    @Produces("text/xml")
+    @Consumes("text/xml")
+    @Valid
+    BookWithValidation echoBook(@Valid BookWithValidation book);
+
+}
+
+@WebService(endpointInterface = 
"org.apache.cxf.systest.jaxrs.validation.spring.BookWorld",
+            serviceName = "BookWorld")
+public class BookWorldImpl implements BookWorld {
+
+    @Override
+    public BookWithValidation echoBook(BookWithValidation book) {
+        return book;
+    }
+}
+
+</pre>
+</div></div><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default" 
style="font-size:12px;">&lt;!-- JAX-RS and JAX-WS endpoints --&gt;
+&lt;jaxrs:server address="/bwrest"&gt;
+        &lt;jaxrs:serviceBeans&gt;
+            &lt;ref bean="bookWorldValidation"/&gt;
+        &lt;/jaxrs:serviceBeans&gt;
+        &lt;jaxrs:providers&gt;
+            &lt;ref bean="exceptionMapper"/&gt;
+        &lt;/jaxrs:providers&gt;
+        &lt;jaxrs:features&gt;
+            &lt;ref bean="commonValidationFeature" /&gt;
+        &lt;/jaxrs:features&gt;
+&lt;/jaxrs:server&gt;
+    
+&lt;jaxws:endpoint xmlns:s="http://bookworld.com"; 
+                serviceName="s:BookWorld" 
+                endpointName="s:BookWorldPort" 
+                implementor="#bookWorldValidation" 
+                address="/bwsoap"&gt;
+    &lt;jaxws:features&gt;
+        &lt;ref bean="commonValidationFeature" /&gt;
+     &lt;/jaxws:features&gt;
+&lt;/jaxws:endpoint&gt;                
+    
+&lt;bean id="bookWorldValidation" 
class="org.apache.cxf.systest.jaxrs.validation.spring.BookWorldImpl"/&gt;
+&lt;bean id="commonValidationFeature" 
class="org.apache.cxf.validation.BeanValidationFeature"/&gt;
+</pre>
+</div></div><p>Check the next section for more examples specific to 
JAX-RS.</p><h1 id="ValidationFeature-BeanValidation1.1andJAX-RS2.0">Bean 
Validation 1.1 and JAX-RS 2.0</h1><h2 
id="ValidationFeature-Server">Server</h2><p>JAX-RS 2.0 specification (Chapter 
7) introduces an optional requirement to get Bean Validation 1.1 
supported.</p><p>Using the common interceptors described in the previous 
section can be sufficient for JAX-RS 2.0 resource methods having their input 
parameters and response values validated.</p><p>However, if you need a response 
values wrapped in JAX-RS Response validated or make sure per-request service 
instances get validated then JAX-RS frontend specific interceptors and the 
invoker need to be used:</p><ul 
class="alternate"><li>org.apache.cxf.jaxrs.validation.JAXRSBeanValidationInInterceptor:
 validates JAX-RS resource method parameters. At the moment it is nearly 
identical to the common BeanValidationInInterceptor which it extends. It can 
also be used as a JAX-RS
  2.0 ContainerRequestFilter</li></ul><ul 
class="alternate"><li>org.apache.cxf.jaxrs.validation.JAXRSBeanValidationOutInterceptor:
 validates JAX-RS resource method return values, unwraps JAX-RS Response. It 
can also be used as a JAX-RS 2.0 ContainerResponseFilter</li></ul><ul 
class="alternate"><li>org.apache.cxf.jaxrs.validation.JAXRSBeanValidationFeature
 can be used to register both in and out validation interceptors.</li></ul><ul 
class="alternate"><li>org.apache.cxf.jaxrs.validation.JAXRSBeanValidationInvoker
 needs to be used for validating non-singleton service objects, see below for 
more information.</li></ul><p>Note the default JAX-RS ExceptionMapper 
(org.apache.cxf.jaxrs.validation.ValidationExceptionMapper) which transforms 
javax.validation.ValidationException to corresponding HTTP status code has to 
be registered. Users can register the custom mappers if 
preferred.</p><p>org.apache.cxf.jaxrs.validation.JAXRSParameterNameProvider can 
be registered directly with the common Bean
 ValidationProvider to get the error messages customized.</p><p>JAX-RS 2.0 
developers should prefer using JAX-RS frontend specific interceptors when 
possible to make sure JAX-RS specific fixes are picked up automatically.</p><h3 
id="ValidationFeature-Validationofnon-singletonserviceobjects">Validation of 
non-singleton service objects</h3><p>The non-singleton service objects are 
created in CXF JAXRSInvoker therefore its subclass 
org.apache.cxf.jaxrs.validation.JAXRSBeanValidationInvoker needs to be 
registered if these objects need to be validated.</p><p>Register it either in a 
jaxrs:invoker block when using Spring or Blueprint or with a "jaxrs.invoker" 
servlet init parameter when using CXFNonSpringJaxrsServlet.</p><p>&#160;</p><h3 
id="ValidationFeature-ConfiguringBeanValidation1.1usingJAXRSServerFactoryBean">Configuring
 Bean Validation 1.1 using JAXRSServerFactoryBean</h3><div class="code panel 
pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" 
style="font-size:12px;">JAXRSServerFactoryBean sf = new 
JAXRSServerFactoryBean();
+sf.setResourceClasses( ... );
+sf.setResourceProvider( ... );
+sf.setProvider(new ValidationExceptionMapper());
+sf.setInInterceptors(Arrays.&lt; Interceptor&lt; ? extends Message &gt; 
&gt;asList(new new JAXRSBeanValidationInInterceptor()));
+sf.setOutInterceptors(Arrays.&lt; Interceptor&lt; ? extends Message &gt; 
&gt;asList(new JAXRSBeanValidationOutInterceptor()));
+sf.create();
+</pre>
+</div></div><h3 
id="ValidationFeature-ConfiguringBeanValidation1.1usingSpringbeandefinitionsXML">Configuring
 Bean Validation 1.1 using Spring bean definitions XML</h3><p>Following the 
similar approach as for JAXRSServerFactoryBean, in case of Spring respective 
bean definitions should be added under &lt;jaxrs:outInterceptors&gt;, 
&lt;jaxrs:inInterceptors&gt; and &lt;jaxrs:providers&gt; sections, 
f.e.:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
+<pre class="brush: xml; gutter: false; theme: Default" 
style="font-size:12px;">&lt;jaxrs:server address="/"&gt;
+    &lt;jaxrs:inInterceptors&gt;
+        &lt;ref bean="validationInInterceptor" /&gt;
+    &lt;/jaxrs:inInterceptors&gt;
+        
+    &lt;jaxrs:outInterceptors&gt;
+        &lt;ref bean="validationOutInterceptor" /&gt;
+    &lt;/jaxrs:outInterceptors&gt;
+        
+    &lt;jaxrs:serviceBeans&gt;
+    ...
+    &lt;/jaxrs:serviceBeans&gt;
+        
+    &lt;jaxrs:providers&gt;
+        &lt;ref bean="exceptionMapper"/&gt;
+    &lt;/jaxrs:providers&gt;
+&lt;/jaxrs:server&gt;
+
+&lt;bean id="exceptionMapper" 
class="org.apache.cxf.jaxrs.validation.ValidationExceptionMapper"/&gt;
+&lt;bean id="validationProvider" 
class="org.apache.cxf.validation.BeanValidationProvider" /&gt;
+
+&lt;bean id="validationInInterceptor" 
class="org.apache.cxf.jaxrs.validation.JAXRSBeanValidationInInterceptor"&gt;
+    &lt;property name="provider" ref="validationProvider" /&gt;
+&lt;/bean&gt;
+
+&lt;bean id="validationOutInterceptor" 
class="org.apache.cxf.jaxrs.validation.JAXRSBeanValidationOutInterceptor"&gt;
+    &lt;property name="provider" ref="validationProvider" /&gt;
+&lt;/bean&gt;   
+</pre>
+</div></div><h3 
id="ValidationFeature-ValidationExceptionsandHTTPstatuscodes">Validation 
Exceptions and HTTP status codes</h3><p>As per JAX-RS 2.0 specification, any 
input parameter validation violation is mapped to HTTP status code 400 Bad 
Request and any return value validation violation (or internal validation 
violation) is mapped to HTTP status code 500 Internal Server Error. This is 
essentially what org.apache.cxf.jaxrs.validation.ValidationExceptionMapper 
does.</p><div class="confluence-information-macro 
confluence-information-macro-note"><span class="aui-icon aui-icon-small 
aui-iconfont-warning confluence-information-macro-icon"></span><div 
class="confluence-information-macro-body"><p>The details of validation 
exceptions are not currently included into the response but only logged. 
Application developers are encouraged to register custom exception mappers if 
reporting the validation error details is required.</p></div></div><h2 
id="ValidationFeature-ClientProxies">Client Prox
 ies</h2><p>CXF 3.1.9 introduces an 
org.apache.cxf.jaxrs.client.validation.JAXRSClientBeanValidationFeature which 
can be used to validate the request parameters of a JAX-RS proxy method.</p><h1 
id="ValidationFeature-CustomizingValidationProvider">Customizing Validation 
Provider</h1><p><a shape="rect" class="external-link" 
href="https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=core/src/main/java/org/apache/cxf/validation/BeanValidationProvider.java;h=2efc7a15f79646d93af9588244c726832221461d;hb=HEAD";>org.apache.cxf.validation.BeanValidationProvider</a>
 is a wrapper around javax.validation.ValidationFactory and used by CXF 
validation interceptors.</p><p>It is created if it has not been injected. 
However if one needs to customize javax.validation.ValidationFactory then a 
custom BeanValidationProvider instance can be injected via the 'provider' 
property into</p><p>the bean validation interceptors.BeanValidationProvider has 
the default constructor, the one accepting javax.validat
 ion.ParameterNameProvider, etc, see the source for more details.</p><p>For 
example, one can customize the way parameters can be described on the JAX-RS 
path by injecting <a shape="rect" class="external-link" 
href="https://git-wip-us.apache.org/repos/asf?p=cxf.git;a=blob;f=rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSParameterNameProvider.java;h=62898defcedf0f1f27505273a9ae34dc9adea528;hb=HEAD";>JAXRSParameterNameProvider</a>
 into BeanValidationProvider.</p><h1 
id="ValidationFeature-Examples">Examples</h1><p>The following examples show 
JAX-RS resource methods being validated but predefined or custom Bean 
Validation 1.1 constraints can be applied to JAX-WS service methods exactly the 
same way.</p><h2 
id="ValidationFeature-Validatingsimpleinputparameters">Validating simple input 
parameters</h2><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" 
style="font-size:12px;">@POST
+@Path("/books")
+public Response addBook(
+        @NotNull @Pattern(regexp = "\\d+") @FormParam("id") String id,
+        @NotNull @Size(min = 1, max = 50) @FormParam("name") String name) {
+    // do some work
+    return Response.created().build();
+}
+</pre>
+</div></div><h2 
id="ValidationFeature-Validatingcomplexinputparameters">Validating complex 
input parameters</h2><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" 
style="font-size:12px;">@POST
+@Path("/books")
+public Response addBook( @Valid Book book ) {
+    // do some work
+    return Response.created().build();
+}
+</pre>
+</div></div><p>This example assumes that class Book has validation constraints 
defined:</p><div class="code panel pdl" style="border-width: 1px;"><div 
class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" 
style="font-size:12px;">public class Book {
+    @NotNull @Pattern(regexp = "\\d+") private String id;
+    @NotNull @Size(min = 1, max = 50) private String name;
+
+    // ...
+}
+</pre>
+</div></div><h2 
id="ValidationFeature-Validatingreturnvalues(non-Response)">Validating return 
values (non-Response)</h2><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" 
style="font-size:12px;">@GET
+@Path("/books/{bookId}")
+@Override    
+@NotNull @Valid
+public Book getBook(@PathParam("bookId") String id) {
+    return new Book( id );     
+}
+</pre>
+</div></div><p>This example assumes that class Book has validation constraints 
defined (as in example above).</p><h2 
id="ValidationFeature-Validatingreturnvalues(Response)">Validating return 
values (Response)</h2><div class="code panel pdl" style="border-width: 
1px;"><div class="codeContent panelContent pdl">
+<pre class="brush: java; gutter: false; theme: Default" 
style="font-size:12px;">@GET
+@Path("/books/{bookId}")
+@Valid @NotNull
+public Response getBookResponse(@PathParam("bookId") String id) {
+    return Response.ok( new Book( id ) ).build();
+}
+</pre>
+</div></div><h1 id="ValidationFeature-BeanValidationandSchemaValidation">Bean 
Validation and Schema Validation</h1><p>Web service developers often rely on 
the schema-based validation.</p><p>Bean validation can be used as an 
alternative form of validation.</p><p>However it can also complement the 
schema-based validation in cases where the current schema is not very 
strict.</p></div>
+           </div>
+           <!-- Content -->
+         </td>
+        </tr>
+      </table>
+   </td>
+   <td id="cell-2-2" colspan="2">&nbsp;</td>
+  </tr>
+  <tr>
+   <td id="cell-3-0">&nbsp;</td>
+   <td id="cell-3-1">&nbsp;</td>
+   <td id="cell-3-2">
+     <div id="footer">
+       <!-- Footer -->
+       <div id="site-footer">
+         <a href="http://cxf.apache.org/privacy-policy.html";>Privacy 
Policy</a> - 
+         (<a 
href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=34842111";>edit
 page</a>) 
+        (<a 
href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=34842111&amp;showComments=true&amp;showCommentArea=true#addcomment";>add
 comment</a>)<br>
+       Apache CXF, CXF, Apache, the Apache feather logo are trademarks of The 
Apache Software Foundation.<br>
+        All other marks mentioned may be trademarks or registered trademarks 
of their respective owners.
+       </div>
+       <!-- Footer -->
+     </div>
+   </td>
+   <td id="cell-3-3">&nbsp;</td>
+   <td id="cell-3-4">&nbsp;</td>
+  </tr>
+  <tr>
+    <td id="cell-4-0" colspan="2">&nbsp;</td>
+    <td id="cell-4-1">&nbsp;</td>
+    <td id="cell-4-2" colspan="2">&nbsp;</td>
+  </tr>
+</table>
+
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl."; : 
"http://www.";);
+document.write(unescape("%3Cscript src='" + gaJsHost + 
"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+try {
+var pageTracker = _gat._getTracker("UA-4458903-1");
+pageTracker._trackPageview();
+} catch(err) {}</script>
+
+</body>
+</html>
+


Reply via email to