camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [camel] branch camel-3.0.x updated: CAMEL-14263: camel-cm-sms should use source code generated configurer to avoid reflection configuration.
Date Sat, 07 Dec 2019 08:32:45 GMT
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-3.0.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-3.0.x by this push:
     new ce3ffa1  CAMEL-14263: camel-cm-sms should use source code generated configurer to
avoid reflection configuration.
ce3ffa1 is described below

commit ce3ffa106f373760e8b502d79914daf6a5f2db2b
Author: Claus Ibsen <claus.ibsen@gmail.com>
AuthorDate: Sat Dec 7 09:22:17 2019 +0100

    CAMEL-14263: camel-cm-sms should use source code generated configurer to avoid reflection
configuration.
---
 .../org/apache/camel/component/cm/CMComponent.java | 24 +++++++++-------------
 .../org/apache/camel/component/cm/CMEndpoint.java  |  2 +-
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMComponent.java
b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMComponent.java
index 179d6a9..e2bd9f6 100644
--- a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMComponent.java
+++ b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMComponent.java
@@ -47,14 +47,13 @@ public class CMComponent extends DefaultComponent {
 
     @Override
     protected Endpoint createEndpoint(final String uri, final String remaining, final Map<String,
Object> parameters) throws Exception {
-
-        // Set configuration based on uri parameters
-        final CMConfiguration config = new CMConfiguration();
-        setProperties(config, parameters);
+        CMEndpoint endpoint = new CMEndpoint(uri, this);
+        endpoint.setHost(remaining);
+        setProperties(endpoint, parameters);
 
         // Validate configuration
         log.debug("Validating uri based configuration");
-        final Set<ConstraintViolation<CMConfiguration>> constraintViolations
= getValidator().validate(config);
+        final Set<ConstraintViolation<CMConfiguration>> constraintViolations
= getValidator().validate(endpoint.getConfiguration());
         if (constraintViolations.size() > 0) {
             final StringBuffer msg = new StringBuffer();
             for (final ConstraintViolation<CMConfiguration> cv : constraintViolations)
{
@@ -65,22 +64,19 @@ public class CMComponent extends DefaultComponent {
             throw new ResolveEndpointFailedException(uri, msg.toString());
         }
 
-        // Component is an Endpoint factory. So far, just one Endpoint type.
-        // Endpoint construction and configuration.
-
-        final CMEndpoint endpoint = new CMEndpoint(uri, this);
-        endpoint.setConfiguration(config);
-        endpoint.setHost(remaining);
-
         return endpoint;
     }
 
     public Validator getValidator() {
+        return validator;
+    }
+
+    @Override
+    protected void doInit() throws Exception {
+        super.doInit();
         if (validator == null) {
             ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
             validator = factory.getValidator();
         }
-        return validator;
     }
-
 }
diff --git a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMEndpoint.java
b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMEndpoint.java
index 9ab3061..e3c3f41 100644
--- a/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMEndpoint.java
+++ b/components/camel-cm-sms/src/main/java/org/apache/camel/component/cm/CMEndpoint.java
@@ -38,7 +38,7 @@ public class CMEndpoint extends DefaultEndpoint {
     @Metadata(required = true)
     private String host;
     @UriParam
-    private CMConfiguration configuration;
+    private CMConfiguration configuration = new CMConfiguration();
 
     public CMEndpoint(final String uri, final CMComponent component) {
         super(uri, component);


Mime
View raw message