From f64c1368fdce6d6efb628a510a678db6b5f31a24 Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Wed, 6 May 2020 18:19:05 +0200 Subject: [PATCH 1/3] yaml-loader: auto generate part fo the dsl --- .../yaml/parser/AggregateStepParser.java | 1 + .../loader/yaml/parser/ChoiceStepParser.java | 2 + .../yaml/parser/CircuitBreakerStepParser.java | 2 + .../yaml/parser/ConvertBodyStepParser.java | 30 ----- .../k/loader/yaml/parser/DelayStepParser.java | 6 +- .../k/loader/yaml/parser/DoTryStepParser.java | 2 + .../yaml/parser/DynamicRouterStepParser.java | 1 + .../loader/yaml/parser/EnrichStepParser.java | 1 + .../loader/yaml/parser/FilterStepParser.java | 2 + .../k/loader/yaml/parser/FromStepParser.java | 2 + .../yaml/parser/IdempotentConsumerParser.java | 2 + .../yaml/parser/LoadBalanceStepParser.java | 2 + .../k/loader/yaml/parser/LoopStepParser.java | 2 + .../loader/yaml/parser/MarshalStepParser.java | 1 + .../yaml/parser/MulticastStepParser.java | 2 + .../yaml/parser/PipelineStepParser.java | 2 + .../yaml/parser/PollEnrichStepParser.java | 1 + .../loader/yaml/parser/ProcessStepParser.java | 1 + .../yaml/parser/RecipientListStepParser.java | 1 + .../yaml/parser/RemoveHeaderStepParser.java | 46 ------- .../yaml/parser/RemoveHeadersStepParser.java | 29 ----- .../parser/RemovePropertiesStepParser.java | 30 ----- .../yaml/parser/RemovePropertyStepParser.java | 46 ------- .../yaml/parser/ResequenceStepParser.java | 2 + .../k/loader/yaml/parser/RestStepParser.java | 2 + .../k/loader/yaml/parser/RouteStepParser.java | 2 + .../yaml/parser/RoutingSlipStepParser.java | 3 +- .../k/loader/yaml/parser/SagaStepParser.java | 2 + .../loader/yaml/parser/SampleStepParser.java | 2 + .../loader/yaml/parser/ScriptStepParser.java | 1 + .../yaml/parser/ServiceCallStepParser.java | 1 + .../loader/yaml/parser/SetBodyStepParser.java | 1 + .../parser/SetExchangePatternStepParser.java | 1 + .../yaml/parser/SetHeaderStepParser.java | 1 + .../yaml/parser/SetPropertyStepParser.java | 1 + .../k/loader/yaml/parser/SortStepParser.java | 1 + .../k/loader/yaml/parser/SplitStepParser.java | 2 + .../k/loader/yaml/parser/StepStepParser.java | 2 + .../k/loader/yaml/parser/StopStepParser.java | 30 ----- .../loader/yaml/parser/ThreadsStepParser.java | 30 ----- .../yaml/parser/ThrottleStepParser.java | 1 + .../yaml/parser/ThrowExceptionStepParser.java | 1 + .../yaml/parser/ToDynamicStepParser.java | 3 +- .../k/loader/yaml/parser/ToStepParser.java | 1 + .../yaml/parser/TransactedStepParser.java | 1 + .../yaml/parser/TransformStepParser.java | 1 + ...ser.java => TypedProcessorStepParser.java} | 16 ++- .../yaml/parser/UnmarshalStepParser.java | 1 + .../yaml/parser/ValidateStepParser.java | 1 + .../loader/yaml/parser/WireTapStepParser.java | 3 +- .../{parser => spi}/ProcessorStepParser.java | 14 +- .../yaml/{parser => spi}/StartStepParser.java | 9 +- .../yaml/{parser => spi}/StepParser.java | 74 +++++++---- .../{parser => spi}/StepParserException.java | 2 +- .../{parser => spi}/StepParserSupport.java | 3 +- .../RemoveHeaderDefinitionMixIn.java} | 21 ++- .../RemovePropertyDefinitionMixIn.java} | 21 ++- .../camel/k/loader/yaml/YamlSourceLoader.java | 7 +- .../camel/k/loader/yaml/TestSupport.groovy | 23 +++- .../k/loader/yaml/parser/BeanTest.groovy | 8 +- .../k/loader/yaml/parser/ChoiceTest.groovy | 1 + .../loader/yaml/parser/ClaimCheckTest.groovy | 6 +- .../loader/yaml/parser/ConvertBodyTest.groovy | 6 +- .../k/loader/yaml/parser/FromTest.groovy | 1 + .../camel/k/loader/yaml/parser/LogTest.groovy | 6 +- .../k/loader/yaml/parser/PipelineTest.groovy | 1 + .../yaml/parser/RemoveHeaderTest.groovy | 17 ++- .../yaml/parser/RemoveHeadersTest.groovy | 6 +- .../yaml/parser/RemovePropertiesTest.groovy | 8 +- .../yaml/parser/RemovePropertyTest.groovy | 18 ++- .../k/loader/yaml/parser/RestTest.groovy | 1 + .../k/loader/yaml/parser/RollbackTest.groovy | 16 +-- .../yaml/parser/SetExchangePatternTest.groovy | 6 +- .../k/loader/yaml/parser/StepTest.groovy | 3 +- .../k/loader/yaml/parser/StopTest.groovy} | 23 ++-- .../k/loader/yaml/parser/ThreadsTest.groovy | 4 +- .../yaml/parser/ThrowExceptionTest.groovy | 24 ++-- .../loader/yaml/parser/TransactedTest.groovy | 2 +- .../quarkus/deployment/DeploymentSupport.java | 54 ++++++++ .../deployment/DeploymentProcessor.java | 77 +++-------- .../yaml/parser/KnativeStepParser.java | 6 +- .../data/routes.yaml | 2 +- .../data/routes.yaml | 2 +- .../data/routes.yaml | 2 +- .../src/main/resources/routes.yaml | 8 +- pom.xml | 2 +- .../camel/k/tooling/apt/CamelProcessor.java | 10 -- tooling/camel-k-maven-plugin/pom.xml | 2 +- .../GenerateYamlLoaderSupportClasses.java | 121 ++++++++++++++++-- .../k/tooling/maven/GenerateYamlSupport.java | 5 +- 90 files changed, 455 insertions(+), 494 deletions(-) delete mode 100644 camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ConvertBodyStepParser.java delete mode 100644 camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemoveHeaderStepParser.java delete mode 100644 camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemoveHeadersStepParser.java delete mode 100644 camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemovePropertiesStepParser.java delete mode 100644 camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemovePropertyStepParser.java delete mode 100644 camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StopStepParser.java delete mode 100644 camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ThreadsStepParser.java rename camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/{RollbackStepParser.java => TypedProcessorStepParser.java} (72%) rename camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/{parser => spi}/ProcessorStepParser.java (77%) rename camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/{parser => spi}/StartStepParser.java (77%) rename camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/{parser => spi}/StepParser.java (56%) rename camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/{parser => spi}/StepParserException.java (97%) rename camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/{parser => spi}/StepParserSupport.java (97%) rename camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/{parser/BeanStepParser.java => support/RemoveHeaderDefinitionMixIn.java} (64%) rename camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/{parser/ClaimCheckStepParser.java => support/RemovePropertyDefinitionMixIn.java} (63%) rename camel-k-loader-yaml/{camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/LogStepParser.java => camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/StopTest.groovy} (66%) diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/AggregateStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/AggregateStepParser.java index 4feff9358..61c8745b6 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/AggregateStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/AggregateStepParser.java @@ -20,6 +20,7 @@ import org.apache.camel.Expression; import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.AggregateDefinition; import org.apache.camel.model.ExpressionSubElementDefinition; import org.apache.camel.model.ProcessorDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ChoiceStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ChoiceStepParser.java index 44f466521..4685cd345 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ChoiceStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ChoiceStepParser.java @@ -21,6 +21,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ChoiceDefinition; import org.apache.camel.model.OtherwiseDefinition; import org.apache.camel.model.ProcessorDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/CircuitBreakerStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/CircuitBreakerStepParser.java index cbf6b3d45..0386d205d 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/CircuitBreakerStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/CircuitBreakerStepParser.java @@ -22,6 +22,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.CircuitBreakerDefinition; import org.apache.camel.model.HystrixConfigurationDefinition; import org.apache.camel.model.OnFallbackDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ConvertBodyStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ConvertBodyStepParser.java deleted file mode 100644 index d117f27bb..000000000 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ConvertBodyStepParser.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.k.loader.yaml.parser; - -import org.apache.camel.k.annotation.yaml.YAMLStepParser; -import org.apache.camel.model.ConvertBodyDefinition; -import org.apache.camel.model.ProcessorDefinition; - -@YAMLStepParser("convert-body") -public class ConvertBodyStepParser implements ProcessorStepParser { - @Override - public ProcessorDefinition toProcessor(Context context) { - return context.node(ConvertBodyDefinition.class); - } -} - diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/DelayStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/DelayStepParser.java index 6d34875ed..9aac9404d 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/DelayStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/DelayStepParser.java @@ -18,17 +18,13 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.DelayDefinition; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.reifier.DelayReifier; -import org.apache.camel.reifier.ProcessorReifier; @YAMLStepParser("delay") public class DelayStepParser implements ProcessorStepParser { - static { - ProcessorReifier.registerReifier(Definition.class, DelayReifier::new); - } - @Override public ProcessorDefinition toProcessor(Context context) { return context.node(Definition.class); diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/DoTryStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/DoTryStepParser.java index 96c55c442..d164b425c 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/DoTryStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/DoTryStepParser.java @@ -22,6 +22,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.CatchDefinition; import org.apache.camel.model.FinallyDefinition; import org.apache.camel.model.ProcessorDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/DynamicRouterStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/DynamicRouterStepParser.java index 2ddc5ae94..4974d78ef 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/DynamicRouterStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/DynamicRouterStepParser.java @@ -18,6 +18,7 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.DynamicRouterDefinition; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.reifier.DynamicRouterReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/EnrichStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/EnrichStepParser.java index ff06a9dcc..997351f86 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/EnrichStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/EnrichStepParser.java @@ -20,6 +20,7 @@ import org.apache.camel.Expression; import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.EnrichDefinition; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.reifier.EnrichReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/FilterStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/FilterStepParser.java index 650e5264b..90af67690 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/FilterStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/FilterStepParser.java @@ -21,6 +21,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.FilterDefinition; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.reifier.FilterReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/FromStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/FromStepParser.java index 7607f2b22..22f846fde 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/FromStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/FromStepParser.java @@ -25,6 +25,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.StartStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.RouteDefinition; import org.apache.camel.util.URISupport; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/IdempotentConsumerParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/IdempotentConsumerParser.java index e35ba8de3..fb90ed1e1 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/IdempotentConsumerParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/IdempotentConsumerParser.java @@ -21,6 +21,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.IdempotentConsumerDefinition; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.reifier.IdempotentConsumerReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/LoadBalanceStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/LoadBalanceStepParser.java index 811e03560..d27983e78 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/LoadBalanceStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/LoadBalanceStepParser.java @@ -25,6 +25,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ExpressionSubElementDefinition; import org.apache.camel.model.LoadBalanceDefinition; import org.apache.camel.model.LoadBalancerDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/LoopStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/LoopStepParser.java index e05af6fcb..f6965f4e7 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/LoopStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/LoopStepParser.java @@ -21,6 +21,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.LoopDefinition; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.reifier.LoopReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/MarshalStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/MarshalStepParser.java index d39f3a2c5..b03f56d9e 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/MarshalStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/MarshalStepParser.java @@ -18,6 +18,7 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.MarshalDefinition; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.reifier.MarshalReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/MulticastStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/MulticastStepParser.java index 98a7ffdce..fd237c342 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/MulticastStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/MulticastStepParser.java @@ -21,6 +21,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.MulticastDefinition; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.reifier.MulticastReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/PipelineStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/PipelineStepParser.java index 1b1393ab3..dfdb8b159 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/PipelineStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/PipelineStepParser.java @@ -21,6 +21,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.PipelineDefinition; import org.apache.camel.model.ProcessorDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/PollEnrichStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/PollEnrichStepParser.java index 88e0ec72b..4b2f04734 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/PollEnrichStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/PollEnrichStepParser.java @@ -20,6 +20,7 @@ import org.apache.camel.Expression; import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.PollEnrichDefinition; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.reifier.PollEnrichReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ProcessStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ProcessStepParser.java index 007811bbf..1e22238e2 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ProcessStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ProcessStepParser.java @@ -17,6 +17,7 @@ package org.apache.camel.k.loader.yaml.parser; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessDefinition; import org.apache.camel.model.ProcessorDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RecipientListStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RecipientListStepParser.java index f0fbccff1..4e1d38654 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RecipientListStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RecipientListStepParser.java @@ -18,6 +18,7 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.RecipientListDefinition; import org.apache.camel.reifier.RecipientListReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemoveHeaderStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemoveHeaderStepParser.java deleted file mode 100644 index 86f07f9b5..000000000 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemoveHeaderStepParser.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.k.loader.yaml.parser; - -import com.fasterxml.jackson.annotation.JsonAlias; -import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; -import org.apache.camel.k.annotation.yaml.YAMLStepParser; -import org.apache.camel.model.ProcessorDefinition; -import org.apache.camel.model.RemoveHeaderDefinition; -import org.apache.camel.reifier.RemoveHeaderReifier; - -@YAMLStepParser("remove-header") -public class RemoveHeaderStepParser implements ProcessorStepParser { - @Override - public ProcessorDefinition toProcessor(Context context) { - return context.node(Definition.class); - } - - @YAMLNodeDefinition(reifiers = RemoveHeaderReifier.class) - public static final class Definition extends RemoveHeaderDefinition { - @JsonAlias("name") - public void setHeaderName(String headerName) { - super.setHeaderName(headerName); - } - - @JsonAlias("name") - public String getHeaderName() { - return super.getHeaderName(); - } - } -} - diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemoveHeadersStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemoveHeadersStepParser.java deleted file mode 100644 index 0215efcd4..000000000 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemoveHeadersStepParser.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.k.loader.yaml.parser; - -import org.apache.camel.k.annotation.yaml.YAMLStepParser; -import org.apache.camel.model.ProcessorDefinition; -import org.apache.camel.model.RemoveHeadersDefinition; - -@YAMLStepParser("remove-headers") -public class RemoveHeadersStepParser implements ProcessorStepParser { - @Override - public ProcessorDefinition toProcessor(Context context) { - return context.node(RemoveHeadersDefinition.class); - } -} diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemovePropertiesStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemovePropertiesStepParser.java deleted file mode 100644 index 91222f87d..000000000 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemovePropertiesStepParser.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.k.loader.yaml.parser; - -import org.apache.camel.k.annotation.yaml.YAMLStepParser; -import org.apache.camel.model.ProcessorDefinition; -import org.apache.camel.model.RemovePropertiesDefinition; - -@YAMLStepParser("remove-properties") -public class RemovePropertiesStepParser implements ProcessorStepParser { - @Override - public ProcessorDefinition toProcessor(Context context) { - return context.node(RemovePropertiesDefinition.class); - } -} - diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemovePropertyStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemovePropertyStepParser.java deleted file mode 100644 index 947f36ff9..000000000 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RemovePropertyStepParser.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.k.loader.yaml.parser; - -import com.fasterxml.jackson.annotation.JsonAlias; -import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; -import org.apache.camel.k.annotation.yaml.YAMLStepParser; -import org.apache.camel.model.ProcessorDefinition; -import org.apache.camel.model.RemovePropertyDefinition; -import org.apache.camel.reifier.RemovePropertyReifier; - -@YAMLStepParser("remove-property") -public class RemovePropertyStepParser implements ProcessorStepParser { - @Override - public ProcessorDefinition toProcessor(Context context) { - return context.node(Definition.class); - } - - @YAMLNodeDefinition(reifiers = RemovePropertyReifier.class) - public static final class Definition extends RemovePropertyDefinition { - @JsonAlias("name") - public void setPropertyName(String headerName) { - super.setPropertyName(headerName); - } - - @JsonAlias("name") - public String getPropertyName() { - return super.getPropertyName(); - } - } -} - diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ResequenceStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ResequenceStepParser.java index de1cce1dc..6200a2ef5 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ResequenceStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ResequenceStepParser.java @@ -24,6 +24,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.ResequenceDefinition; import org.apache.camel.model.config.BatchResequencerConfig; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RestStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RestStepParser.java index 978cfedf9..99cb057a0 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RestStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RestStepParser.java @@ -24,6 +24,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.StartStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.rest.RestBindingMode; import org.apache.camel.model.rest.RestDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RouteStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RouteStepParser.java index 3b8dfafe7..c227a3250 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RouteStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RouteStepParser.java @@ -24,6 +24,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Node; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StartStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.RouteDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RoutingSlipStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RoutingSlipStepParser.java index 4e43cb171..dd5530053 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RoutingSlipStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RoutingSlipStepParser.java @@ -19,6 +19,7 @@ import org.apache.camel.Expression; import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.RoutingSlipDefinition; import org.apache.camel.reifier.RoutingSlipReifier; @@ -31,7 +32,7 @@ public ProcessorDefinition toProcessor(Context context) { } @YAMLNodeDefinition(reifiers = RoutingSlipReifier.class) - public static final class Definition extends RoutingSlipDefinition implements HasExpression { + public static final class Definition> extends RoutingSlipDefinition implements HasExpression { public Definition() { super((Expression) null, RoutingSlipDefinition.DEFAULT_DELIMITER); } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SagaStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SagaStepParser.java index 4772b1039..5f6186b5f 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SagaStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SagaStepParser.java @@ -21,6 +21,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.SagaDefinition; import org.apache.camel.reifier.SagaReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SampleStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SampleStepParser.java index 6cba016f6..48a55c785 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SampleStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SampleStepParser.java @@ -21,6 +21,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.SamplingDefinition; import org.apache.camel.reifier.SamplingReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ScriptStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ScriptStepParser.java index 105a1c548..8abe16cbd 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ScriptStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ScriptStepParser.java @@ -18,6 +18,7 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.ScriptDefinition; import org.apache.camel.reifier.ScriptReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ServiceCallStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ServiceCallStepParser.java index 9c708f26b..2b9a8d1c0 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ServiceCallStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ServiceCallStepParser.java @@ -18,6 +18,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.cloud.ServiceCallDefinition; import org.apache.camel.model.cloud.ServiceCallExpressionConfiguration; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetBodyStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetBodyStepParser.java index a879b9f8c..f4fddb103 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetBodyStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetBodyStepParser.java @@ -18,6 +18,7 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.SetBodyDefinition; import org.apache.camel.reifier.SetBodyReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetExchangePatternStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetExchangePatternStepParser.java index 3ad2ad55e..81aa70a8c 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetExchangePatternStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetExchangePatternStepParser.java @@ -17,6 +17,7 @@ package org.apache.camel.k.loader.yaml.parser; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.SetExchangePatternDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetHeaderStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetHeaderStepParser.java index 4d3987ee4..c6caf6242 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetHeaderStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetHeaderStepParser.java @@ -18,6 +18,7 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.SetHeaderDefinition; import org.apache.camel.reifier.SetHeaderReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetPropertyStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetPropertyStepParser.java index d55445b1e..5d0948290 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetPropertyStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SetPropertyStepParser.java @@ -18,6 +18,7 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.SetPropertyDefinition; import org.apache.camel.reifier.SetPropertyReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SortStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SortStepParser.java index be6fe23c1..90f90047e 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SortStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SortStepParser.java @@ -18,6 +18,7 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.SortDefinition; import org.apache.camel.reifier.SortReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SplitStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SplitStepParser.java index e641ad9f7..3faabcac6 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SplitStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/SplitStepParser.java @@ -21,6 +21,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.SplitDefinition; import org.apache.camel.reifier.SplitReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepStepParser.java index 26450ffd2..006133ef4 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepStepParser.java @@ -21,6 +21,8 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; import org.apache.camel.k.loader.yaml.model.Step; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.StepDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StopStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StopStepParser.java deleted file mode 100644 index 7e147bc95..000000000 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StopStepParser.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.k.loader.yaml.parser; - -import org.apache.camel.k.annotation.yaml.YAMLStepParser; -import org.apache.camel.model.ProcessorDefinition; -import org.apache.camel.model.StopDefinition; - -@YAMLStepParser("stop") -public class StopStepParser implements ProcessorStepParser { - @Override - public ProcessorDefinition toProcessor(Context context) { - return context.node(StopDefinition.class); - } -} - diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ThreadsStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ThreadsStepParser.java deleted file mode 100644 index a21fc333d..000000000 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ThreadsStepParser.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.k.loader.yaml.parser; - -import org.apache.camel.k.annotation.yaml.YAMLStepParser; -import org.apache.camel.model.ProcessorDefinition; -import org.apache.camel.model.ThreadsDefinition; - -@YAMLStepParser("threads") -public class ThreadsStepParser implements ProcessorStepParser { - @Override - public ProcessorDefinition toProcessor(Context context) { - return context.node(ThreadsDefinition.class); - } -} - diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ThrottleStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ThrottleStepParser.java index b2ee2ac56..90e8308f4 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ThrottleStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ThrottleStepParser.java @@ -18,6 +18,7 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.ThrottleDefinition; import org.apache.camel.reifier.ThrottleReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ThrowExceptionStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ThrowExceptionStepParser.java index 455e5650c..393301394 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ThrowExceptionStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ThrowExceptionStepParser.java @@ -17,6 +17,7 @@ package org.apache.camel.k.loader.yaml.parser; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.ThrowExceptionDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToDynamicStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToDynamicStepParser.java index 21ab51907..19cc5b33d 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToDynamicStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToDynamicStepParser.java @@ -23,11 +23,12 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.ToDynamicDefinition; import org.apache.camel.util.URISupport; -@YAMLStepParser("tod") +@YAMLStepParser({"tod", "to-d"}) public class ToDynamicStepParser implements ProcessorStepParser { @Override public ProcessorDefinition toProcessor(Context context) { diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToStepParser.java index ad2d4bfd4..66ba2d326 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ToStepParser.java @@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.ToDefinition; import org.apache.camel.util.URISupport; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/TransactedStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/TransactedStepParser.java index 01be806eb..1fd34e0f8 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/TransactedStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/TransactedStepParser.java @@ -17,6 +17,7 @@ package org.apache.camel.k.loader.yaml.parser; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.TransactedDefinition; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/TransformStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/TransformStepParser.java index c09c99c9f..a12f1a4d6 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/TransformStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/TransformStepParser.java @@ -18,6 +18,7 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.TransformDefinition; import org.apache.camel.reifier.TransformReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RollbackStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/TypedProcessorStepParser.java similarity index 72% rename from camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RollbackStepParser.java rename to camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/TypedProcessorStepParser.java index 4931752ff..cac8d37fe 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/RollbackStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/TypedProcessorStepParser.java @@ -16,15 +16,19 @@ */ package org.apache.camel.k.loader.yaml.parser; -import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; -import org.apache.camel.model.RollbackDefinition; -@YAMLStepParser("rollback") -public class RollbackStepParser implements ProcessorStepParser { +@SuppressWarnings("rawtypes") +public class TypedProcessorStepParser implements ProcessorStepParser { + private final Class type; + + public TypedProcessorStepParser(Class type) { + this.type = type; + } + @Override public ProcessorDefinition toProcessor(Context context) { - return context.node(RollbackDefinition.class); + return context.node(type); } } - diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/UnmarshalStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/UnmarshalStepParser.java index d4b0e9075..aec8e98f5 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/UnmarshalStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/UnmarshalStepParser.java @@ -18,6 +18,7 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.UnmarshalDefinition; import org.apache.camel.reifier.UnmarshalReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ValidateStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ValidateStepParser.java index ca0740a36..abd61826d 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ValidateStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ValidateStepParser.java @@ -18,6 +18,7 @@ import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.ValidateDefinition; import org.apache.camel.reifier.ValidateReifier; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/WireTapStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/WireTapStepParser.java index ca6593045..9667bfd8c 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/WireTapStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/WireTapStepParser.java @@ -24,6 +24,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.camel.k.annotation.yaml.YAMLNodeDefinition; import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; import org.apache.camel.model.ExpressionSubElementDefinition; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.SetHeaderDefinition; @@ -34,7 +35,7 @@ import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.URISupport; -@YAMLStepParser("wiretap") +@YAMLStepParser({"wiretap", "wire-tap"}) public class WireTapStepParser implements ProcessorStepParser { @SuppressWarnings("unchecked") @Override diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ProcessorStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/ProcessorStepParser.java similarity index 77% rename from camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ProcessorStepParser.java rename to camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/ProcessorStepParser.java index 5c343474b..ee520c315 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ProcessorStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/ProcessorStepParser.java @@ -14,9 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.yaml.parser; +package org.apache.camel.k.loader.yaml.spi; -import org.apache.camel.NoFactoryAvailableException; import org.apache.camel.model.ProcessorDefinition; @FunctionalInterface @@ -28,10 +27,11 @@ public interface ProcessorStepParser extends StepParser { ProcessorDefinition toProcessor(Context context); static ProcessorDefinition invoke(Context context, String stepId) { - try { - return StepParser.lookup(context.camelContext(), ProcessorStepParser.class, stepId).toProcessor(context); - } catch (NoFactoryAvailableException e) { - throw new RuntimeException(e); - } + return context.lookup(ProcessorStepParser.class, stepId).toProcessor(context); + } + + @SuppressWarnings("rawtypes") + static ProcessorStepParser forType(Class type) { + return c -> c.node(type); } } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StartStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StartStepParser.java similarity index 77% rename from camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StartStepParser.java rename to camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StartStepParser.java index 2fb2333fa..f80bcdbb5 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StartStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StartStepParser.java @@ -14,9 +14,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.yaml.parser; +package org.apache.camel.k.loader.yaml.spi; -import org.apache.camel.NoFactoryAvailableException; import org.apache.camel.model.ProcessorDefinition; @FunctionalInterface @@ -28,10 +27,6 @@ public interface StartStepParser extends StepParser { ProcessorDefinition toStartProcessor(Context context); static ProcessorDefinition invoke(Context context, String stepId) { - try { - return StepParser.lookup(context.camelContext(), StartStepParser.class, stepId).toStartProcessor(context); - } catch (NoFactoryAvailableException e) { - throw new RuntimeException(e); - } + return context.lookup(StartStepParser.class, stepId).toStartProcessor(context); } } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParser.java similarity index 56% rename from camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepParser.java rename to camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParser.java index 871218e75..2fab5f246 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParser.java @@ -14,60 +14,47 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.yaml.parser; +package org.apache.camel.k.loader.yaml.spi; import java.io.IOException; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.camel.CamelContext; import org.apache.camel.ExtendedCamelContext; -import org.apache.camel.NoFactoryAvailableException; +import org.apache.camel.spi.HasCamelContext; import org.apache.camel.util.ObjectHelper; public interface StepParser { String SERVICE_LOCATION = "META-INF/services/org/apache/camel/k/loader/yaml-parser/"; - @SuppressWarnings("unchecked") - static T lookup(CamelContext camelContext, Class type, String stepId) throws NoFactoryAvailableException { - T converter = camelContext.getRegistry().lookupByNameAndType(stepId, type); - if (converter == null) { - converter = camelContext.adapt(ExtendedCamelContext.class) - .getFactoryFinder(SERVICE_LOCATION) - .newInstance(stepId, type) - .orElseThrow(() -> new RuntimeException("No handler for step with id: " + stepId)); - } - - return converter; - } - - class Context { + /** + * Context for step parsing. + */ + class Context implements HasCamelContext { private final ObjectMapper mapper; private final CamelContext camelContext; private final JsonNode node; + private final Resolver resolver; - public Context(CamelContext camelContext, ObjectMapper mapper, JsonNode node) { + public Context(CamelContext camelContext, ObjectMapper mapper, JsonNode node, Resolver resolver) { this.camelContext = camelContext; this.mapper = mapper; this.node = node; + this.resolver = ObjectHelper.notNull(resolver, "resolver"); } - public CamelContext camelContext() { + @Override + public CamelContext getCamelContext() { return camelContext; } - public T camelContext(Class type) { - return camelContext.adapt(type); - } - public JsonNode node() { return node; } - public ObjectMapper mapper() { - return mapper; - } - public T node(Class type) { ObjectHelper.notNull(node, "node"); ObjectHelper.notNull(type, "type"); @@ -87,13 +74,46 @@ public T node(Class type) { return definition; } + public T lookup(Class type, String stepId) { + StepParser parser = resolver.resolve(camelContext, stepId); + if (type.isInstance(parser)) { + return type.cast(parser); + } + + throw new RuntimeException("No handler for step with id: " + stepId); + } + public static Context of(Context context, JsonNode step) { return new Context( context.camelContext, context.mapper, - step + step, + context.resolver ); } } + /** + * Step resolver. + */ + interface Resolver { + StepParser resolve(CamelContext camelContext, String stepId); + + default StepParser lookup(CamelContext camelContext, String stepId) { + StepParser answer = camelContext.getRegistry().lookupByNameAndType(stepId, StepParser.class); + if (answer == null) { + answer = camelContext.adapt(ExtendedCamelContext.class) + .getFactoryFinder(SERVICE_LOCATION) + .newInstance(stepId, StepParser.class) + .orElseThrow(() -> new RuntimeException("No handler for step with id: " + stepId)); + } + + return answer; + } + + static Resolver caching(Resolver delegate) { + final ConcurrentMap cache = new ConcurrentHashMap<>(); + return (camelContext, stepId) -> cache.computeIfAbsent(stepId, key -> delegate.resolve(camelContext, key)); + } + } } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepParserException.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserException.java similarity index 97% rename from camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepParserException.java rename to camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserException.java index 171f9683a..08a39c697 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepParserException.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserException.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.yaml.parser; +package org.apache.camel.k.loader.yaml.spi; import java.util.Arrays; import java.util.List; diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepParserSupport.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserSupport.java similarity index 97% rename from camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepParserSupport.java rename to camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserSupport.java index e1235811b..0a70f558c 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/StepParserSupport.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/spi/StepParserSupport.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.yaml.parser; +package org.apache.camel.k.loader.yaml.spi; import java.util.List; @@ -46,6 +46,7 @@ public static ProcessorDefinition convertSteps(ProcessorStepParser.Context co ProcessorDefinition current = parent; for (Step step : steps) { + ProcessorDefinition child = ProcessorStepParser.invoke( ProcessorStepParser.Context.of(context, step.node), step.id diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/BeanStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/support/RemoveHeaderDefinitionMixIn.java similarity index 64% rename from camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/BeanStepParser.java rename to camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/support/RemoveHeaderDefinitionMixIn.java index a60f712fb..2716f531d 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/BeanStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/support/RemoveHeaderDefinitionMixIn.java @@ -14,17 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.yaml.parser; +package org.apache.camel.k.loader.yaml.support; -import org.apache.camel.k.annotation.yaml.YAMLStepParser; -import org.apache.camel.model.BeanDefinition; -import org.apache.camel.model.ProcessorDefinition; +import com.fasterxml.jackson.annotation.JsonAlias; +import org.apache.camel.k.annotation.yaml.YAMLMixIn; -@YAMLStepParser("bean") -public class BeanStepParser implements ProcessorStepParser { - @Override - public ProcessorDefinition toProcessor(Context context) { - return context.node(BeanDefinition.class); - } -} +@YAMLMixIn(org.apache.camel.model.RemoveHeaderDefinition.class) +public abstract class RemoveHeaderDefinitionMixIn { + @JsonAlias({"name", "header-name"}) + public abstract void setHeaderName(String headerName); + @JsonAlias({"name", "header-name"}) + public abstract String getHeaderName(); +} diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ClaimCheckStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/support/RemovePropertyDefinitionMixIn.java similarity index 63% rename from camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ClaimCheckStepParser.java rename to camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/support/RemovePropertyDefinitionMixIn.java index 59e7ab7ca..30b369505 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/ClaimCheckStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/support/RemovePropertyDefinitionMixIn.java @@ -14,17 +14,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.yaml.parser; +package org.apache.camel.k.loader.yaml.support; -import org.apache.camel.k.annotation.yaml.YAMLStepParser; -import org.apache.camel.model.ClaimCheckDefinition; -import org.apache.camel.model.ProcessorDefinition; +import com.fasterxml.jackson.annotation.JsonAlias; +import org.apache.camel.k.annotation.yaml.YAMLMixIn; -@YAMLStepParser("claim-check") -public class ClaimCheckStepParser implements ProcessorStepParser { - @Override - public ProcessorDefinition toProcessor(Context context) { - return context.node(ClaimCheckDefinition.class); - } -} +@YAMLMixIn(org.apache.camel.model.RemovePropertyDefinition.class) +public abstract class RemovePropertyDefinitionMixIn { + @JsonAlias({"name", "property-name"}) + public abstract void setPropertyName(String headerName); + @JsonAlias({"name", "property-name"}) + public abstract String getPropertyName(); +} diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/YamlSourceLoader.java b/camel-k-loader-yaml/camel-k-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/YamlSourceLoader.java index ed865c30f..1c1b4cd06 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/YamlSourceLoader.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/YamlSourceLoader.java @@ -38,8 +38,8 @@ import org.apache.camel.k.SourceLoader; import org.apache.camel.k.annotation.Loader; import org.apache.camel.k.loader.yaml.model.Step; -import org.apache.camel.k.loader.yaml.parser.StartStepParser; -import org.apache.camel.k.loader.yaml.parser.StepParser; +import org.apache.camel.k.loader.yaml.spi.StartStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParser; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.RoutesDefinition; @@ -93,13 +93,14 @@ final RouteBuilder builder(InputStream is) { return new RouteBuilder() { @Override public void configure() throws Exception { + final StepParser.Resolver resolver = StepParser.Resolver.caching(new YamlStepResolver()); final CamelContext camelContext = getContext(); final List routes = new ArrayList<>(); final List rests = new ArrayList<>(); try (is) { for (Step step : mapper.readValue(is, Step[].class)) { - final StepParser.Context context = new StepParser.Context(camelContext, mapper, step.node); + final StepParser.Context context = new StepParser.Context(camelContext, mapper, step.node, resolver); final ProcessorDefinition root = StartStepParser.invoke(context, step.id); if (root == null) { diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/TestSupport.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/TestSupport.groovy index 97d5b4208..597d4296c 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/TestSupport.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/TestSupport.groovy @@ -21,8 +21,9 @@ import groovy.util.logging.Slf4j import org.apache.camel.CamelContext import org.apache.camel.component.mock.MockEndpoint import org.apache.camel.impl.DefaultCamelContext -import org.apache.camel.k.loader.yaml.parser.ProcessorStepParser -import org.apache.camel.k.loader.yaml.parser.StepParser +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser +import org.apache.camel.k.loader.yaml.spi.StartStepParser +import org.apache.camel.k.loader.yaml.spi.StepParser import org.apache.camel.model.ProcessorDefinition import spock.lang.Specification @@ -30,17 +31,18 @@ import java.nio.charset.StandardCharsets @Slf4j class TestSupport extends Specification { + static def RESOLVER = new YamlStepResolver() static def MAPPER = new YamlSourceLoader().mapper() static StepParser.Context stepContext(String content) { def node = MAPPER.readTree(content.stripMargin()) def cctx = new DefaultCamelContext() - return new StepParser.Context(cctx, MAPPER, node) + return new StepParser.Context(cctx, MAPPER, node, RESOLVER) } static StepParser.Context stepContext(JsonNode content) { - return new StepParser.Context(new DefaultCamelContext(), MAPPER, content) + return new StepParser.Context(new DefaultCamelContext(), MAPPER, content, RESOLVER) } static CamelContext startContext(String content) { @@ -105,4 +107,17 @@ class TestSupport extends Specification { static ProcessorDefinition toProcessor(Class type, String content) { return type.getConstructor().newInstance().toProcessor(stepContext(content)) } + + static ProcessorDefinition toProcessor(String id, String content) { + def ctx = stepContext(content) + def parser = RESOLVER.resolve(ctx.camelContext, id) + + if (parser instanceof ProcessorStepParser) { + return parser.toProcessor(ctx) + } + if (parser instanceof StartStepParser) { + return parser.toStartProcessor(ctx) + } + throw new IllegalArgumentException("No parser of ${id}") + } } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/BeanTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/BeanTest.groovy index 78f1486ca..30f1a19b0 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/BeanTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/BeanTest.groovy @@ -21,20 +21,16 @@ import org.apache.camel.k.loader.yaml.TestSupport import org.apache.camel.model.BeanDefinition class BeanTest extends TestSupport { - def "definition"() { - given: - def stepContext = stepContext(''' + when: + def processor = toProcessor('bean', ''' ref: "myBean" method: "process" ''') - when: - def processor = new BeanStepParser().toProcessor(stepContext) then: with(processor, BeanDefinition) { ref == 'myBean' method == 'process' } } - } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ChoiceTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ChoiceTest.groovy index 08d1a24ad..474acddb2 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ChoiceTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ChoiceTest.groovy @@ -17,6 +17,7 @@ package org.apache.camel.k.loader.yaml.parser import org.apache.camel.k.loader.yaml.TestSupport +import org.apache.camel.k.loader.yaml.spi.StepParserException import org.apache.camel.model.ChoiceDefinition class ChoiceTest extends TestSupport { diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ClaimCheckTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ClaimCheckTest.groovy index a3005673b..a43133707 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ClaimCheckTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ClaimCheckTest.groovy @@ -21,14 +21,12 @@ import org.apache.camel.model.ClaimCheckDefinition class ClaimCheckTest extends TestSupport { def "definition"() { - given: - def stepContext = stepContext(''' + when: + def processor = toProcessor('claim-check', ''' operation: "Push" key: "foo" filter: "header:(foo|bar)" ''') - when: - def processor = new ClaimCheckStepParser().toProcessor(stepContext) then: with(processor, ClaimCheckDefinition) { operation == 'Push' diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ConvertBodyTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ConvertBodyTest.groovy index 5c1daa962..a5cfc8ba4 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ConvertBodyTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ConvertBodyTest.groovy @@ -21,14 +21,12 @@ import org.apache.camel.model.ConvertBodyDefinition class ConvertBodyTest extends TestSupport { def "definition"() { - given: - def stepContext = stepContext(''' + when: + def processor = toProcessor('convert-body-to',''' type: "java.lang.String" type-class: "java.lang.String" charset: "UTF8" ''') - when: - def processor = new ConvertBodyStepParser().toProcessor(stepContext) then: with(processor, ConvertBodyDefinition) { type == 'java.lang.String' diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/FromTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/FromTest.groovy index 14b4a5b05..87161ed51 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/FromTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/FromTest.groovy @@ -17,6 +17,7 @@ package org.apache.camel.k.loader.yaml.parser import org.apache.camel.k.loader.yaml.TestSupport +import org.apache.camel.k.loader.yaml.spi.StepParserException import org.apache.camel.model.FromDefinition import org.apache.camel.model.RouteDefinition diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/LogTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/LogTest.groovy index 06b8c98a4..eeb1e9f4d 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/LogTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/LogTest.groovy @@ -23,14 +23,12 @@ import org.apache.camel.model.LogDefinition class LogTest extends TestSupport { def "definition"() { - given: - def stepContext = stepContext(''' + when: + def processor =toProcessor('log', ''' logging-level: "ERROR" message: "test" log-name: "yaml" ''') - when: - def processor = new LogStepParser().toProcessor(stepContext) then: with(processor, LogDefinition) { loggingLevel == 'ERROR' diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/PipelineTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/PipelineTest.groovy index 89955c657..68a11ddca 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/PipelineTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/PipelineTest.groovy @@ -18,6 +18,7 @@ package org.apache.camel.k.loader.yaml.parser import org.apache.camel.k.loader.yaml.TestSupport +import org.apache.camel.k.loader.yaml.spi.StepParserException import org.apache.camel.model.PipelineDefinition class PipelineTest extends TestSupport { diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemoveHeaderTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemoveHeaderTest.groovy index 39ac88ae0..4e56e749e 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemoveHeaderTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemoveHeaderTest.groovy @@ -22,12 +22,21 @@ import org.apache.camel.model.RemoveHeaderDefinition class RemoveHeaderTest extends TestSupport { def "definition"() { - given: - def stepContext = stepContext(''' - name: test + when: + def processor = toProcessor('remove-header', ''' + header-name: test ''') + then: + with(processor, RemoveHeaderDefinition) { + headerName == 'test' + } + } + + def "definition (alias)"() { when: - def processor = new RemoveHeaderStepParser().toProcessor(stepContext) + def processor = toProcessor('remove-header', ''' + name: test + ''') then: with(processor, RemoveHeaderDefinition) { headerName == 'test' diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemoveHeadersTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemoveHeadersTest.groovy index 4fd49ce40..7bedad6fa 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemoveHeadersTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemoveHeadersTest.groovy @@ -22,16 +22,14 @@ import org.apache.camel.model.RemoveHeadersDefinition class RemoveHeadersTest extends org.apache.camel.k.loader.yaml.TestSupport { def "definition"() { - given: - def stepContext = stepContext(''' + when: + def processor = toProcessor('remove-headers', ''' pattern: toRemove exclude-pattern: toExclude exclude-patterns: - toExclude1 - toExclude2 ''') - when: - def processor = new RemoveHeadersStepParser().toProcessor(stepContext) then: with(processor, RemoveHeadersDefinition) { pattern == 'toRemove' diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemovePropertiesTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemovePropertiesTest.groovy index 90a151e7e..15193d537 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemovePropertiesTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemovePropertiesTest.groovy @@ -31,7 +31,13 @@ class RemovePropertiesTest extends org.apache.camel.k.loader.yaml.TestSupport { - toExclude2 ''') when: - def processor = new RemovePropertiesStepParser().toProcessor(stepContext) + def processor = toProcessor('remove-properties', ''' + pattern: toRemove + exclude-pattern: toExclude + exclude-patterns: + - toExclude1 + - toExclude2 + ''') then: with(processor, RemovePropertiesDefinition) { pattern == 'toRemove' diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemovePropertyTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemovePropertyTest.groovy index edd04125d..6687f446f 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemovePropertyTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RemovePropertyTest.groovy @@ -22,16 +22,24 @@ import org.apache.camel.model.RemovePropertyDefinition class RemovePropertyTest extends TestSupport { def "definition"() { - given: - def stepContext = stepContext(''' - name: test - ''') when: - def processor = new RemovePropertyStepParser().toProcessor(stepContext) + def processor = toProcessor('remove-property', ''' + property-name: test + ''') then: with(processor, RemovePropertyDefinition) { propertyName == 'test' } } + def "definition (alias)"() { + when: + def processor = toProcessor('remove-property', ''' + name: test + ''') + then: + with(processor, RemovePropertyDefinition) { + propertyName == 'test' + } + } } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RestTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RestTest.groovy index 9fe806a3b..30d090e24 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RestTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RestTest.groovy @@ -17,6 +17,7 @@ package org.apache.camel.k.loader.yaml.parser import org.apache.camel.k.loader.yaml.TestSupport +import org.apache.camel.k.loader.yaml.spi.StepParserException import org.apache.camel.model.RouteDefinition import org.apache.camel.model.rest.GetVerbDefinition diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RollbackTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RollbackTest.groovy index 3ba76f614..71dc515a5 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RollbackTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/RollbackTest.groovy @@ -17,25 +17,21 @@ package org.apache.camel.k.loader.yaml.parser import org.apache.camel.k.loader.yaml.TestSupport -import org.apache.camel.model.IdempotentConsumerDefinition -import org.apache.camel.model.LogDefinition import org.apache.camel.model.RollbackDefinition class RollbackTest extends TestSupport { def "definition"() { - given: - def stepContext = stepContext(''' + when: + def processor = toProcessor('rollback', ''' mark-rollback-only: "true" message: "test" ''') - when: - def processor = new RollbackStepParser().toProcessor(stepContext) then: - with(processor, RollbackDefinition) { - markRollbackOnly == "true" - message == 'test' - } + with(processor, RollbackDefinition) { + markRollbackOnly == "true" + message == 'test' + } } } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/SetExchangePatternTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/SetExchangePatternTest.groovy index a7d35313e..9efb531f4 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/SetExchangePatternTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/SetExchangePatternTest.groovy @@ -23,12 +23,10 @@ import org.apache.camel.model.SetExchangePatternDefinition class SetExchangePatternTest extends TestSupport { def "definition"() { - given: - def stepContext = stepContext(''' + when: + def processor = toProcessor('set-exchange-pattern', ''' pattern: "InOut" ''') - when: - def processor = new SetExchangePatternStepParser().toProcessor(stepContext) then: with(processor, SetExchangePatternDefinition) { pattern == ExchangePattern.InOut.name() diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/StepTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/StepTest.groovy index a25b2690a..17ee0dd04 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/StepTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/StepTest.groovy @@ -17,6 +17,7 @@ package org.apache.camel.k.loader.yaml.parser import org.apache.camel.k.loader.yaml.TestSupport +import org.apache.camel.k.loader.yaml.spi.StepParserException import org.apache.camel.model.StepDefinition class StepTest extends TestSupport { @@ -40,7 +41,7 @@ class StepTest extends TestSupport { def "should fail without steps"() { given: - def stepContext = stepContext(TestSupport.MAPPER.createObjectNode()); + def stepContext = stepContext(MAPPER.createObjectNode()); when: new StepStepParser().toProcessor(stepContext) then: diff --git a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/LogStepParser.java b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/StopTest.groovy similarity index 66% rename from camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/LogStepParser.java rename to camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/StopTest.groovy index 2019c5ccc..f89d68dbd 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml-common/src/main/java/org/apache/camel/k/loader/yaml/parser/LogStepParser.java +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/StopTest.groovy @@ -14,17 +14,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.loader.yaml.parser; +package org.apache.camel.k.loader.yaml.parser -import org.apache.camel.k.annotation.yaml.YAMLStepParser; -import org.apache.camel.model.LogDefinition; -import org.apache.camel.model.ProcessorDefinition; -@YAMLStepParser("log") -public class LogStepParser implements ProcessorStepParser { - @Override - public ProcessorDefinition toProcessor(Context context) { - return context.node(LogDefinition.class); +import org.apache.camel.k.loader.yaml.TestSupport +import org.apache.camel.model.StopDefinition + +class StopTest extends TestSupport { + + def "definition"() { + when: + def processor = toProcessor('stop', '''{}''') + then: + with(processor, StopDefinition) { + } } -} +} diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ThreadsTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ThreadsTest.groovy index 8cb63c076..0657c0ab3 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ThreadsTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ThreadsTest.groovy @@ -27,7 +27,9 @@ class ThreadsTest extends TestSupport { pool-size: 5 ''') when: - def processor = new ThreadsStepParser().toProcessor(stepContext) + def processor = toProcessor('threads', ''' + pool-size: 5 + ''') then: with (processor, ThreadsDefinition) { poolSize == '5' diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ThrowExceptionTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ThrowExceptionTest.groovy index d592d1435..1d1295c43 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ThrowExceptionTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/ThrowExceptionTest.groovy @@ -22,18 +22,16 @@ import org.apache.camel.model.ThrowExceptionDefinition class ThrowExceptionTest extends TestSupport { def "definition"() { - given: - def stepContext = stepContext(''' - exception-type: "java.lang.IllegalArgumentException" - message: "test" - ''') when: - def processor = new ThrowExceptionStepParser().toProcessor(stepContext) - then: - with(processor, ThrowExceptionDefinition) { - message == 'test' - exceptionType == "java.lang.IllegalArgumentException" - } - } + def processor = toProcessor('throw-exception', ''' + exception-type: "java.lang.IllegalArgumentException" + message: "test" + ''') + then: + with(processor, ThrowExceptionDefinition) { + message == 'test' + exceptionType == "java.lang.IllegalArgumentException" + } + } -} + } diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/TransactedTest.groovy b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/TransactedTest.groovy index 23253f979..ed60dfef2 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/TransactedTest.groovy +++ b/camel-k-loader-yaml/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/TransactedTest.groovy @@ -23,7 +23,7 @@ class TransactedTest extends TestSupport { def "definition with expression"() { when: - def processor = toProcessor(TransactedStepParser, ''' + def processor = toProcessor('transacted', ''' ref: "my-policy" ''') then: diff --git a/camel-k-quarkus/camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus/deployment/DeploymentSupport.java b/camel-k-quarkus/camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus/deployment/DeploymentSupport.java index 01a28761b..9803f9ada 100644 --- a/camel-k-quarkus/camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus/deployment/DeploymentSupport.java +++ b/camel-k-quarkus/camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus/deployment/DeploymentSupport.java @@ -16,6 +16,12 @@ */ package org.apache.camel.k.core.quarkus.deployment; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import org.jboss.jandex.AnnotationInstance; +import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; import org.jboss.jandex.IndexView; @@ -39,4 +45,52 @@ public static Iterable getAllKnownSubclasses(IndexView view, String n public static Iterable getAllKnownSubclasses(IndexView view, Class type) { return view.getAllKnownSubclasses(DotName.createSimple(type.getName())); } + + public static Iterable getAllKnownImplementors(IndexView view, DotName type) { + return view.getAllKnownImplementors(type); + } + + public static Iterable getAllKnownSubclasses(IndexView view, DotName type) { + return view.getAllKnownSubclasses(type); + } + + public static Iterable getAnnotated(IndexView view, String name) { + return getAnnotated(view, DotName.createSimple(name)); + } + + public static Iterable getAnnotated(IndexView view, Class type) { + return getAnnotated(view, DotName.createSimple(type.getName())); + } + + public static Iterable getAnnotated(IndexView view, DotName type) { + return view.getAnnotations(type).stream() + .map(AnnotationInstance::target) + .filter(t -> t.kind() == AnnotationTarget.Kind.CLASS) + .map(AnnotationTarget::asClass) + .collect(Collectors.toList()); + } + + + public static ReflectiveClassBuildItem reflectiveClassBuildItem(ClassInfo... classInfos) { + return new ReflectiveClassBuildItem( + true, + false, + Stream.of(classInfos) + .map(ClassInfo::name) + .map(DotName::toString) + .toArray(String[]::new) + ); + } + + public static ReflectiveClassBuildItem reflectiveClassBuildItem(boolean methods, boolean fields, ClassInfo... classInfos) { + return new ReflectiveClassBuildItem( + methods, + fields, + Stream.of(classInfos) + .map(ClassInfo::name) + .map(DotName::toString) + .toArray(String[]::new) + ); + } + } diff --git a/camel-k-quarkus/camel-k-quarkus-loader-yaml/deployment/src/main/java/org/apache/camel/k/loader/yaml/quarkus/deployment/DeploymentProcessor.java b/camel-k-quarkus/camel-k-quarkus-loader-yaml/deployment/src/main/java/org/apache/camel/k/loader/yaml/quarkus/deployment/DeploymentProcessor.java index f62abb4ae..c49c1c4c8 100644 --- a/camel-k-quarkus/camel-k-quarkus-loader-yaml/deployment/src/main/java/org/apache/camel/k/loader/yaml/quarkus/deployment/DeploymentProcessor.java +++ b/camel-k-quarkus/camel-k-quarkus-loader-yaml/deployment/src/main/java/org/apache/camel/k/loader/yaml/quarkus/deployment/DeploymentProcessor.java @@ -16,8 +16,6 @@ */ package org.apache.camel.k.loader.yaml.quarkus.deployment; -import java.util.stream.Collectors; - import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.CombinedIndexBuildItem; @@ -26,29 +24,29 @@ import org.apache.camel.k.loader.yaml.model.Step; import org.apache.camel.k.loader.yaml.parser.HasDataFormat; import org.apache.camel.k.loader.yaml.parser.HasExpression; -import org.apache.camel.k.loader.yaml.parser.StepParser; -import org.apache.camel.k.loader.yaml.support.Any23DataFormatMixIn; -import org.apache.camel.k.loader.yaml.support.ExpressionNodeMixIn; -import org.apache.camel.k.loader.yaml.support.ProcessorDefinitionMixIn; -import org.apache.camel.k.loader.yaml.support.XStreamDataFormatMixIn; +import org.apache.camel.k.loader.yaml.spi.StepParser; import org.apache.camel.model.DataFormatDefinition; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.language.ExpressionDefinition; import org.apache.camel.quarkus.core.deployment.CamelServicePatternBuildItem; -import org.jboss.jandex.AnnotationInstance; -import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; import org.jboss.jandex.IndexView; +import static org.apache.camel.k.core.quarkus.deployment.DeploymentSupport.getAllKnownImplementors; +import static org.apache.camel.k.core.quarkus.deployment.DeploymentSupport.getAllKnownSubclasses; +import static org.apache.camel.k.core.quarkus.deployment.DeploymentSupport.getAnnotated; +import static org.apache.camel.k.core.quarkus.deployment.DeploymentSupport.reflectiveClassBuildItem; + public class DeploymentProcessor { public static final DotName YAML_STEP_PARSER_ANNOTATION = DotName.createSimple("org.apache.camel.k.annotation.yaml.YAMLStepParser"); public static final DotName YAML_STEP_DEFINITION_ANNOTATION = DotName.createSimple("org.apache.camel.k.annotation.yaml.YAMLNodeDefinition"); + public static final DotName YAML_MIXIN_ANNOTATION = DotName.createSimple("org.apache.camel.k.annotation.yaml.YAMLMixIn"); @BuildStep CamelServicePatternBuildItem servicePatterns() { return new CamelServicePatternBuildItem( - CamelServicePatternBuildItem.CamelServiceDestination.REGISTRY, + CamelServicePatternBuildItem.CamelServiceDestination.DISCOVERY, true, StepParser.SERVICE_LOCATION + "/*"); } @@ -61,72 +59,31 @@ void registerReflectiveClasses( IndexView view = combinedIndexBuildItem.getIndex(); for (ClassInfo ci : getAnnotated(view, YAML_STEP_PARSER_ANNOTATION)) { - reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, ci.name().toString())); + reflectiveClass.produce(reflectiveClassBuildItem(true, true, ci)); } for (ClassInfo ci : getAnnotated(view, YAML_STEP_DEFINITION_ANNOTATION)) { - reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, ci.name().toString())); + reflectiveClass.produce(reflectiveClassBuildItem(true, true, ci)); + } + for (ClassInfo ci : getAnnotated(view, YAML_MIXIN_ANNOTATION)) { + reflectiveClass.produce(reflectiveClassBuildItem(true, true, ci)); } for (ClassInfo ci : getAllKnownImplementors(view, Step.Deserializer.class)) { - reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, ci.name().toString())); + reflectiveClass.produce(reflectiveClassBuildItem(true, true, ci)); } for (ClassInfo ci : getAllKnownSubclasses(view, ProcessorDefinition.class)) { - reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, ci.name().toString())); + reflectiveClass.produce(reflectiveClassBuildItem(true, true, ci)); } for (ClassInfo ci : getAllKnownSubclasses(view, ExpressionDefinition.class)) { - reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, ci.name().toString())); + reflectiveClass.produce(reflectiveClassBuildItem(true, true, ci)); } for (ClassInfo ci : getAllKnownSubclasses(view, DataFormatDefinition.class)) { - reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, ci.name().toString())); + reflectiveClass.produce(reflectiveClassBuildItem(true, true, ci)); } reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, Step.Deserializer.class)); reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, HasExpression.class)); reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, HasDataFormat.class)); reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, Node.class)); - reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, ProcessorDefinitionMixIn.class)); - reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, ExpressionNodeMixIn.class)); - reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, Any23DataFormatMixIn.class)); - reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, XStreamDataFormatMixIn.class)); - } - - private static Iterable getAllKnownImplementors(IndexView view, String name) { - return getAllKnownImplementors(view, DotName.createSimple(name)); - } - - private static Iterable getAllKnownImplementors(IndexView view, Class type) { - return getAllKnownImplementors(view, DotName.createSimple(type.getName())); - } - - private static Iterable getAllKnownImplementors(IndexView view, DotName type) { - return view.getAllKnownImplementors(type); - } - - private static Iterable getAllKnownSubclasses(IndexView view, String name) { - return getAllKnownSubclasses(view, DotName.createSimple(name)); - } - - private static Iterable getAllKnownSubclasses(IndexView view, Class type) { - return getAllKnownSubclasses(view, DotName.createSimple(type.getName())); - } - - private static Iterable getAllKnownSubclasses(IndexView view, DotName type) { - return view.getAllKnownSubclasses(type); - } - - private static Iterable getAnnotated(IndexView view, String name) { - return getAnnotated(view, DotName.createSimple(name)); - } - - private static Iterable getAnnotated(IndexView view, Class type) { - return getAnnotated(view, DotName.createSimple(type.getName())); - } - - private static Iterable getAnnotated(IndexView view, DotName type) { - return view.getAnnotations(type).stream() - .map(AnnotationInstance::target) - .filter(t -> t.kind() == AnnotationTarget.Kind.CLASS) - .map(AnnotationTarget::asClass) - .collect(Collectors.toList()); } } diff --git a/camel-k-runtime-knative/src/main/java/org/apache/camel/k/knative/yaml/parser/KnativeStepParser.java b/camel-k-runtime-knative/src/main/java/org/apache/camel/k/knative/yaml/parser/KnativeStepParser.java index 581ae1d44..48c07f8ac 100644 --- a/camel-k-runtime-knative/src/main/java/org/apache/camel/k/knative/yaml/parser/KnativeStepParser.java +++ b/camel-k-runtime-knative/src/main/java/org/apache/camel/k/knative/yaml/parser/KnativeStepParser.java @@ -23,9 +23,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.camel.component.knative.spi.Knative; -import org.apache.camel.k.loader.yaml.parser.ProcessorStepParser; -import org.apache.camel.k.loader.yaml.parser.StartStepParser; -import org.apache.camel.k.loader.yaml.parser.StepParserSupport; +import org.apache.camel.k.loader.yaml.spi.ProcessorStepParser; +import org.apache.camel.k.loader.yaml.spi.StartStepParser; +import org.apache.camel.k.loader.yaml.spi.StepParserSupport; import org.apache.camel.model.ProcessorDefinition; import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.ToDefinition; diff --git a/examples/camel-k-runtime-example-knative/data/routes.yaml b/examples/camel-k-runtime-example-knative/data/routes.yaml index 72b90e450..dae43ba93 100644 --- a/examples/camel-k-runtime-example-knative/data/routes.yaml +++ b/examples/camel-k-runtime-example-knative/data/routes.yaml @@ -21,7 +21,7 @@ from: uri: "knative:endpoint/from" steps: - - convert-body: + - convert-body-to: type: "java.lang.String" - to: uri: "log:knative" diff --git a/examples/camel-k-runtime-example-quarkus-knative/data/routes.yaml b/examples/camel-k-runtime-example-quarkus-knative/data/routes.yaml index e0559a54b..31bda6642 100644 --- a/examples/camel-k-runtime-example-quarkus-knative/data/routes.yaml +++ b/examples/camel-k-runtime-example-quarkus-knative/data/routes.yaml @@ -21,7 +21,7 @@ from: uri: "knative://endpoint/source" steps: - - convert-body: + - convert-body-to: type: "java.lang.String" - choice: when: diff --git a/examples/camel-k-runtime-example-quarkus-yaml/data/routes.yaml b/examples/camel-k-runtime-example-quarkus-yaml/data/routes.yaml index 23c82e82d..287fd748d 100644 --- a/examples/camel-k-runtime-example-quarkus-yaml/data/routes.yaml +++ b/examples/camel-k-runtime-example-quarkus-yaml/data/routes.yaml @@ -21,7 +21,7 @@ from: uri: "platform-http:/hello" steps: - - convert-body: + - convert-body-to: type: "java.lang.String" - to: uri: "log:info" diff --git a/examples/camel-k-runtime-example-yaml/src/main/resources/routes.yaml b/examples/camel-k-runtime-example-yaml/src/main/resources/routes.yaml index 11244a04f..7a5dd037b 100644 --- a/examples/camel-k-runtime-example-yaml/src/main/resources/routes.yaml +++ b/examples/camel-k-runtime-example-yaml/src/main/resources/routes.yaml @@ -24,7 +24,7 @@ accepts: "text/plain" binding-mode: "off" steps: - - convert-body: + - convert-body-to: type: "java.lang.String" - to: uri: "log:in" @@ -50,7 +50,7 @@ uri: "log:contains2" - marshal: json: {} - - convert-body: + - convert-body-to: type: "java.lang.String" - to: uri: "log:out" @@ -63,7 +63,7 @@ accepts: "text/plain" binding-mode: "off" steps: - - convert-body: + - convert-body-to: type: "java.lang.String" - to: uri: "log:in" @@ -84,7 +84,7 @@ accepts: "text/plain" binding-mode: "off" steps: - - convert-body: + - convert-body-to: type: "java.lang.String" - to: uri: "log:in" diff --git a/pom.xml b/pom.xml index 7b5950975..c76999ecd 100644 --- a/pom.xml +++ b/pom.xml @@ -70,7 +70,7 @@ 1.9.0 3.8.1 3.0.0-M4 - 1.7.0 + 1.5 3.0.0-M4 2.7 0.3.1 diff --git a/tooling/camel-k-apt/src/main/java/org/apache/camel/k/tooling/apt/CamelProcessor.java b/tooling/camel-k-apt/src/main/java/org/apache/camel/k/tooling/apt/CamelProcessor.java index fd3d69b57..886668af6 100644 --- a/tooling/camel-k-apt/src/main/java/org/apache/camel/k/tooling/apt/CamelProcessor.java +++ b/tooling/camel-k-apt/src/main/java/org/apache/camel/k/tooling/apt/CamelProcessor.java @@ -38,12 +38,10 @@ import org.apache.camel.k.annotation.Loader; import org.apache.camel.k.annotation.LoaderInterceptor; -import org.apache.camel.k.annotation.yaml.YAMLStepParser; @SupportedAnnotationTypes({ "org.apache.camel.k.annotation.Loader", "org.apache.camel.k.annotation.LoaderInterceptor", - "org.apache.camel.k.annotation.yaml.YAMLStepParser" }) @SupportedSourceVersion(SourceVersion.RELEASE_8) public class CamelProcessor extends AbstractProcessor { @@ -67,14 +65,6 @@ public boolean process(Set annotations, RoundEnvironment e ); }); - on(element, YAMLStepParser.class, (e, a) -> { - for (String id: a.value()) { - service( - output("META-INF/services/org/apache/camel/k/loader/yaml-parser/%s", id), - e - ); - } - }); } } diff --git a/tooling/camel-k-maven-plugin/pom.xml b/tooling/camel-k-maven-plugin/pom.xml index dbab817be..00cf2876c 100644 --- a/tooling/camel-k-maven-plugin/pom.xml +++ b/tooling/camel-k-maven-plugin/pom.xml @@ -34,7 +34,7 @@ camel-k-maven-plugin - 3.6.1 + 3.6.3 3.6.0 3.1.0 diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java index f681f60a5..39822573d 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java @@ -19,11 +19,16 @@ import java.io.IOException; import java.nio.file.Paths; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Set; import javax.lang.model.element.Modifier; import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.databind.Module; +import com.google.common.base.CaseFormat; +import com.squareup.javapoet.ClassName; import com.squareup.javapoet.CodeBlock; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; @@ -55,6 +60,10 @@ public void execute() throws MojoFailureException { .indent(" ") .build() .writeTo(Paths.get(output)); + JavaFile.builder("org.apache.camel.k.loader.yaml", generateResolver()) + .indent(" ") + .build() + .writeTo(Paths.get(output)); } catch (IOException e) { throw new MojoFailureException(e.getMessage()); } @@ -86,14 +95,15 @@ public final TypeSpec generateJacksonModule() { .addParameter(Module.SetupContext.class, "context"); definitions(EXPRESSION_DEFINITION_CLASS).forEach( - (k, v) -> mb.addStatement("context.registerSubtypes(new com.fasterxml.jackson.databind.jsontype.NamedType($T.class, $S))", v, k) + (k, v) -> mb.addStatement("context.registerSubtypes(new com.fasterxml.jackson.databind.jsontype.NamedType($L.class, $S))", v.getName(), k) ); definitions(DATAFORMAT_DEFINITION_CLASS).forEach( - (k, v) -> mb.addStatement("context.registerSubtypes(new com.fasterxml.jackson.databind.jsontype.NamedType($T.class, $S))", v, k) + (k, v) -> mb.addStatement("context.registerSubtypes(new com.fasterxml.jackson.databind.jsontype.NamedType($L.class, $S))", v.getName(), k) ); definitions(LOAD_BALANCE_DEFINITION_CLASS).forEach( - (k, v) -> mb.addStatement("context.registerSubtypes(new com.fasterxml.jackson.databind.jsontype.NamedType($T.class, $S))", v, k) + (k, v) -> mb.addStatement("context.registerSubtypes(new com.fasterxml.jackson.databind.jsontype.NamedType($L.class, $S))", v.getName(), k) ); + annotated(YAML_MIXIN_ANNOTATION).forEach(i -> { final AnnotationInstance annotation = i.classAnnotation(YAML_MIXIN_ANNOTATION); final AnnotationValue targets = annotation.value("value"); @@ -124,18 +134,18 @@ public final TypeSpec generateReifiers() { .addModifiers(Modifier.PUBLIC) .addModifiers(Modifier.STATIC); - annotated(YAML_STEP_DEFINITION_ANNOTATION).forEach(i -> { - final AnnotationInstance annotation = i.classAnnotation(YAML_STEP_DEFINITION_ANNOTATION); + annotated(YAML_NODE_DEFINITION_ANNOTATION).forEach(i -> { + final AnnotationInstance annotation = i.classAnnotation(YAML_NODE_DEFINITION_ANNOTATION); final AnnotationValue reifiers = annotation.value("reifiers"); - String name = i.toString(); - if (i.nestingType() == ClassInfo.NestingType.INNER) { - name = i.enclosingClass().toString() + "." + i.simpleName(); - } - if (reifiers != null) { + String name = i.toString(); + if (i.nestingType() == ClassInfo.NestingType.INNER) { + name = i.enclosingClass().toString() + "." + i.simpleName(); + } + for (String reifier: reifiers.asStringArray()) { - mb.addStatement("org.apache.camel.reifier.ProcessorReifier.registerReifier($L.class, $L::new);", name, reifier); + mb.addStatement("org.apache.camel.reifier.ProcessorReifier.registerReifier($L.class, $L::new)", name, reifier); } } }); @@ -144,4 +154,93 @@ public final TypeSpec generateReifiers() { return type.build(); } + + public final TypeSpec generateResolver() { + Set ids = new HashSet<>(); + + MethodSpec.Builder mb = MethodSpec.methodBuilder("resolve") + .addAnnotation(Override.class) + .addModifiers(Modifier.PUBLIC) + .addParameter(ClassName.get("org.apache.camel", "CamelContext"), "camelContext") + .addParameter(ClassName.get("java.lang", "String"), "id") + .returns(ClassName.get("org.apache.camel.k.loader.yaml.spi", "StepParser")); + + mb.beginControlFlow("switch(id)"); + + // custom parsers + annotated(YAML_STEP_PARSER_ANNOTATION) + .sorted(Comparator.comparing(i -> i.name().toString())) + .forEach( + i -> { + AnnotationValue value = i.classAnnotation(YAML_STEP_PARSER_ANNOTATION).value(); + for (String id: value.asStringArray()) { + if (ids.add(id)) { + mb.beginControlFlow("case $S:", id); + mb.addStatement("return new $L()", i.name().toString()); + mb.endControlFlow(); + } + } + } + ); + + // auto generated parsers + annotated(XMLROOTELEMENT_ANNOTATION_CLASS) + .forEach( + i -> { + AnnotationInstance meta = i.classAnnotation(METADATA_ANNOTATION); + AnnotationInstance root = i.classAnnotation(XMLROOTELEMENT_ANNOTATION_CLASS); + + if (meta != null && root != null) { + AnnotationValue name = root.value("name"); + AnnotationValue label = meta.value("label"); + + if (name != null && label != null) { + // skip known definitions for which there is a custom + // implementation + switch (i.name().toString()) { + case "org.apache.camel.model.Resilience4jConfigurationDefinition": + case "org.apache.camel.model.HystrixConfigurationDefinition": + case "org.apache.camel.model.config.StreamResequencerConfig": + case "org.apache.camel.model.config.BatchResequencerConfig": + case "org.apache.camel.model.OnFallbackDefinition": + case "org.apache.camel.model.InOnlyDefinition": + case "org.apache.camel.model.InOutDefinition": + case "org.apache.camel.model.OtherwiseDefinition": + case "org.apache.camel.model.WhenDefinition": + return; + default: + break; + } + switch (i.name().prefix().toString()) { + case "org.apache.camel.model.loadbalancer": + return; + default: + break; + } + + Set labels = Set.of(label.asString().split(",", -1)); + if (labels.contains("eip")) { + String id = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, name.asString()); + if (ids.add(id)) { + mb.beginControlFlow("case $S:", id); + mb.addStatement("return new org.apache.camel.k.loader.yaml.parser.TypedProcessorStepParser($L.class)", i.name().toString()); + mb.endControlFlow(); + } + } + } + } + } + ); + + mb.beginControlFlow("default:"); + mb.addStatement("return lookup(camelContext, id)"); + mb.endControlFlow(); + mb.endControlFlow(); + + return TypeSpec.classBuilder("YamlStepResolver") + .addModifiers(Modifier.PUBLIC, Modifier.FINAL) + .addSuperinterface(ClassName.get("org.apache.camel.k.loader.yaml.spi", "StepParser.Resolver")) + .addMethod(mb.build()) + .build(); + } } diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlSupport.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlSupport.java index 337e04552..1d9c5402a 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlSupport.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlSupport.java @@ -47,9 +47,11 @@ public abstract class GenerateYamlSupport extends AbstractMojo { public static final DotName EXPRESSION_DEFINITION_CLASS = DotName.createSimple("org.apache.camel.model.language.ExpressionDefinition"); public static final DotName DATAFORMAT_DEFINITION_CLASS = DotName.createSimple("org.apache.camel.model.DataFormatDefinition"); public static final DotName XMLROOTELEMENT_ANNOTATION_CLASS = DotName.createSimple("javax.xml.bind.annotation.XmlRootElement"); - public static final DotName YAML_STEP_DEFINITION_ANNOTATION = DotName.createSimple("org.apache.camel.k.annotation.yaml.YAMLNodeDefinition"); + public static final DotName YAML_NODE_DEFINITION_ANNOTATION = DotName.createSimple("org.apache.camel.k.annotation.yaml.YAMLNodeDefinition"); + public static final DotName YAML_STEP_PARSER_ANNOTATION = DotName.createSimple("org.apache.camel.k.annotation.yaml.YAMLStepParser"); public static final DotName YAML_MIXIN_ANNOTATION = DotName.createSimple("org.apache.camel.k.annotation.yaml.YAMLMixIn"); public static final DotName LOAD_BALANCE_DEFINITION_CLASS = DotName.createSimple("org.apache.camel.model.LoadBalancerDefinition"); + public static final DotName METADATA_ANNOTATION = DotName.createSimple("org.apache.camel.spi.Metadata"); @Parameter(defaultValue = "${project}", readonly = true, required = true) protected MavenProject project; @@ -89,7 +91,6 @@ protected Stream annotated(DotName type) { ClassLoader cl = getClassLoader(); IndexView view = getCompositeIndexer(cl); - return view.getAnnotations(type).stream() .map(AnnotationInstance::target) .filter(t -> t.kind() == AnnotationTarget.Kind.CLASS) From f5d30756a615e0a0c1412252dcd015434a103cdc Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Thu, 7 May 2020 14:33:26 +0200 Subject: [PATCH 2/3] yaml-loader: add language doc --- docs/modules/languages/nav-languages.adoc | 1 + .../modules/languages/pages/yaml.adoc | 140 +++++++++--------- 2 files changed, 73 insertions(+), 68 deletions(-) rename camel-k-loader-yaml/README.adoc => docs/modules/languages/pages/yaml.adoc (94%) diff --git a/docs/modules/languages/nav-languages.adoc b/docs/modules/languages/nav-languages.adoc index 377ca336d..6fde60dfd 100644 --- a/docs/modules/languages/nav-languages.adoc +++ b/docs/modules/languages/nav-languages.adoc @@ -4,3 +4,4 @@ ** xref:languages:javascript.adoc[JavaScript] ** xref:languages:java.adoc[Java] ** xref:languages:xml.adoc[XML] +** xref:languages:yaml.adoc[YAML] diff --git a/camel-k-loader-yaml/README.adoc b/docs/modules/languages/pages/yaml.adoc similarity index 94% rename from camel-k-loader-yaml/README.adoc rename to docs/modules/languages/pages/yaml.adoc index 1956eba79..3a1333441 100644 --- a/camel-k-loader-yaml/README.adoc +++ b/docs/modules/languages/pages/yaml.adoc @@ -1,14 +1,15 @@ -= YAML DSL - -This artifact provides a YAML based DSL for Apache Camel and Apache Camel K. += Writing Integrations in YAML +[WARNING] +==== The YAML DSL is current in preview support level. +==== == Defining a route A route is a sequence of elements, or `steps`, defined as follow: -[source, yaml] +[source,yaml] ---- from: #<1> uri: "direct:start" @@ -36,7 +37,7 @@ As general rule each step provide all the parameters the related definition decl + Some steps such as `filter` and `split` have their own pipeline when an exchange matches the filter expression or for the items generated by the split expression, such pipeline can be defined by the `steps` field: + -[source, yaml] +[source,yaml] ---- filter: expression: @@ -55,7 +56,7 @@ if the `steps` field is omitted, then each subsequent step is considered part of + Some EIP such as `filter` and `split` supports the definition of an expression through the `expression` field: + -[source, yaml] +[source,yaml] .Explicit Expression field ---- filter: @@ -65,7 +66,7 @@ filter: + To make the DSL less verbose, the `expression` field can be omitted: + -[source, yaml] +[source,yaml] .Implicit Expression field ---- filter: @@ -74,7 +75,7 @@ filter: + In general expression can be defined inline like in the examples above but in case you need provide more information, you can 'unroll' the expression definition and configure any single parameter the expression defines. + -[source, yaml] +[source,yaml] .Full Expression definition ---- filter: @@ -87,7 +88,7 @@ filter: + Some EIP such as `set-body` and `marshal` supports the definition of data formats through the `data-format` field: + -[source, yaml] +[source,yaml] .Explicit Data Format field ---- set-body: @@ -98,7 +99,7 @@ set-body: + To make the DSL less verbose, the `data-format` field can be omitted: + -[source, yaml] +[source,yaml] .Implicit Data Format field ---- set-body: @@ -111,60 +112,6 @@ set-body: In case you want to use the data-format's default settings, you need to place an empty block as data format parameters, like `json: {}` ==== - -== Supported EIP - -- Aggregate -- Bean -- Choice -- Claim Check -- Convert Body -- Delay -- Dynamic Router -- Enrich -- Filter -- From -- Idempotent Consumer -- Load Balance -- Log -- Loop -- Marshal -- Multicast -- Pipeline -- PollEnrich -- Process -- Recipient List -- Remove Header -- Remove Headers -- Remove Property -- Remove Properties -- Resequence -- Rest DSL -- Rollback -- Routing Slip -- Sample -- Script -- Set Body -- Set Exchange Pattern -- Set Header -- Set Property -- Sort -- Split -- Step -- Stop -- Threads -- Throttle -- Throw Exception -- To -- To Dynamic -- Transform -- Try Catch Finally -- Unmarshal -- Validate -- Wire Tap - -The Try Catch Finally EIP currently only support specifying one `do-catch` clause. - == Extending the DSL The DSL is designed to be easily extended so you can provide your own step handler which is discovered at runtime using Camel's factory finder. @@ -181,11 +128,13 @@ class=com.acme.converter.MyConverter - create the step handler extending `org.apache.camel.k.loader.yaml.parser.ProcessorStepParser` + -[source, java] +[source,java] ---- package com.acme.converter.AcmeConverter -import org.apache.camel.k.loader.yaml.parser.ProcessorStepParser;public class AcmeConverter +import org.apache.camel.k.loader.yaml.parser.ProcessorStepParser; + +public class AcmeConverter implements ProcessorStepParser { /** * @param context contains a references to the camel context and the current node as raw JsonNode @@ -216,8 +165,7 @@ import org.apache.camel.k.loader.yaml.parser.ProcessorStepParser;public class Ac Assuming the entry in the `META-INF/services/org/apache/camel/k/yaml` is named `acme` then you can use it from the YAML DSL like: - -[source, yaml] +[source,yaml] ---- from: uri: "direct:start" @@ -227,3 +175,59 @@ from: port: 8081 ---- +== Supported EIP + +- Aggregate +- Bean +- Choice +- Circuit Breaker +- Claim Check +- Convert Body +- Delay +- Dynamic Router +- Enrich +- Filter +- From +- Idempotent Consumer +- Load Balance +- Log +- Loop +- Marshal +- Multicast +- Pipeline +- PollEnrich +- Process +- Recipient List +- Remove Header +- Remove Headers +- Remove Property +- Remove Properties +- Resequence +- Rest DSL +- Rollback +- Routing Slip +- Saga +- Sample +- Script +- ServiceCall +- Set Body +- Set Exchange Pattern +- Set Header +- Set Property +- Sort +- Split +- Step +- Stop +- Threads +- Throttle +- Throw Exception +- To +- To Dynamic +- Transacted +- Transform +- Try Catch Finally +- Unmarshal +- Validate +- Wire Tap + +The Try Catch Finally EIP currently only support specifying one `do-catch` clause. From e6c9522ac299cbc5f5ddd7f9bfd848d6e95343b9 Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Thu, 7 May 2020 16:40:53 +0200 Subject: [PATCH 3/3] yaml-loader: allow to blacklist definitions --- .../camel-k-loader-yaml/pom.xml | 14 ++++++++ .../GenerateYamlLoaderSupportClasses.java | 35 ++++++++----------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/camel-k-loader-yaml/camel-k-loader-yaml/pom.xml b/camel-k-loader-yaml/camel-k-loader-yaml/pom.xml index 1f8d67f5b..199a2d7f0 100644 --- a/camel-k-loader-yaml/camel-k-loader-yaml/pom.xml +++ b/camel-k-loader-yaml/camel-k-loader-yaml/pom.xml @@ -145,6 +145,20 @@ generate-yaml-loader-support-classes + + + org.apache.camel.model.Resilience4jConfigurationDefinition + org.apache.camel.model.HystrixConfigurationDefinition + org.apache.camel.model.OnFallbackDefinition + org.apache.camel.model.InOnlyDefinition + org.apache.camel.model.InOutDefinition + org.apache.camel.model.OtherwiseDefinition + org.apache.camel.model.WhenDefinition + org.apache.camel.model.config.StreamResequencerConfig + org.apache.camel.model.config.BatchResequencerConfig + org.apache.camel.model.loadbalancer/** + + diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java index 39822573d..91d7cc5fd 100644 --- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java +++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateYamlLoaderSupportClasses.java @@ -21,6 +21,7 @@ import java.nio.file.Paths; import java.util.Comparator; import java.util.HashSet; +import java.util.List; import java.util.Set; import javax.lang.model.element.Modifier; @@ -33,9 +34,11 @@ import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.TypeSpec; +import org.apache.camel.util.AntPathMatcher; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationValue; @@ -49,6 +52,9 @@ threadSafe = true, requiresProject = false) public class GenerateYamlLoaderSupportClasses extends GenerateYamlSupport { + @Parameter + protected List blacklistedDefinitions; + @Override public void execute() throws MojoFailureException { try { @@ -195,27 +201,14 @@ public final TypeSpec generateResolver() { AnnotationValue label = meta.value("label"); if (name != null && label != null) { - // skip known definitions for which there is a custom - // implementation - switch (i.name().toString()) { - case "org.apache.camel.model.Resilience4jConfigurationDefinition": - case "org.apache.camel.model.HystrixConfigurationDefinition": - case "org.apache.camel.model.config.StreamResequencerConfig": - case "org.apache.camel.model.config.BatchResequencerConfig": - case "org.apache.camel.model.OnFallbackDefinition": - case "org.apache.camel.model.InOnlyDefinition": - case "org.apache.camel.model.InOutDefinition": - case "org.apache.camel.model.OtherwiseDefinition": - case "org.apache.camel.model.WhenDefinition": - return; - default: - break; - } - switch (i.name().prefix().toString()) { - case "org.apache.camel.model.loadbalancer": - return; - default: - break; + + if (blacklistedDefinitions != null) { + for (String blacklistedDefinition: blacklistedDefinitions) { + if (AntPathMatcher.INSTANCE.match(blacklistedDefinition.replace('.', '/'), i.name().toString('/'))) { + getLog().debug("Skipping definition: " + i.name().toString()); + return; + } + } } Set labels = Set.of(label.asString().split(",", -1));