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 93b0d7c CAMEL-15739: camel-core - Move AdviceWith from Reifier to Builder 93b0d7c is described below commit 93b0d7c1195332614dbb9a91364d094b2953f595 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Fri Oct 23 06:56:03 2020 +0200 CAMEL-15739: camel-core - Move AdviceWith from Reifier to Builder --- .../policy/MicroProfileMetricsRoutePolicyTest.java | 4 +- .../test/junit5/patterns/AdviceWithLambdaTest.java | 4 +- ...nterceptSendToEndpointWithLoadbalancerTest.java | 4 +- .../test/issues/AdviceWithOnCompletionTest.java | 4 +- .../AdviceWithOnExceptionMultipleIssueTest.java | 6 +- .../camel/test/patterns/AdviceWithLambdaTest.java | 4 +- .../java/org/apache/camel/builder/AdviceWith.java | 118 ++++++++++++++++++++- .../camel/builder/AdviceWithRouteBuilder.java | 92 +++++----------- .../interceptor/AdviceWithLambdaTest.java | 14 +-- .../ROOT/pages/camel-3x-upgrade-guide-3_7.adoc | 2 + 10 files changed, 162 insertions(+), 90 deletions(-) diff --git a/components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/route/policy/MicroProfileMetricsRoutePolicyTest.java b/components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/route/policy/MicroProfileMetricsRoutePolicyTest.java index 191abd8..c269678 100644 --- a/components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/route/policy/MicroProfileMetricsRoutePolicyTest.java +++ b/components/camel-microprofile-metrics/src/test/java/org/apache/camel/component/microprofile/metrics/route/policy/MicroProfileMetricsRoutePolicyTest.java @@ -20,7 +20,7 @@ import java.util.Arrays; import io.smallrye.metrics.TagsUtils; import org.apache.camel.CamelContext; -import org.apache.camel.builder.AdviceWithRouteBuilder; +import org.apache.camel.builder.AdviceWith; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.microprofile.metrics.MicroProfileMetricsHelper; import org.apache.camel.component.microprofile.metrics.MicroProfileMetricsTestSupport; @@ -103,7 +103,7 @@ public class MicroProfileMetricsRoutePolicyTest extends MicroProfileMetricsTestS @Test public void adviceWithTest() throws Exception { - AdviceWithRouteBuilder.adviceWith(context, "foo", advisor -> { + AdviceWith.adviceWith(context, "foo", advisor -> { advisor.replaceFromWith("direct:replaced"); }); assertEquals(6, countRouteMetrics("foo")); diff --git a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithLambdaTest.java b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithLambdaTest.java index 3ec84fc..2df582b 100644 --- a/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithLambdaTest.java +++ b/components/camel-test-junit5/src/test/java/org/apache/camel/test/junit5/patterns/AdviceWithLambdaTest.java @@ -17,7 +17,7 @@ package org.apache.camel.test.junit5.patterns; import org.apache.camel.RoutesBuilder; -import org.apache.camel.builder.AdviceWithRouteBuilder; +import org.apache.camel.builder.AdviceWith; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit5.CamelTestSupport; import org.junit.jupiter.api.Test; @@ -34,7 +34,7 @@ public class AdviceWithLambdaTest extends CamelTestSupport { getMockEndpoint("mock:result").expectedMessageCount(1); // advice the route in one line - AdviceWithRouteBuilder.adviceWith(context, "foo", a -> a.weaveAddLast().to("mock:result")); + AdviceWith.adviceWith(context, "foo", a -> a.weaveAddLast().to("mock:result")); // start Camel context.start(); diff --git a/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/issues/AdviceWithInterceptSendToEndpointWithLoadbalancerTest.java b/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/issues/AdviceWithInterceptSendToEndpointWithLoadbalancerTest.java index a19e0a1..689884e 100644 --- a/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/issues/AdviceWithInterceptSendToEndpointWithLoadbalancerTest.java +++ b/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/issues/AdviceWithInterceptSendToEndpointWithLoadbalancerTest.java @@ -16,7 +16,7 @@ */ package org.apache.camel.test.issues; -import org.apache.camel.builder.AdviceWithRouteBuilder; +import org.apache.camel.builder.AdviceWith; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.spring.junit5.CamelSpringTestSupport; import org.junit.jupiter.api.Test; @@ -39,7 +39,7 @@ public class AdviceWithInterceptSendToEndpointWithLoadbalancerTest extends Camel @Test public void testSimpleMultipleAdvice() throws Exception { - AdviceWithRouteBuilder.adviceWith(context, "load-balancer-test-route", + AdviceWith.adviceWith(context, "load-balancer-test-route", a -> a.interceptSendToEndpoint("seda:end1").skipSendToOriginalEndpoint().to("mock:end")); context.start(); diff --git a/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/issues/AdviceWithOnCompletionTest.java b/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/issues/AdviceWithOnCompletionTest.java index 7d20a6a..effe4d4 100644 --- a/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/issues/AdviceWithOnCompletionTest.java +++ b/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/issues/AdviceWithOnCompletionTest.java @@ -16,7 +16,7 @@ */ package org.apache.camel.test.issues; -import org.apache.camel.builder.AdviceWithRouteBuilder; +import org.apache.camel.builder.AdviceWith; import org.apache.camel.test.spring.junit5.CamelSpringTestSupport; import org.junit.jupiter.api.Test; import org.springframework.context.support.AbstractApplicationContext; @@ -36,7 +36,7 @@ public class AdviceWithOnCompletionTest extends CamelSpringTestSupport { @Test public void testOnCompletion() throws Exception { - AdviceWithRouteBuilder.adviceWith(context, "advice-with-on-completion-test-route", a -> { + AdviceWith.adviceWith(context, "advice-with-on-completion-test-route", a -> { a.replaceFromWith("direct:start"); a.weaveAddFirst().convertBodyTo(String.class); a.weaveAddLast().to("mock:result"); diff --git a/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.java b/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.java index d0909b6..b72e08b 100644 --- a/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.java +++ b/components/camel-test-spring-junit5/src/test/java/org/apache/camel/test/issues/AdviceWithOnExceptionMultipleIssueTest.java @@ -39,11 +39,11 @@ public class AdviceWithOnExceptionMultipleIssueTest extends CamelSpringTestSuppo @Test public void testSimpleMultipleAdvice() throws Exception { - AdviceWithRouteBuilder.adviceWith(context, "RouteA", a -> { + AdviceWith.adviceWith(context, "RouteA", a -> { a.interceptSendToEndpoint("mock:resultA").process(); }); - AdviceWithRouteBuilder.adviceWith(context, "RouteB", a -> { + AdviceWith.adviceWith(context, "RouteB", a -> { }); context.start(); @@ -55,7 +55,7 @@ public class AdviceWithOnExceptionMultipleIssueTest extends CamelSpringTestSuppo @Test public void testMultipleAdviceWithExceptionThrown() throws Exception { - AdviceWithRouteBuilder.adviceWith(context, "RouteA", a -> { + AdviceWith.adviceWith(context, "RouteA", a -> { a.interceptSendToEndpoint("mock:resultA").process(e -> { throw new Exception("my exception"); }); diff --git a/components/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithLambdaTest.java b/components/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithLambdaTest.java index 449b083..612626c 100644 --- a/components/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithLambdaTest.java +++ b/components/camel-test/src/test/java/org/apache/camel/test/patterns/AdviceWithLambdaTest.java @@ -17,7 +17,7 @@ package org.apache.camel.test.patterns; import org.apache.camel.RoutesBuilder; -import org.apache.camel.builder.AdviceWithRouteBuilder; +import org.apache.camel.builder.AdviceWith; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; @@ -34,7 +34,7 @@ public class AdviceWithLambdaTest extends CamelTestSupport { getMockEndpoint("mock:result").expectedMessageCount(1); // advice the route in one line - AdviceWithRouteBuilder.adviceWith(context, "foo", a -> a.weaveAddLast().to("mock:result")); + AdviceWith.adviceWith(context, "foo", a -> a.weaveAddLast().to("mock:result")); // start Camel context.start(); diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/builder/AdviceWith.java b/core/camel-core-engine/src/main/java/org/apache/camel/builder/AdviceWith.java index a65ef80..d35cdc5 100644 --- a/core/camel-core-engine/src/main/java/org/apache/camel/builder/AdviceWith.java +++ b/core/camel-core-engine/src/main/java/org/apache/camel/builder/AdviceWith.java @@ -21,9 +21,11 @@ import java.util.List; import org.apache.camel.CamelContext; import org.apache.camel.ExtendedCamelContext; import org.apache.camel.model.Model; +import org.apache.camel.model.ModelCamelContext; import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.RoutesDefinition; import org.apache.camel.util.ObjectHelper; +import org.apache.camel.util.function.ThrowingConsumer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,6 +43,88 @@ public final class AdviceWith { } /** + * Advices this route with the route builder using a lambda expression. It can be used as following: + * + * <pre> + * AdviceWith.adviceWith(context, "myRoute", a -> + * a.weaveAddLast().to("mock:result"); + * </pre> + * <p/> + * <b>Important:</b> It is recommended to only advice a given route once (you can of course advice multiple routes). + * If you do it multiple times, then it may not work as expected, especially when any kind of error handling is + * involved. + * <p/> + * The advice process will add the interceptors, on exceptions, on completions etc. configured from the route + * builder to this route. + * <p/> + * This is mostly used for testing purpose to add interceptors and the likes to an existing route. + * <p/> + * Will stop and remove the old route from camel context and add and start this new advised route. + * + * @param camelContext the camel context + * @param routeId either the route id as a string value, or <tt>null</tt> to chose the 1st route, or you can + * specify a number for the n'th route, or provide the route definition instance directly as + * well. + * @param builder the advice with route builder + * @return a new route which is this route merged with the route builder + * @throws Exception can be thrown from the route builder + */ + public static RouteDefinition adviceWith( + CamelContext camelContext, Object routeId, ThrowingConsumer<AdviceWithRouteBuilder, Exception> builder) + throws Exception { + RouteDefinition rd = findRouteDefinition(camelContext, routeId); + return camelContext.adapt(ModelCamelContext.class).adviceWith(rd, new AdviceWithRouteBuilder() { + @Override + public void configure() throws Exception { + builder.accept(this); + } + }); + } + + /** + * Advices this route with the route builder using a lambda expression. It can be used as following: + * + * <pre> + * AdviceWith.adviceWith(context, "myRoute", false, a -> + * a.weaveAddLast().to("mock:result"); + * </pre> + * <p/> + * <b>Important:</b> It is recommended to only advice a given route once (you can of course advice multiple routes). + * If you do it multiple times, then it may not work as expected, especially when any kind of error handling is + * involved. + * <p/> + * The advice process will add the interceptors, on exceptions, on completions etc. configured from the route + * builder to this route. + * <p/> + * This is mostly used for testing purpose to add interceptors and the likes to an existing route. + * <p/> + * Will stop and remove the old route from camel context and add and start this new advised route. + * + * @param camelContext the camel context + * @param routeId either the route id as a string value, or <tt>null</tt> to chose the 1st route, or you can + * specify a number for the n'th route, or provide the route definition instance directly as + * well. + * @param logXml whether to log the before and after advices routes as XML to the log (this can be turned off + * to perform faster) + * @param builder the advice with route builder + * @return a new route which is this route merged with the route builder + * @throws Exception can be thrown from the route builder + */ + public static RouteDefinition adviceWith( + CamelContext camelContext, Object routeId, boolean logXml, + ThrowingConsumer<AdviceWithRouteBuilder, Exception> builder) + throws Exception { + RouteDefinition rd = findRouteDefinition(camelContext, routeId); + return adviceWith(rd, camelContext, new AdviceWithRouteBuilder() { + @Override + public void configure() throws Exception { + setLogRouteAsXml(logXml); + builder.accept(this); + } + }); + } + + /** * Advices this route with the route builder. * <p/> * <b>Important:</b> It is recommended to only advice a given route once (you can of course advice multiple routes). @@ -49,8 +133,7 @@ public final class AdviceWith { * needed to support this properly. * <p/> * You can use a regular {@link RouteBuilder} but the specialized {@link AdviceWithRouteBuilder} has additional - * features when using the <a href="http://camel.apache.org/advicewith.html">advice with</a> feature. We therefore - * suggest you to use the {@link AdviceWithRouteBuilder}. + * features when using the advice with feature. We therefore suggest you to use the {@link AdviceWithRouteBuilder}. * <p/> * The advice process will add the interceptors, on exceptions, on completions etc. configured from the route * builder to this route. @@ -171,4 +254,35 @@ public final class AdviceWith { return merged; } + private static RouteDefinition findRouteDefinition(CamelContext camelContext, Object routeId) { + ModelCamelContext mcc = camelContext.adapt(ModelCamelContext.class); + if (mcc.getRouteDefinitions().isEmpty()) { + throw new IllegalArgumentException("Cannot advice route as there are no routes"); + } + + RouteDefinition rd; + if (routeId instanceof RouteDefinition) { + rd = (RouteDefinition) routeId; + } else { + String id = mcc.getTypeConverter().convertTo(String.class, routeId); + if (id != null) { + rd = mcc.getRouteDefinition(id); + if (rd == null) { + // okay it may be a number + Integer num = mcc.getTypeConverter().tryConvertTo(Integer.class, routeId); + if (num != null) { + rd = mcc.getRouteDefinitions().get(num); + } + } + if (rd == null) { + throw new IllegalArgumentException("Cannot advice route as route with id: " + routeId + " does not exists"); + } + } else { + // grab first route + rd = mcc.getRouteDefinitions().get(0); + } + } + return rd; + } + } diff --git a/core/camel-core-engine/src/main/java/org/apache/camel/builder/AdviceWithRouteBuilder.java b/core/camel-core-engine/src/main/java/org/apache/camel/builder/AdviceWithRouteBuilder.java index 4f90d50..c3f7327b 100644 --- a/core/camel-core-engine/src/main/java/org/apache/camel/builder/AdviceWithRouteBuilder.java +++ b/core/camel-core-engine/src/main/java/org/apache/camel/builder/AdviceWithRouteBuilder.java @@ -23,7 +23,6 @@ import org.apache.camel.CamelContext; import org.apache.camel.Endpoint; import org.apache.camel.ExtendedCamelContext; import org.apache.camel.impl.engine.InterceptSendToMockEndpointStrategy; -import org.apache.camel.model.ModelCamelContext; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.RouteDefinition; import org.apache.camel.support.EndpointHelper; @@ -61,8 +60,7 @@ public abstract class AdviceWithRouteBuilder extends RouteBuilder { * <p/> * <b>Important:</b> It is recommended to only advice a given route once (you can of course advice multiple routes). * If you do it multiple times, then it may not work as expected, especially when any kind of error handling is - * involved. The Camel team plan for Camel 3.0 to support this as internal refactorings in the routing engine is - * needed to support this properly. + * involved. * <p/> * The advice process will add the interceptors, on exceptions, on completions etc. configured from the route * builder to this route. @@ -71,24 +69,20 @@ public abstract class AdviceWithRouteBuilder extends RouteBuilder { * <p/> * Will stop and remove the old route from camel context and add and start this new advised route. * - * @param camelContext the camel context - * @param routeId either the route id as a string value, or <tt>null</tt> to chose the 1st route, or you can - * specify a number for the n'th route, or provide the route definition instance directly as - * well. - * @param builder the advice with route builder - * @return a new route which is this route merged with the route builder - * @throws Exception can be thrown from the route builder + * @param camelContext the camel context + * @param routeId either the route id as a string value, or <tt>null</tt> to chose the 1st route, or you + * can specify a number for the n'th route, or provide the route definition instance + * directly as well. + * @param builder the advice with route builder + * @return a new route which is this route merged with the route builder + * @throws Exception can be thrown from the route builder + * @deprecated use {@link AdviceWith#adviceWith(CamelContext, Object, ThrowingConsumer)} */ + @Deprecated public static RouteDefinition adviceWith( CamelContext camelContext, Object routeId, ThrowingConsumer<AdviceWithRouteBuilder, Exception> builder) throws Exception { - RouteDefinition rd = findRouteDefinition(camelContext, routeId); - return camelContext.adapt(ModelCamelContext.class).adviceWith(rd, new AdviceWithRouteBuilder() { - @Override - public void configure() throws Exception { - builder.accept(this); - } - }); + return AdviceWith.adviceWith(camelContext, routeId, builder); } /** @@ -101,8 +95,7 @@ public abstract class AdviceWithRouteBuilder extends RouteBuilder { * <p/> * <b>Important:</b> It is recommended to only advice a given route once (you can of course advice multiple routes). * If you do it multiple times, then it may not work as expected, especially when any kind of error handling is - * involved. The Camel team plan for Camel 3.0 to support this as internal refactorings in the routing engine is - * needed to support this properly. + * involved. * <p/> * The advice process will add the interceptors, on exceptions, on completions etc. configured from the route * builder to this route. @@ -111,60 +104,23 @@ public abstract class AdviceWithRouteBuilder extends RouteBuilder { * <p/> * Will stop and remove the old route from camel context and add and start this new advised route. * - * @param camelContext the camel context - * @param routeId either the route id as a string value, or <tt>null</tt> to chose the 1st route, or you can - * specify a number for the n'th route, or provide the route definition instance directly as - * well. - * @param logXml whether to log the before and after advices routes as XML to the log (this can be turned off - * to perform faster) - * @param builder the advice with route builder - * @return a new route which is this route merged with the route builder - * @throws Exception can be thrown from the route builder + * @param camelContext the camel context + * @param routeId either the route id as a string value, or <tt>null</tt> to chose the 1st route, or you + * can specify a number for the n'th route, or provide the route definition instance + * directly as well. + * @param logXml whether to log the before and after advices routes as XML to the log (this can be turned + * off to perform faster) + * @param builder the advice with route builder + * @return a new route which is this route merged with the route builder + * @throws Exception can be thrown from the route builder + * @deprecated use {@link AdviceWith#adviceWith(CamelContext, Object, boolean, ThrowingConsumer)} */ + @Deprecated public static RouteDefinition adviceWith( CamelContext camelContext, Object routeId, boolean logXml, ThrowingConsumer<AdviceWithRouteBuilder, Exception> builder) throws Exception { - RouteDefinition rd = findRouteDefinition(camelContext, routeId); - - return AdviceWith.adviceWith(rd, camelContext, new AdviceWithRouteBuilder() { - @Override - public void configure() throws Exception { - setLogRouteAsXml(logXml); - builder.accept(this); - } - }); - } - - protected static RouteDefinition findRouteDefinition(CamelContext camelContext, Object routeId) { - ModelCamelContext mcc = camelContext.adapt(ModelCamelContext.class); - if (mcc.getRouteDefinitions().isEmpty()) { - throw new IllegalArgumentException("Cannot advice route as there are no routes"); - } - - RouteDefinition rd; - if (routeId instanceof RouteDefinition) { - rd = (RouteDefinition) routeId; - } else { - String id = mcc.getTypeConverter().convertTo(String.class, routeId); - if (id != null) { - rd = mcc.getRouteDefinition(id); - if (rd == null) { - // okay it may be a number - Integer num = mcc.getTypeConverter().tryConvertTo(Integer.class, routeId); - if (num != null) { - rd = mcc.getRouteDefinitions().get(num); - } - } - if (rd == null) { - throw new IllegalArgumentException("Cannot advice route as route with id: " + routeId + " does not exists"); - } - } else { - // grab first route - rd = mcc.getRouteDefinitions().get(0); - } - } - return rd; + return AdviceWith.adviceWith(camelContext, routeId, logXml, builder); } /** diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithLambdaTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithLambdaTest.java index 9262ea2..d7591f0 100644 --- a/core/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithLambdaTest.java +++ b/core/camel-core/src/test/java/org/apache/camel/processor/interceptor/AdviceWithLambdaTest.java @@ -18,7 +18,7 @@ package org.apache.camel.processor.interceptor; import org.apache.camel.CamelExecutionException; import org.apache.camel.ContextTestSupport; -import org.apache.camel.builder.AdviceWithRouteBuilder; +import org.apache.camel.builder.AdviceWith; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.model.RouteDefinition; import org.junit.jupiter.api.Test; @@ -40,7 +40,7 @@ public class AdviceWithLambdaTest extends ContextTestSupport { @Test public void testAdvised() throws Exception { - AdviceWithRouteBuilder.adviceWith(context, null, a -> { + AdviceWith.adviceWith(context, null, a -> { a.interceptSendToEndpoint("mock:foo").skipSendToOriginalEndpoint().to("log:foo").to("mock:advised"); }); @@ -56,7 +56,7 @@ public class AdviceWithLambdaTest extends ContextTestSupport { @Test public void testAdvisedNoLog() throws Exception { - AdviceWithRouteBuilder.adviceWith(context, null, false, a -> { + AdviceWith.adviceWith(context, null, false, a -> { a.weaveByToUri("mock:result").remove(); a.weaveAddLast().transform().constant("Bye World"); }); @@ -73,7 +73,7 @@ public class AdviceWithLambdaTest extends ContextTestSupport { @Test public void testAdvisedNoNewRoutesAllowed() throws Exception { try { - AdviceWithRouteBuilder.adviceWith(context, 0, a -> { + AdviceWith.adviceWith(context, 0, a -> { a.from("direct:bar").to("mock:bar"); a.interceptSendToEndpoint("mock:foo").skipSendToOriginalEndpoint().to("log:foo").to("mock:advised"); @@ -86,7 +86,7 @@ public class AdviceWithLambdaTest extends ContextTestSupport { @Test public void testAdvisedThrowException() throws Exception { - AdviceWithRouteBuilder.adviceWith(context, "myRoute", a -> { + AdviceWith.adviceWith(context, "myRoute", a -> { a.interceptSendToEndpoint("mock:foo").to("mock:advised").throwException(new IllegalArgumentException("Damn")); }); @@ -107,7 +107,7 @@ public class AdviceWithLambdaTest extends ContextTestSupport { @Test public void testAdvisedRouteDefinition() throws Exception { - AdviceWithRouteBuilder.adviceWith(context, context.getRouteDefinitions().get(0), a -> { + AdviceWith.adviceWith(context, context.getRouteDefinitions().get(0), a -> { a.interceptSendToEndpoint("mock:foo").skipSendToOriginalEndpoint().to("log:foo").to("mock:advised"); }); @@ -123,7 +123,7 @@ public class AdviceWithLambdaTest extends ContextTestSupport { @Test public void testAdvisedEmptyRouteDefinition() throws Exception { try { - AdviceWithRouteBuilder.adviceWith(context, new RouteDefinition(), a -> { + AdviceWith.adviceWith(context, new RouteDefinition(), a -> { a.interceptSendToEndpoint("mock:foo").skipSendToOriginalEndpoint().to("log:foo").to("mock:advised"); }); fail("Should throw exception"); diff --git a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_7.adoc b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_7.adoc index 8b88c1a..efc127a 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_7.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-3x-upgrade-guide-3_7.adoc @@ -9,6 +9,8 @@ from both 3.0 to 3.1 and 3.1 to 3.2. === AdviceWith Advice routes moved the `adviceWith` method from `org.apache.camel.reifier.RouteReifier` to `org.apache.camel.builder.AdviceWith`. +Also `adviceWith` methods on `org.apache.camel.builder.AdviceWithRouteBuilder` is deprecated in favour +of using methods on `org.apache.camel.builder.AdviceWith`. === API changes