-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml-dsl: enable flow mode deserialization by default
- Loading branch information
1 parent
2ec6ab7
commit b3e53c5
Showing
6 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...aml-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/yaml/YamlDslConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.apache.camel.quarkus.dsl.yaml; | ||
|
||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
@ConfigRoot(name = "camel.yaml", phase = ConfigPhase.BUILD_TIME) | ||
public class YamlDslConfiguration { | ||
/** | ||
* If {@code true} the YAML DSL support flow-mode which allow to write more concise routes as for EIPs that have | ||
* their own output like filter, aggregate, split, etc. the {@code steps} element can be omitted an in that case, | ||
* the next processing step is automatically wired to the EIP's outputs. | ||
* <p/> | ||
* As example, a YAML DSL to process only the timer events from 5 to 10 would look like: | ||
* | ||
* <pre> | ||
* {@code | ||
* - from: | ||
* uri: "timer:tick" | ||
* steps: | ||
* - filter: | ||
* simple: "${exchangeProperty.CamelTimerCounter} range '5..10'" | ||
* steps: | ||
* - to: "direct:filtered" | ||
* } | ||
* </pre> | ||
* | ||
* With the flow mode enabled the same logic can be expressed in a more concise way: | ||
* | ||
* <pre> | ||
* {@code | ||
* - from: | ||
* uri: "kamelet:source" | ||
* steps: | ||
* - filter: | ||
* simple: "${exchangeProperty.CamelTimerCounter} range '5..10'" | ||
* - to: "kamelet:sink" | ||
* } | ||
* </pre> | ||
* | ||
* | ||
*/ | ||
@ConfigItem(defaultValue = "true") | ||
public boolean flowMode; | ||
} |
21 changes: 21 additions & 0 deletions
21
...ore/yaml-dsl/runtime/src/main/java/org/apache/camel/quarkus/dsl/yaml/YamlDslRecorder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.apache.camel.quarkus.dsl.yaml; | ||
|
||
import io.quarkus.runtime.RuntimeValue; | ||
import io.quarkus.runtime.annotations.Recorder; | ||
import org.apache.camel.CamelContext; | ||
import org.apache.camel.dsl.yaml.YamlRoutesBuilderLoader; | ||
import org.apache.camel.spi.CamelContextCustomizer; | ||
|
||
@Recorder | ||
public class YamlDslRecorder { | ||
public RuntimeValue<CamelContextCustomizer> setYamlDeserializationMode(String mode) { | ||
return new RuntimeValue<>(new CamelContextCustomizer() { | ||
@Override | ||
public void configure(CamelContext camelContext) { | ||
camelContext.getGlobalOptions().put( | ||
YamlRoutesBuilderLoader.DESERIALIZATION_MODE, | ||
mode); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters