[camel] branch master updated: CAMEL-15146: Handle validatorFactory field in BeanValidatorComponentConfigurer

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[camel] branch master updated: CAMEL-15146: Handle validatorFactory field in BeanValidatorComponentConfigurer

jamesnetherton-2
This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/master by this push:
     new 2255a34  CAMEL-15146: Handle validatorFactory field in BeanValidatorComponentConfigurer
2255a34 is described below

commit 2255a346884d8f19fc761ab19d678b1c5661fb48
Author: James Netherton <[hidden email]>
AuthorDate: Fri Jun 5 10:59:54 2020 +0100

    CAMEL-15146: Handle validatorFactory field in BeanValidatorComponentConfigurer
---
 .../bean/validator/BeanValidatorComponentConfigurer.java    |  5 +++++
 .../camel/component/bean/validator/bean-validator.json      |  3 ++-
 .../src/main/docs/bean-validator-component.adoc             |  3 ++-
 .../component/bean/validator/BeanValidatorComponent.java    | 10 ++++++++++
 .../component/bean/validator/BeanValidatorEndpoint.java     |  8 ++++----
 .../bean/validator/BeanValidatorConfigurationTest.java      |  6 +++---
 .../component/bean/validator/ValidatorFactoryTest.java      |  8 ++++----
 .../component/dsl/BeanValidatorComponentBuilderFactory.java | 13 +++++++++++++
 .../modules/ROOT/pages/bean-validator-component.adoc        |  3 ++-
 9 files changed, 45 insertions(+), 14 deletions(-)

diff --git a/components/camel-bean-validator/src/generated/java/org/apache/camel/component/bean/validator/BeanValidatorComponentConfigurer.java b/components/camel-bean-validator/src/generated/java/org/apache/camel/component/bean/validator/BeanValidatorComponentConfigurer.java
index c0d5789..e948c9c 100644
--- a/components/camel-bean-validator/src/generated/java/org/apache/camel/component/bean/validator/BeanValidatorComponentConfigurer.java
+++ b/components/camel-bean-validator/src/generated/java/org/apache/camel/component/bean/validator/BeanValidatorComponentConfigurer.java
@@ -33,6 +33,8 @@ public class BeanValidatorComponentConfigurer extends PropertyConfigurerSupport
         case "traversableResolver": target.setTraversableResolver(property(camelContext, javax.validation.TraversableResolver.class, value)); return true;
         case "validationproviderresolver":
         case "validationProviderResolver": target.setValidationProviderResolver(property(camelContext, javax.validation.ValidationProviderResolver.class, value)); return true;
+        case "validatorfactory":
+        case "validatorFactory": target.setValidatorFactory(property(camelContext, javax.validation.ValidatorFactory.class, value)); return true;
         default: return false;
         }
     }
@@ -47,6 +49,7 @@ public class BeanValidatorComponentConfigurer extends PropertyConfigurerSupport
         answer.put("messageInterpolator", javax.validation.MessageInterpolator.class);
         answer.put("traversableResolver", javax.validation.TraversableResolver.class);
         answer.put("validationProviderResolver", javax.validation.ValidationProviderResolver.class);
+        answer.put("validatorFactory", javax.validation.ValidatorFactory.class);
         return answer;
     }
 
@@ -68,6 +71,8 @@ public class BeanValidatorComponentConfigurer extends PropertyConfigurerSupport
         case "traversableResolver": return target.getTraversableResolver();
         case "validationproviderresolver":
         case "validationProviderResolver": return target.getValidationProviderResolver();
+        case "validatorfactory":
+        case "validatorFactory": return target.getValidatorFactory();
         default: return null;
         }
     }
diff --git a/components/camel-bean-validator/src/generated/resources/org/apache/camel/component/bean/validator/bean-validator.json b/components/camel-bean-validator/src/generated/resources/org/apache/camel/component/bean/validator/bean-validator.json
index fe4c04e..a4f9753 100644
--- a/components/camel-bean-validator/src/generated/resources/org/apache/camel/component/bean/validator/bean-validator.json
+++ b/components/camel-bean-validator/src/generated/resources/org/apache/camel/component/bean/validator/bean-validator.json
@@ -27,7 +27,8 @@
     "constraintValidatorFactory": { "kind": "property", "displayName": "Constraint Validator Factory", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "javax.validation.ConstraintValidatorFactory", "deprecated": false, "secret": false, "description": "To use a custom ConstraintValidatorFactory" },
     "messageInterpolator": { "kind": "property", "displayName": "Message Interpolator", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "javax.validation.MessageInterpolator", "deprecated": false, "secret": false, "description": "To use a custom MessageInterpolator" },
     "traversableResolver": { "kind": "property", "displayName": "Traversable Resolver", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "javax.validation.TraversableResolver", "deprecated": false, "secret": false, "description": "To use a custom TraversableResolver" },
