cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: Minor update to validation features to support the injection of the validation provider too
Date Wed, 16 Apr 2014 15:23:34 GMT
Repository: cxf
Updated Branches:
  refs/heads/master fd835f2a8 -> 82774ce60


Minor update to validation features to support the injection of the validation provider too


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/82774ce6
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/82774ce6
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/82774ce6

Branch: refs/heads/master
Commit: 82774ce60cc8fc708fad3239975151157a56ffc3
Parents: fd835f2
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Apr 16 16:23:15 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Apr 16 16:23:15 2014 +0100

----------------------------------------------------------------------
 .../cxf/validation/BeanValidationFeature.java   | 18 ++++++++++++++---
 .../validation/JAXRSBeanValidationFeature.java  | 21 +++++++++++++++++---
 2 files changed, 33 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/82774ce6/core/src/main/java/org/apache/cxf/validation/BeanValidationFeature.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/validation/BeanValidationFeature.java b/core/src/main/java/org/apache/cxf/validation/BeanValidationFeature.java
index 395c580..e5516fc 100644
--- a/core/src/main/java/org/apache/cxf/validation/BeanValidationFeature.java
+++ b/core/src/main/java/org/apache/cxf/validation/BeanValidationFeature.java
@@ -25,9 +25,21 @@ import org.apache.cxf.interceptor.InterceptorProvider;
 
 public class BeanValidationFeature extends AbstractFeature {
 
+    private BeanValidationProvider validationProvider;
+    
     @Override
-    protected void initializeProvider(InterceptorProvider provider, Bus bus) {
-        provider.getInInterceptors().add(new BeanValidationInInterceptor());
-        provider.getOutInterceptors().add(new BeanValidationOutInterceptor());
+    protected void initializeProvider(InterceptorProvider interceptorProvider, Bus bus) {
+        BeanValidationInInterceptor in = new BeanValidationInInterceptor();
+        BeanValidationOutInterceptor out = new BeanValidationOutInterceptor();
+        if (validationProvider != null) {
+            in.setProvider(validationProvider);
+            out.setProvider(validationProvider);
+        }
+        interceptorProvider.getInInterceptors().add(in);
+        interceptorProvider.getOutInterceptors().add(out);
+    }
+
+    public void setProvider(BeanValidationProvider provider) {
+        this.validationProvider = provider;
     }
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/82774ce6/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationFeature.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationFeature.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationFeature.java
index 4db2ce0..186a3e6 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationFeature.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/validation/JAXRSBeanValidationFeature.java
@@ -21,13 +21,28 @@ package org.apache.cxf.jaxrs.validation;
 import org.apache.cxf.Bus;
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.interceptor.InterceptorProvider;
+import org.apache.cxf.validation.BeanValidationInInterceptor;
+import org.apache.cxf.validation.BeanValidationOutInterceptor;
+import org.apache.cxf.validation.BeanValidationProvider;
 
 
 public class JAXRSBeanValidationFeature extends AbstractFeature {
 
+    private BeanValidationProvider validationProvider;
+    
     @Override
-    protected void initializeProvider(InterceptorProvider provider, Bus bus) {
-        provider.getInInterceptors().add(new JAXRSBeanValidationInInterceptor());
-        provider.getOutInterceptors().add(new JAXRSBeanValidationOutInterceptor());
+    protected void initializeProvider(InterceptorProvider interceptorProvider, Bus bus) {
+        BeanValidationInInterceptor in = new JAXRSBeanValidationInInterceptor();
+        BeanValidationOutInterceptor out = new JAXRSBeanValidationOutInterceptor();
+        if (validationProvider != null) {
+            in.setProvider(validationProvider);
+            out.setProvider(validationProvider);
+        }
+        interceptorProvider.getInInterceptors().add(in);
+        interceptorProvider.getOutInterceptors().add(out);
+    }
+
+    public void setProvider(BeanValidationProvider provider) {
+        this.validationProvider = provider;
     }
 }


Mime
View raw message