You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/12/07 08:22:53 UTC
[camel] branch master updated: CAMEL-14263: camel-cm-sms should use
source code generated configurer to avoid reflection configuration.
This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 ce91776 CAMEL-14263: camel-cm-sms should use source code generated configurer to avoid reflection configuration.
ce91776 is described below
commit ce917762c310073c3ac8cc75b4ae6780dbaf8f2e
Author: Claus Ibsen <cl...@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);