-    "validationProviderResolver": { "kind": "property", "displayName": "Validation Provider Resolver", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "javax.validation.ValidationProviderResolver", "deprecated": false, "secret": false, "description": "To use a a custom ValidationProviderResolver" }
+    "validationProviderResolver": { "kind": "property", "displayName": "Validation Provider Resolver", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "javax.validation.ValidationProviderResolver", "deprecated": false, "secret": false, "description": "To use a a custom ValidationProviderResolver" },
+    "validatorFactory": { "kind": "property", "displayName": "Validator Factory", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "javax.validation.ValidatorFactory", "deprecated": false, "secret": false, "description": "To use a custom ValidatorFactory" }
   },
   "properties": {
     "label": { "kind": "path", "displayName": "Label", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "secret": false, "description": "Where label is an arbitrary text value describing the endpoint" },
diff --git a/components/camel-bean-validator/src/main/docs/bean-validator-component.adoc b/components/camel-bean-validator/src/main/docs/bean-validator-component.adoc
index 67d7ddd..d105cb2 100644
--- a/components/camel-bean-validator/src/main/docs/bean-validator-component.adoc
+++ b/components/camel-bean-validator/src/main/docs/bean-validator-component.adoc
@@ -53,7 +53,7 @@ Where *label* is an arbitrary text value describing the endpoint. +
 
 
 // component options: START
-The Bean Validator component supports 7 options, which are listed below.
+The Bean Validator component supports 8 options, which are listed below.
 
 
 
@@ -67,6 +67,7 @@ The Bean Validator component supports 7 options, which are listed below.
 | *messageInterpolator* (advanced) | To use a custom MessageInterpolator |  | MessageInterpolator
 | *traversableResolver* (advanced) | To use a custom TraversableResolver |  | TraversableResolver
 | *validationProviderResolver* (advanced) | To use a a custom ValidationProviderResolver |  | ValidationProviderResolver
+| *validatorFactory* (advanced) | To use a custom ValidatorFactory |  | ValidatorFactory
 |===
 // component options: END
 
diff --git a/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorComponent.java b/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorComponent.java
index ba97c37..3e18c73 100644
--- a/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorComponent.java
+++ b/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorComponent.java
@@ -123,4 +123,14 @@ public class BeanValidatorComponent extends DefaultComponent {
         this.constraintValidatorFactory = constraintValidatorFactory;
     }
 
+    /**
+     * To use a custom {@link ValidatorFactory}
+     */
+    public void setValidatorFactory(ValidatorFactory validatorFactory) {
+        this.validatorFactory = validatorFactory;
+    }
+
+    public ValidatorFactory getValidatorFactory() {
+        return validatorFactory;
+    }
 }
diff --git a/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorEndpoint.java b/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorEndpoint.java
index 737ce75..6640b93 100644
--- a/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorEndpoint.java
+++ b/components/camel-bean-validator/src/main/java/org/apache/camel/component/bean/validator/BeanValidatorEndpoint.java
@@ -170,14 +170,14 @@ public class BeanValidatorEndpoint extends DefaultEndpoint {
         this.constraintValidatorFactory = constraintValidatorFactory;
     }
 
-    public ValidatorFactory getValidatorFactory() {
-        return validatorFactory;
-    }
-
     /**
      * To use a custom {@link ValidatorFactory}
      */
     public void setValidatorFactory(ValidatorFactory validatorFactory) {
         this.validatorFactory = validatorFactory;
     }
+
+    public ValidatorFactory getValidatorFactory() {
+        return validatorFactory;
+    }
 }
diff --git a/components/camel-bean-validator/src/test/java/org/apache/camel/component/bean/validator/BeanValidatorConfigurationTest.java b/components/camel-bean-validator/src/test/java/org/apache/camel/component/bean/validator/BeanValidatorConfigurationTest.java
index 39c0e7f..d9fb785 100644
--- a/components/camel-bean-validator/src/test/java/org/apache/camel/component/bean/validator/BeanValidatorConfigurationTest.java
+++ b/components/camel-bean-validator/src/test/java/org/apache/camel/component/bean/validator/BeanValidatorConfigurationTest.java
@@ -71,9 +71,9 @@ public class BeanValidatorConfigurationTest extends CamelTestSupport {
                          + "&traversableResolver=#myTraversableResolver" + "&constraintValidatorFactory=#myConstraintValidatorFactory", BeanValidatorEndpoint.class);
 
         assertEquals("org.apache.camel.component.bean.validator.OptionalChecks", endpoint.getGroup());
