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 2020/02/14 10:20:09 UTC
[camel] branch master updated: CAMEL-14564: camel-webhook - Init
delegate endpoint eager so its not null for camel-k
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 ca15b27 CAMEL-14564: camel-webhook - Init delegate endpoint eager so its not null for camel-k
ca15b27 is described below
commit ca15b277cb42af4f2c69baf318ce9717bee6d1f6
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Fri Feb 14 11:19:46 2020 +0100
CAMEL-14564: camel-webhook - Init delegate endpoint eager so its not null for camel-k
---
.../apache/camel/component/webhook/WebhookComponent.java | 2 ++
.../apache/camel/component/webhook/WebhookEndpoint.java | 15 ++++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookComponent.java b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookComponent.java
index ffed773..f056560 100644
--- a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookComponent.java
+++ b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookComponent.java
@@ -58,6 +58,8 @@ public class WebhookComponent extends DefaultComponent {
RestConfiguration restConfig = getCamelContext().getRestConfiguration(config.getWebhookComponentName(), true);
config.setRestConfiguration(restConfig);
+
+ endpoint.afterPropertiesConfigured(getCamelContext());
return endpoint;
}
diff --git a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookEndpoint.java b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookEndpoint.java
index a577057..dd10b36 100644
--- a/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookEndpoint.java
+++ b/components/camel-webhook/src/main/java/org/apache/camel/component/webhook/WebhookEndpoint.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.webhook;
+import org.apache.camel.AfterPropertiesConfigured;
+import org.apache.camel.CamelContext;
import org.apache.camel.Consumer;
import org.apache.camel.DelegateEndpoint;
import org.apache.camel.Endpoint;
@@ -25,7 +27,6 @@ import org.apache.camel.spi.RestConsumerFactory;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.support.DefaultEndpoint;
-import org.apache.camel.support.ObjectHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,7 +35,7 @@ import org.slf4j.LoggerFactory;
* webhook endpoints and automatically register them with their own webhook provider.
*/
@UriEndpoint(firstVersion = "3.0.0", scheme = "webhook", title = "Webhook", syntax = "webhook:endpointUri", consumerOnly = true, label = "cloud", lenientProperties = true)
-public class WebhookEndpoint extends DefaultEndpoint implements DelegateEndpoint {
+public class WebhookEndpoint extends DefaultEndpoint implements DelegateEndpoint, AfterPropertiesConfigured {
private static final Logger LOG = LoggerFactory.getLogger(WebhookEndpoint.class);
@@ -68,15 +69,19 @@ public class WebhookEndpoint extends DefaultEndpoint implements DelegateEndpoint
}
@Override
- protected void doStart() throws Exception {
- super.doStart();
-
+ public void afterPropertiesConfigured(CamelContext camelContext) {
+ // setup delegate endpoint in constructor
Endpoint delegate = getCamelContext().getEndpoint(configuration.getEndpointUri());
if (!(delegate instanceof WebhookCapableEndpoint)) {
throw new IllegalArgumentException("The provided endpoint is not capable of being used in webhook mode: " + configuration.getEndpointUri());
}
delegateEndpoint = (WebhookCapableEndpoint) delegate;
delegateEndpoint.setWebhookConfiguration(configuration);
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
if (configuration.isWebhookAutoRegister()) {
LOG.info("Registering webhook for endpoint: {}", delegateEndpoint);