You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bu...@apache.org on 2013/11/30 19:48:11 UTC

svn commit: r888637 - in /websites/production/cxf/content: cache/docs.pageCache docs/validationfeature.html

Author: buildbot
Date: Sat Nov 30 18:48:11 2013
New Revision: 888637

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 Sat Nov 30 18:48:11 2013
@@ -28,6 +28,15 @@
 <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>
+  SyntaxHighlighter.defaults['toolbar'] = false;
+  SyntaxHighlighter.all();
+</script>
 
 
     <title>
@@ -123,7 +132,7 @@ Apache CXF -- ValidationFeature
 <div id="ConfluenceContent"><p><span style="font-size:2em;font-weight:bold"> Bean Validation Feature </span></p>
 
 <div>
-<ul><li><a shape="rect" href="#ValidationFeature-Introduction">Introduction</a></li><li><a shape="rect" href="#ValidationFeature-Dependencies">Dependencies</a></li><ul><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></ul></div>
+<ul><ul><li><a shape="rect" href="#ValidationFeature-Introduction">Introduction</a></li><li><a shape="rect" href="#ValidationFeature-Dependencies">Dependencies</a></li><ul><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></ul><li><a shape="rect" href="#ValidationFeature-BeanValidation1.1andJAXRS2.0integration">Bean Validation 1.1 and JAX-RS 2.0 integration</a></li><ul><li><a shape="rect" href="#ValidationFeature-ConfiguringBeanValidation1.1usingJAXRSServerFactoryBean">Configuring Bean Validation 1.1 using JAXRSServerFactoryBean</a></li></ul></ul></div>
 
 <h2><a shape="rect" name="ValidationFeature-Introduction"></a>Introduction</h2>
 <p>Among many other features, JAX-RS 2.0 specification introduces Bean Validation 1.1 support as a mandatory part of implementation. In an effort to fulfill this requirement, Apache CXF provides full-fledge validation support for JAX-RS / JAX-WS endpoints, both for request parameters and response values.</p>
@@ -180,7 +189,31 @@ Apache CXF -- ValidationFeature
     &lt;version&gt;1.1.0-alpha-SNAPSHOT&lt;/version&gt;
 &lt;/dependency&gt;
 </pre>
-</div></div></div>
+</div></div>
+
+<h1><a shape="rect" name="ValidationFeature-BeanValidation1.1andJAXRS2.0integration"></a>Bean Validation 1.1 and JAX-RS 2.0 integration</h1>
+
+<p>Bean Validation 1.1 support in JAX-RS 2.0 is built on top of three main components:</p>
+<ul class="alternate" type="square"><li>in-interceptor (org.apache.cxf.jaxrs.validation.JAXRSBeanValidationInInterceptor): validates REST/WS endpoint parameters before invoking the method</li><li>out-interceptor (org.apache.cxf.jaxrs.validation.JAXRSBeanValidationOutInterceptor): validates REST/WS endpoint return value after the method invocation</li><li>exception mapper (org.apache.cxf.jaxrs.validation.ValidationExceptionMapper): transforms any ValidationException to corresponding HTTP status code</li></ul>
+
+
+<p>All these components may share the single instance of org.apache.cxf.validation.BeanValidationProvider which actually delegates all validation logic to available Bean Validation 1.1 implementation.</p>
+
+<h2><a shape="rect" name="ValidationFeature-ConfiguringBeanValidation1.1usingJAXRSServerFactoryBean"></a>Configuring Bean Validation 1.1 using JAXRSServerFactoryBean</h2>
+
+<p>It's quite easy to enable bean validation support using JAXRSServerFactoryBean as following code snippet shows:</p>
+<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
+<script class="theme: Default; brush: java; gutter: false" type="syntaxhighlighter"><![CDATA[
+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();
+]]></script>
+</div></div>
+</div>
            </div>
            <!-- Content -->
          </td>