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 2022/01/02 13:18:13 UTC
[camel] branch main updated: CAMEL-17406: camel-core - InterceptFrom header with intercepted endpoint should be done without affecting model
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new a8a1b22 CAMEL-17406: camel-core - InterceptFrom header with intercepted endpoint should be done without affecting model
a8a1b22 is described below
commit a8a1b229aba084f5aa28abef85566a82f8bb092b
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Sun Jan 2 11:49:08 2022 +0100
CAMEL-17406: camel-core - InterceptFrom header with intercepted endpoint should be done without affecting model
---
.../apache/camel/reifier/InterceptFromReifier.java | 29 ++++++++--------------
1 file changed, 10 insertions(+), 19 deletions(-)
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/InterceptFromReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/InterceptFromReifier.java
index 114848e..a216a99 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/InterceptFromReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/InterceptFromReifier.java
@@ -16,13 +16,13 @@
*/
package org.apache.camel.reifier;
+import org.apache.camel.AsyncCallback;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.Route;
import org.apache.camel.model.InterceptFromDefinition;
import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.model.SetHeaderDefinition;
-import org.apache.camel.support.ExpressionAdapter;
+import org.apache.camel.support.processor.DelegateAsyncProcessor;
public class InterceptFromReifier extends InterceptReifier<InterceptFromDefinition> {
@@ -33,26 +33,17 @@ public class InterceptFromReifier extends InterceptReifier<InterceptFromDefiniti
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Processor createProcessor() throws Exception {
- // insert a set header definition so we can set the intercepted endpoint
- // uri as a header
- // this allows us to use the same header for both the interceptFrom and
- // interceptSendToEndpoint
- SetHeaderDefinition headerDefinition = new SetHeaderDefinition(Exchange.INTERCEPTED_ENDPOINT, new ExpressionAdapter() {
- public Object evaluate(Exchange exchange, Class type) {
+ final Processor child = this.createChildProcessor(true);
+
+ return new DelegateAsyncProcessor(child) {
+ @Override
+ public boolean process(Exchange exchange, AsyncCallback callback) {
if (exchange.getFromEndpoint() != null) {
- return exchange.getFromEndpoint().getEndpointUri();
- } else {
- return null;
+ exchange.getMessage().setHeader(Exchange.INTERCEPTED_ENDPOINT, exchange.getFromEndpoint().getEndpointUri());
}
+ return super.process(exchange, callback);
}
-
- public String toString() {
- return "";
- }
- });
- definition.getOutputs().add(0, headerDefinition);
-
- return this.createChildProcessor(true);
+ };
}
}