-        assertSame(endpoint.getMessageInterpolator(), this.messageInterpolator);
-        assertSame(endpoint.getTraversableResolver(), this.traversableResolver);
-        assertSame(endpoint.getConstraintValidatorFactory(), this.constraintValidatorFactory);
+        assertSame(this.messageInterpolator, endpoint.getMessageInterpolator());
+        assertSame(this.traversableResolver, endpoint.getTraversableResolver());
+        assertSame(this.constraintValidatorFactory, endpoint.getConstraintValidatorFactory());
     }
 
     class MyMessageInterpolator implements MessageInterpolator {
diff --git a/components/camel-bean-validator/src/test/java/org/apache/camel/component/bean/validator/ValidatorFactoryTest.java b/components/camel-bean-validator/src/test/java/org/apache/camel/component/bean/validator/ValidatorFactoryTest.java
index 193179a..73dba98 100644
--- a/components/camel-bean-validator/src/test/java/org/apache/camel/component/bean/validator/ValidatorFactoryTest.java
+++ b/components/camel-bean-validator/src/test/java/org/apache/camel/component/bean/validator/ValidatorFactoryTest.java
@@ -55,8 +55,8 @@ public class ValidatorFactoryTest extends CamelTestSupport {
         BeanValidatorEndpoint endpoint = context.getEndpoint("bean-validator:dummy?validatorFactory=#myValidatorFactory", BeanValidatorEndpoint.class);
         BeanValidatorProducer producer = (BeanValidatorProducer)endpoint.createProducer();
 
-        assertSame(endpoint.getValidatorFactory(), this.validatorFactory);
-        assertSame(producer.getValidatorFactory(), this.validatorFactory);
+        assertSame(this.validatorFactory, endpoint.getValidatorFactory());
+        assertSame(this.validatorFactory, producer.getValidatorFactory());
     }
 
     @DisabledOnOs(AIX)
@@ -67,8 +67,8 @@ public class ValidatorFactoryTest extends CamelTestSupport {
         BeanValidatorProducer producer = (BeanValidatorProducer)endpoint.createProducer();
 
         assertNull(endpoint.getValidatorFactory());
-        assertNotSame(endpoint.getValidatorFactory(), this.validatorFactory);
+        assertNotSame(this.validatorFactory, endpoint.getValidatorFactory());
         assertNotNull(producer.getValidatorFactory());
-        assertNotSame(producer.getValidatorFactory(), this.validatorFactory);
+        assertNotSame(this.validatorFactory, producer.getValidatorFactory());
     }
 }
diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/BeanValidatorComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/BeanValidatorComponentBuilderFactory.java
index c058747..407c8d2 100644
--- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/BeanValidatorComponentBuilderFactory.java
+++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/BeanValidatorComponentBuilderFactory.java
@@ -148,6 +148,18 @@ public interface BeanValidatorComponentBuilderFactory {
             doSetProperty("validationProviderResolver", validationProviderResolver);
             return this;
         }
+        /**
+         * To use a custom ValidatorFactory.
+         *
+         * The option is a: <code>javax.validation.ValidatorFactory</code> type.
+         *
+         * Group: advanced
+         */
+        default BeanValidatorComponentBuilder validatorFactory(
+                javax.validation.ValidatorFactory validatorFactory) {
+            doSetProperty("validatorFactory", validatorFactory);
+            return this;
+        }
     }
 
     class BeanValidatorComponentBuilderImpl
@@ -172,6 +184,7 @@ public interface BeanValidatorComponentBuilderFactory {
             case "messageInterpolator": ((BeanValidatorComponent) component).setMessageInterpolator((javax.validation.MessageInterpolator) value); return true;
             case "traversableResolver": ((BeanValidatorComponent) component).setTraversableResolver((javax.validation.TraversableResolver) value); return true;
             case "validationProviderResolver": ((BeanValidatorComponent) component).setValidationProviderResolver((javax.validation.ValidationProviderResolver) value); return true;
+            case "validatorFactory": ((BeanValidatorComponent) component).setValidatorFactory((javax.validation.ValidatorFactory) value); return true;
             default: return false;
             }
         }
diff --git a/docs/components/modules/ROOT/pages/bean-validator-component.adoc b/docs/components/modules/ROOT/pages/bean-validator-component.adoc
index cb69de1..dc6a4a5 100644
--- a/docs/components/modules/ROOT/pages/bean-validator-component.adoc
+++ b/docs/components/modules/ROOT/pages/bean-validator-component.adoc
@@ -55,7 +55,7 @@ Where *label* is an arbitrary text value describing the endpoint. +
 
 
 // component options: START
-The Bean Validator component supports 7 options, which are listed below.
+The Bean Validator component supports 8 options, which are listed below.
 
 
 
@@ -69,6 +69,7 @@ The Bean Validator component supports 7 options, which are listed below.
 | *messageInterpolator* (advanced) | To use a custom MessageInterpolator |  | MessageInterpolator
 | *traversableResolver* (advanced) | To use a custom TraversableResolver |  | TraversableResolver
 | *validationProviderResolver* (advanced) | To use a a custom ValidationProviderResolver |  | ValidationProviderResolver
+| *validatorFactory* (advanced) | To use a custom ValidatorFactory |  | ValidatorFactory
 |===
 // component options: END