From 528aae4374f66e4e82eb02ab4fc8e0ff22fd29cd Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 21 Feb 2019 10:54:46 +0100 Subject: [PATCH 1/2] Removed runtime folder --- runtime/.gitignore | 10 - runtime/.maven-versions-rules.xml | 39 -- runtime/camel-k-maven-plugin/pom.xml | 169 ----- .../k/tooling/maven/GenerateCatalogMojo.java | 227 ------- .../maven/GenerateDependencyListMojo.java | 104 ---- .../k/tooling/maven/GenerateRestXML.java | 94 --- .../camel/k/tooling/maven/model/Artifact.java | 67 -- .../k/tooling/maven/model/CamelArtifact.java | 170 ----- .../k/tooling/maven/model/CamelScheme.java | 71 --- .../model/CatalogComponentDefinition.java | 81 --- .../model/CatalogDataFormatDefinition.java | 60 -- .../model/CatalogLanguageDefinition.java | 60 -- .../tooling/maven/model/CatalogProcessor.java | 42 -- .../k/tooling/maven/model/CatalogSupport.java | 47 -- .../tooling/maven/model/crd/CamelCatalog.java | 35 -- .../maven/model/crd/CamelCatalogSpec.java | 40 -- .../k/tooling/maven/model/k8s/ObjectMeta.java | 37 -- .../k/tooling/maven/model/k8s/TypeMeta.java | 37 -- .../processors/CatalogProcessor_2_x.java | 163 ----- .../src/main/resources/META-INF/LICENSE.txt | 203 ------ .../src/main/resources/META-INF/NOTICE.txt | 11 - ...mel.k.tooling.maven.model.CatalogProcessor | 1 - runtime/camel-k-runtime-core/pom.xml | 86 --- .../java/org/apache/camel/k/Constants.java | 34 - .../org/apache/camel/k/ContextCustomizer.java | 30 - .../org/apache/camel/k/InMemoryRegistry.java | 81 --- .../java/org/apache/camel/k/RoutesLoader.java | 40 -- .../main/java/org/apache/camel/k/Runtime.java | 78 --- .../main/java/org/apache/camel/k/Source.java | 99 --- .../k/listener/AbstractPhaseListener.java | 36 -- .../camel/k/listener/ContextConfigurer.java | 51 -- .../listener/ContextLifecycleConfigurer.java | 48 -- .../camel/k/listener/RoutesConfigurer.java | 83 --- .../apache/camel/k/listener/RoutesDumper.java | 57 -- .../k/support/PlatformStreamHandler.java | 116 ---- .../camel/k/support/RuntimeSupport.java | 214 ------- .../apache/camel/k/support/URIResolver.java | 66 -- .../src/main/resources/META-INF/LICENSE.txt | 203 ------ .../src/main/resources/META-INF/NOTICE.txt | 11 - runtime/camel-k-runtime-groovy/pom.xml | 117 ---- .../camel/k/groovy/GroovyRoutesLoader.groovy | 57 -- .../groovy/dsl/ComponentConfiguration.groovy | 68 -- .../groovy/dsl/ComponentsConfiguration.groovy | 84 --- .../k/groovy/dsl/ContextConfiguration.groovy | 42 -- .../dsl/IntegrationConfiguration.groovy | 78 --- .../k/groovy/dsl/RegistryConfiguration.groovy | 35 -- .../k/groovy/dsl/RestConfiguration.groovy | 45 -- .../extension/LogComponentExtension.groovy | 33 - .../src/main/resources/META-INF/LICENSE.txt | 203 ------ .../src/main/resources/META-INF/NOTICE.txt | 11 - ...rg.codehaus.groovy.runtime.ExtensionModule | 4 - .../services/org/apache/camel/k/loader/groovy | 18 - .../apache/camel/k/groovy/LoaderTest.groovy | 48 -- .../camel/k/groovy/dsl/IntegrationTest.groovy | 98 --- .../dsl/extension/LogExtensionTest.groovy | 43 -- .../src/test/resources/log4j2-test.xml | 18 - .../resources/routes-with-bindings.groovy | 12 - ...routes-with-component-configuration.groovy | 31 - .../test/resources/routes-with-rest.groovy | 19 - .../src/test/resources/routes.groovy | 3 - runtime/camel-k-runtime-jvm/pom.xml | 129 ---- .../org/apache/camel/k/jvm/Application.java | 58 -- .../camel/k/jvm/ApplicationRuntime.java | 154 ----- .../camel/k/jvm/ApplicationSupport.java | 53 -- .../apache/camel/k/jvm/dsl/Components.java | 47 -- .../camel/k/jvm/loader/JavaClassLoader.java | 47 -- .../camel/k/jvm/loader/JavaScriptLoader.java | 73 --- .../camel/k/jvm/loader/JavaSourceLoader.java | 105 ---- .../apache/camel/k/jvm/loader/XmlLoader.java | 75 --- .../src/main/resources/META-INF/LICENSE.txt | 203 ------ .../src/main/resources/META-INF/NOTICE.txt | 11 - .../services/org/apache/camel/k/loader/class | 18 - .../services/org/apache/camel/k/loader/java | 18 - .../services/org/apache/camel/k/loader/js | 18 - .../services/org/apache/camel/k/loader/xml | 18 - .../src/main/resources/log4j2.properties | 7 - .../java/org/apache/camel/k/jvm/MyRoutes.java | 27 - .../apache/camel/k/jvm/PropertiesTest.java | 169 ----- .../camel/k/jvm/RoutesLoadersCommonTest.java | 71 --- .../apache/camel/k/jvm/RoutesLoadersTest.java | 112 ---- .../org/apache/camel/k/jvm/RuntimeTest.java | 106 ---- .../apache/camel/k/jvm/TestCustomizer.java | 39 -- .../org/apache/camel/k/customizer/test | 18 - .../src/test/resources/MyRoutes.java | 25 - .../resources/MyRoutesWithNameOverride.java | 25 - .../resources/MyRoutesWithNestedClass.java | 39 -- .../test/resources/MyRoutesWithPackage.java | 11 - .../MyRoutesWithRestConfiguration.java | 30 - .../test/resources/conf.d/001/conf.properties | 1 - .../test/resources/conf.d/002/conf.properties | 2 - .../src/test/resources/conf.properties | 2 - .../src/test/resources/log4j2-test.xml | 17 - .../src/test/resources/my-resource.txt | 1 - .../src/test/resources/r1.js | 4 - .../src/test/resources/r2.mytype | 4 - .../src/test/resources/rests.xml | 9 - .../resources/routes-compressed.js.gz.b64 | 1 - .../src/test/resources/routes.js | 2 - .../src/test/resources/routes.mytype | 3 - .../src/test/resources/routes.xml | 7 - runtime/camel-k-runtime-kotlin/pom.xml | 123 ---- .../camel/k/kotlin/KotlinRoutesLoader.kt | 87 --- .../k/kotlin/dsl/ComponentsConfiguration.kt | 43 -- .../k/kotlin/dsl/ContextConfiguration.kt | 35 -- .../k/kotlin/dsl/IntegrationConfiguration.kt | 54 -- .../k/kotlin/dsl/RegistryConfiguration.kt | 25 - .../camel/k/kotlin/dsl/RestConfiguration.kt | 39 -- .../extension/LogComponentExtensions.kt | 24 - .../src/main/resources/META-INF/LICENSE.txt | 203 ------ .../src/main/resources/META-INF/NOTICE.txt | 11 - .../services/org/apache/camel/k/loader/kts | 18 - .../org/apache/camel/k/kotlin/LoaderTest.kt | 47 -- .../camel/k/kotlin/dsl/IntegrationTest.kt | 74 --- .../k/kotlin/extension/LogExtensionTest.kt | 24 - .../src/test/resources/log4j2-test.xml | 17 - .../src/test/resources/routes-new.kts | 2 - .../test/resources/routes-with-bindings.kts | 16 - .../routes-with-component-configuration.kts | 28 - .../src/test/resources/routes-with-rest.kts | 22 - .../src/test/resources/routes.kts | 6 - .../pom.xml | 37 -- .../camel/k/spring/boot/layout/Factory.java | 49 -- .../src/main/resources/META-INF/LICENSE.txt | 203 ------ .../src/main/resources/META-INF/NOTICE.txt | 11 - .../main/resources/META-INF/spring.factories | 2 - runtime/camel-k-runtime-spring-boot/pom.xml | 137 ---- .../camel/k/spring/boot/Application.java | 65 -- .../boot/ApplicationAutoConfiguration.java | 132 ---- .../src/main/resources/META-INF/LICENSE.txt | 203 ------ .../src/main/resources/META-INF/NOTICE.txt | 11 - .../main/resources/META-INF/spring.factories | 2 - runtime/camel-k-runtime-yaml/pom.xml | 86 --- .../apache/camel/k/yaml/YamlFlowLoader.java | 103 --- .../apache/camel/k/yaml/model/Endpoint.java | 46 -- .../org/apache/camel/k/yaml/model/Flow.java | 31 - .../org/apache/camel/k/yaml/model/Step.java | 38 -- .../camel/k/yaml/model/StepHandler.java | 30 - .../k/yaml/model/handler/EndpointHandler.java | 36 -- .../src/main/resources/META-INF/LICENSE.txt | 203 ------ .../src/main/resources/META-INF/NOTICE.txt | 11 - .../services/org/apache/camel/k/loader/flow | 18 - .../org/apache/camel/k/yaml/flow/endpoint | 18 - .../apache/camel/k/yaml/RoutesLoaderTest.java | 51 -- .../src/test/resources/log4j2-test.xml | 17 - .../src/test/resources/routes.flow | 5 - runtime/camel-knative-http/pom.xml | 108 ---- .../component/knative/http/KnativeHttp.java | 22 - .../knative/http/KnativeHttpComponent.java | 263 -------- .../src/main/resources/META-INF/LICENSE.txt | 203 ------ .../src/main/resources/META-INF/NOTICE.txt | 11 - .../org/apache/camel/component/knative-http | 18 - .../knative/http/KnativeHttpMain.java | 52 -- .../src/test/resources/log4j2-test.xml | 19 - runtime/camel-knative/pom.xml | 140 ----- .../camel/component/knative/Knative.java | 47 -- .../component/knative/KnativeComponent.java | 135 ---- .../knative/KnativeConfiguration.java | 83 --- .../knative/KnativeConversionProcessor.java | 28 - .../component/knative/KnativeEndpoint.java | 212 ------- .../component/knative/KnativeEnvironment.java | 210 ------- .../component/knative/KnativeProducer.java | 79 --- .../component/knative/KnativeSupport.java | 46 -- .../knative/ce/CloudEventsProcessors.java | 65 -- .../camel/component/knative/ce/V01.java | 102 --- .../camel/component/knative/ce/V02.java | 102 --- .../src/main/resources/META-INF/LICENSE.txt | 203 ------ .../src/main/resources/META-INF/NOTICE.txt | 11 - .../org/apache/camel/component/knative | 18 - .../component/knative/CloudEventsV01Test.java | 349 ----------- .../component/knative/CloudEventsV02Test.java | 349 ----------- .../knative/KnativeComponentTest.java | 585 ------------------ .../src/test/resources/environment.json | 26 - .../src/test/resources/log4j2-test.xml | 19 - runtime/pom.xml | 316 ---------- 174 files changed, 12191 deletions(-) delete mode 100644 runtime/.gitignore delete mode 100644 runtime/.maven-versions-rules.xml delete mode 100644 runtime/camel-k-maven-plugin/pom.xml delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateDependencyListMojo.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/Artifact.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CamelArtifact.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CamelScheme.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogComponentDefinition.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogDataFormatDefinition.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogLanguageDefinition.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogProcessor.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogSupport.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/crd/CamelCatalog.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/crd/CamelCatalogSpec.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/k8s/ObjectMeta.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/k8s/TypeMeta.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java delete mode 100644 runtime/camel-k-maven-plugin/src/main/resources/META-INF/LICENSE.txt delete mode 100644 runtime/camel-k-maven-plugin/src/main/resources/META-INF/NOTICE.txt delete mode 100644 runtime/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.model.CatalogProcessor delete mode 100644 runtime/camel-k-runtime-core/pom.xml delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Constants.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/ContextCustomizer.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/InMemoryRegistry.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RoutesLoader.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Runtime.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Source.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/AbstractPhaseListener.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextConfigurer.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextLifecycleConfigurer.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesDumper.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/PlatformStreamHandler.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/RuntimeSupport.java delete mode 100644 runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/URIResolver.java delete mode 100644 runtime/camel-k-runtime-core/src/main/resources/META-INF/LICENSE.txt delete mode 100644 runtime/camel-k-runtime-core/src/main/resources/META-INF/NOTICE.txt delete mode 100644 runtime/camel-k-runtime-groovy/pom.xml delete mode 100644 runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentConfiguration.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentsConfiguration.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RestConfiguration.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/extension/LogComponentExtension.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/main/resources/META-INF/LICENSE.txt delete mode 100644 runtime/camel-k-runtime-groovy/src/main/resources/META-INF/NOTICE.txt delete mode 100644 runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule delete mode 100644 runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org/apache/camel/k/loader/groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/test/resources/log4j2-test.xml delete mode 100644 runtime/camel-k-runtime-groovy/src/test/resources/routes-with-bindings.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/test/resources/routes-with-component-configuration.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/test/resources/routes-with-rest.groovy delete mode 100644 runtime/camel-k-runtime-groovy/src/test/resources/routes.groovy delete mode 100644 runtime/camel-k-runtime-jvm/pom.xml delete mode 100644 runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/Application.java delete mode 100644 runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationRuntime.java delete mode 100644 runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationSupport.java delete mode 100644 runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/dsl/Components.java delete mode 100644 runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaClassLoader.java delete mode 100644 runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaScriptLoader.java delete mode 100644 runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaSourceLoader.java delete mode 100644 runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/XmlLoader.java delete mode 100644 runtime/camel-k-runtime-jvm/src/main/resources/META-INF/LICENSE.txt delete mode 100644 runtime/camel-k-runtime-jvm/src/main/resources/META-INF/NOTICE.txt delete mode 100644 runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/class delete mode 100644 runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/java delete mode 100644 runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/js delete mode 100644 runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/xml delete mode 100644 runtime/camel-k-runtime-jvm/src/main/resources/log4j2.properties delete mode 100644 runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/MyRoutes.java delete mode 100644 runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java delete mode 100644 runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersCommonTest.java delete mode 100644 runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java delete mode 100644 runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTest.java delete mode 100644 runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/TestCustomizer.java delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/META-INF/services/org/apache/camel/k/customizer/test delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/MyRoutes.java delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithNameOverride.java delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithNestedClass.java delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithPackage.java delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithRestConfiguration.java delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/conf.d/001/conf.properties delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/conf.d/002/conf.properties delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/conf.properties delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/log4j2-test.xml delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/my-resource.txt delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/r1.js delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/r2.mytype delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/rests.xml delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/routes-compressed.js.gz.b64 delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/routes.js delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/routes.mytype delete mode 100644 runtime/camel-k-runtime-jvm/src/test/resources/routes.xml delete mode 100644 runtime/camel-k-runtime-kotlin/pom.xml delete mode 100644 runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt delete mode 100644 runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ComponentsConfiguration.kt delete mode 100644 runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt delete mode 100644 runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt delete mode 100644 runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt delete mode 100644 runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RestConfiguration.kt delete mode 100644 runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/extension/LogComponentExtensions.kt delete mode 100644 runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/LICENSE.txt delete mode 100644 runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/NOTICE.txt delete mode 100644 runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/services/org/apache/camel/k/loader/kts delete mode 100644 runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt delete mode 100644 runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationTest.kt delete mode 100644 runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/extension/LogExtensionTest.kt delete mode 100644 runtime/camel-k-runtime-kotlin/src/test/resources/log4j2-test.xml delete mode 100644 runtime/camel-k-runtime-kotlin/src/test/resources/routes-new.kts delete mode 100644 runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-bindings.kts delete mode 100644 runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-component-configuration.kts delete mode 100644 runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-rest.kts delete mode 100644 runtime/camel-k-runtime-kotlin/src/test/resources/routes.kts delete mode 100644 runtime/camel-k-runtime-spring-boot-layout/pom.xml delete mode 100644 runtime/camel-k-runtime-spring-boot-layout/src/main/java/org/apache/camel/k/spring/boot/layout/Factory.java delete mode 100644 runtime/camel-k-runtime-spring-boot-layout/src/main/resources/META-INF/LICENSE.txt delete mode 100644 runtime/camel-k-runtime-spring-boot-layout/src/main/resources/META-INF/NOTICE.txt delete mode 100644 runtime/camel-k-runtime-spring-boot-layout/src/main/resources/META-INF/spring.factories delete mode 100644 runtime/camel-k-runtime-spring-boot/pom.xml delete mode 100644 runtime/camel-k-runtime-spring-boot/src/main/java/org/apache/camel/k/spring/boot/Application.java delete mode 100644 runtime/camel-k-runtime-spring-boot/src/main/java/org/apache/camel/k/spring/boot/ApplicationAutoConfiguration.java delete mode 100644 runtime/camel-k-runtime-spring-boot/src/main/resources/META-INF/LICENSE.txt delete mode 100644 runtime/camel-k-runtime-spring-boot/src/main/resources/META-INF/NOTICE.txt delete mode 100644 runtime/camel-k-runtime-spring-boot/src/main/resources/META-INF/spring.factories delete mode 100644 runtime/camel-k-runtime-yaml/pom.xml delete mode 100644 runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/YamlFlowLoader.java delete mode 100644 runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/Endpoint.java delete mode 100644 runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/Flow.java delete mode 100644 runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/Step.java delete mode 100644 runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/StepHandler.java delete mode 100644 runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/handler/EndpointHandler.java delete mode 100644 runtime/camel-k-runtime-yaml/src/main/resources/META-INF/LICENSE.txt delete mode 100644 runtime/camel-k-runtime-yaml/src/main/resources/META-INF/NOTICE.txt delete mode 100644 runtime/camel-k-runtime-yaml/src/main/resources/META-INF/services/org/apache/camel/k/loader/flow delete mode 100644 runtime/camel-k-runtime-yaml/src/main/resources/META-INF/services/org/apache/camel/k/yaml/flow/endpoint delete mode 100644 runtime/camel-k-runtime-yaml/src/test/java/org/apache/camel/k/yaml/RoutesLoaderTest.java delete mode 100644 runtime/camel-k-runtime-yaml/src/test/resources/log4j2-test.xml delete mode 100644 runtime/camel-k-runtime-yaml/src/test/resources/routes.flow delete mode 100644 runtime/camel-knative-http/pom.xml delete mode 100644 runtime/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttp.java delete mode 100644 runtime/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpComponent.java delete mode 100644 runtime/camel-knative-http/src/main/resources/META-INF/LICENSE.txt delete mode 100644 runtime/camel-knative-http/src/main/resources/META-INF/NOTICE.txt delete mode 100644 runtime/camel-knative-http/src/main/resources/META-INF/services/org/apache/camel/component/knative-http delete mode 100644 runtime/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpMain.java delete mode 100644 runtime/camel-knative-http/src/test/resources/log4j2-test.xml delete mode 100644 runtime/camel-knative/pom.xml delete mode 100644 runtime/camel-knative/src/main/java/org/apache/camel/component/knative/Knative.java delete mode 100644 runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java delete mode 100644 runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java delete mode 100644 runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConversionProcessor.java delete mode 100644 runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java delete mode 100644 runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEnvironment.java delete mode 100644 runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeProducer.java delete mode 100644 runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeSupport.java delete mode 100644 runtime/camel-knative/src/main/java/org/apache/camel/component/knative/ce/CloudEventsProcessors.java delete mode 100644 runtime/camel-knative/src/main/java/org/apache/camel/component/knative/ce/V01.java delete mode 100644 runtime/camel-knative/src/main/java/org/apache/camel/component/knative/ce/V02.java delete mode 100644 runtime/camel-knative/src/main/resources/META-INF/LICENSE.txt delete mode 100644 runtime/camel-knative/src/main/resources/META-INF/NOTICE.txt delete mode 100644 runtime/camel-knative/src/main/resources/META-INF/services/org/apache/camel/component/knative delete mode 100644 runtime/camel-knative/src/test/java/org/apache/camel/component/knative/CloudEventsV01Test.java delete mode 100644 runtime/camel-knative/src/test/java/org/apache/camel/component/knative/CloudEventsV02Test.java delete mode 100644 runtime/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java delete mode 100644 runtime/camel-knative/src/test/resources/environment.json delete mode 100644 runtime/camel-knative/src/test/resources/log4j2-test.xml delete mode 100644 runtime/pom.xml diff --git a/runtime/.gitignore b/runtime/.gitignore deleted file mode 100644 index ed92983151..0000000000 --- a/runtime/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -target - -*.iml - -.idea -.project -.metadata -.settings -.factorypath -.classpath diff --git a/runtime/.maven-versions-rules.xml b/runtime/.maven-versions-rules.xml deleted file mode 100644 index 44e512be36..0000000000 --- a/runtime/.maven-versions-rules.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - (?i).*Alpha(?:-?\d+)? - (?i).*a(?:-?\d+)? - (?i).*Beta(?:-?\d+)? - (?i).*-B(?:-?\d+)? - (?i).*RC(?:-?\d+)? - (?i).*CR(?:-?\d+)? - (?i).*M(?:-?\d+)? - - - - - - \ No newline at end of file diff --git a/runtime/camel-k-maven-plugin/pom.xml b/runtime/camel-k-maven-plugin/pom.xml deleted file mode 100644 index a6ad36e9bf..0000000000 --- a/runtime/camel-k-maven-plugin/pom.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - - - org.apache.camel.k - camel-k-runtime-parent - 0.3.0-SNAPSHOT - - - 4.0.0 - maven-plugin - - camel-k-maven-plugin - - - - org.apache.maven - maven-core - 3.6.0 - - - * - * - - - - - org.apache.maven.plugin-tools - maven-plugin-annotations - 3.6.0 - - - org.codehaus.plexus - plexus-utils - - - - - org.apache.maven.shared - maven-common-artifact-filters - 3.1.0 - - - org.apache.maven - maven-repository-metadata - - - org.codehaus.plexus - plexus-utils - - - - - org.apache.maven - maven-plugin-api - 3.6.0 - - - * - * - - - - - org.apache.camel - camel-swagger-rest-dsl-generator - ${camel.version} - provided - - - org.apache.camel - camel-catalog - provided - - - org.yaml - snakeyaml - ${snakeyaml.version} - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.datatype - jackson-datatype-jdk8 - ${jackson.version} - - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - org.apache.commons - commons-lang3 - ${commons-lang.version} - - - com.vdurmont - semver4j - ${semver4j.version} - - - org.immutables - value - ${immutables.version} - provided - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson.version} - - - com.google.guava - guava - 20.0 - - - - - - - org.apache.maven.plugins - maven-plugin-plugin - 3.5.2 - - - - - - default-descriptor - process-classes - - descriptor - - - - help-goal - - helpmojo - - - - - - - diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java deleted file mode 100644 index d6abd9c5f5..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java +++ /dev/null @@ -1,227 +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.tooling.maven; - -import java.io.IOException; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Comparator; -import java.util.Map; -import java.util.Objects; -import java.util.ServiceLoader; -import java.util.SortedMap; -import java.util.TreeMap; -import java.util.stream.StreamSupport; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; -import org.apache.camel.catalog.DefaultCamelCatalog; -import org.apache.camel.k.tooling.maven.model.CamelArtifact; -import org.apache.camel.k.tooling.maven.model.CatalogComponentDefinition; -import org.apache.camel.k.tooling.maven.model.CatalogDataFormatDefinition; -import org.apache.camel.k.tooling.maven.model.CatalogLanguageDefinition; -import org.apache.camel.k.tooling.maven.model.CatalogProcessor; -import org.apache.camel.k.tooling.maven.model.CatalogSupport; -import org.apache.camel.k.tooling.maven.model.crd.CamelCatalog; -import org.apache.camel.k.tooling.maven.model.crd.CamelCatalogSpec; -import org.apache.camel.k.tooling.maven.model.k8s.ObjectMeta; -import org.apache.commons.lang3.StringUtils; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -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.apache.maven.project.MavenProject; - -@Mojo( - name = "generate-catalog", - defaultPhase = LifecyclePhase.GENERATE_RESOURCES, - threadSafe = true, - requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, - requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME) -public class GenerateCatalogMojo extends AbstractMojo { - - @Parameter(readonly = true, defaultValue = "${project}") - private MavenProject project; - - @Parameter(property = "catalog.path", defaultValue = "${project.build.directory}") - private String outputPath; - - @Parameter(property = "catalog.file", defaultValue = "camel-catalog-${catalog.version}.yaml") - private String outputFile; - - // ******************** - // - // ******************** - - @Override - public void execute() throws MojoExecutionException, MojoFailureException { - final Path output = Paths.get(this.outputPath, this.outputFile); - - try { - if (Files.notExists(output.getParent())) { - Files.createDirectories(output.getParent()); - } - - if (Files.exists(output)) { - Files.delete(output); - } - } catch (IOException e) { - throw new MojoExecutionException("Exception while generating camel catalog", e); - } - - final SortedMap artifacts = new TreeMap<>(); - final org.apache.camel.catalog.CamelCatalog catalog = new DefaultCamelCatalog(); - - try { - processComponents(catalog, artifacts); - processLanguages(catalog, artifacts); - processDataFormats(catalog, artifacts); - - ServiceLoader processors = ServiceLoader.load(CatalogProcessor.class); - Comparator comparator = Comparator.comparingInt(CatalogProcessor::getOrder); - - // - // post process catalog - // - StreamSupport.stream(processors.spliterator(), false).sorted(comparator).filter(p -> p.accepts(catalog)).forEach(p -> { - getLog().info("Executing processor: " + p.getClass().getName()); - - p.process(project, catalog, artifacts); - }); - - // - // apiVersion: camel.apache.org/v1alpha1 - // kind: CamelCatalog - // metadata: - // name: catalog-x.y.z - // labels: - // app: "camel-k" - // camel.apache.org/catalog.version: x.y.x - // camel.apache.org/catalog.loader.version: x.y.z - // spec: - // version: - // status: - // artifacts: - // - try (Writer writer = Files.newBufferedWriter(output, StandardCharsets.UTF_8)) { - CamelCatalog cr = new CamelCatalog.Builder() - .metadata(new ObjectMeta.Builder() - .name("camel-catalog-" + catalog.getCatalogVersion()) - .putLabels("app", "camel-k") - .putLabels("camel.apache.org/catalog.version", catalog.getCatalogVersion()) - .putLabels("camel.apache.org/catalog.loader.version", catalog.getLoadedVersion()) - .build()) - .spec(new CamelCatalogSpec.Builder() - .version(catalog.getCatalogVersion()) - .artifacts(artifacts) - .build()) - .build(); - - YAMLFactory factory = new YAMLFactory() - .configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true) - .configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true) - .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false) - .configure(YAMLGenerator.Feature.WRITE_DOC_START_MARKER, false); - - //new Yaml(representer, options).dump(cr, writer); - ObjectMapper mapper = new ObjectMapper(factory); - mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); - mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY); - mapper.writeValue(writer, cr); - } - } catch (IOException e) { - throw new MojoExecutionException("Exception while generating catalog", e); - } - } - - private void processComponents(org.apache.camel.catalog.CamelCatalog catalog, Map artifacts) { - for (String name : catalog.findComponentNames()) { - String json = catalog.componentJSonSchema(name); - CatalogComponentDefinition definition = CatalogSupport.unmarshallComponent(json); - - artifacts.compute(definition.getArtifactId(), (key, artifact) -> { - if (artifact == null) { - artifact = new CamelArtifact(); - artifact.setGroupId(definition.getGroupId()); - artifact.setArtifactId(definition.getArtifactId()); - - Objects.requireNonNull(artifact.getGroupId()); - Objects.requireNonNull(artifact.getArtifactId()); - } - - definition.getSchemes() - .map(StringUtils::trimToNull) - .filter(Objects::nonNull) - .forEach(artifact::createScheme); - - return artifact; - }); - } - } - - private void processLanguages(org.apache.camel.catalog.CamelCatalog catalog, Map artifacts) { - for (String name : catalog.findLanguageNames()) { - String json = catalog.languageJSonSchema(name); - CatalogLanguageDefinition definition = CatalogSupport.unmarshallLanguage(json); - - artifacts.compute(definition.getArtifactId(), (key, artifact) -> { - if (artifact == null) { - artifact = new CamelArtifact(); - artifact.setGroupId(definition.getGroupId()); - artifact.setArtifactId(definition.getArtifactId()); - - Objects.requireNonNull(artifact.getGroupId()); - Objects.requireNonNull(artifact.getArtifactId()); - } - - artifact.addLanguage(definition.getName()); - - return artifact; - }); - } - } - - private void processDataFormats(org.apache.camel.catalog.CamelCatalog catalog, Map artifacts) { - for (String name : catalog.findDataFormatNames()) { - String json = catalog.dataFormatJSonSchema(name); - CatalogDataFormatDefinition definition = CatalogSupport.unmarshallDataFormat(json); - - artifacts.compute(definition.getArtifactId(), (key, artifact) -> { - if (artifact == null) { - artifact = new CamelArtifact(); - artifact.setGroupId(definition.getGroupId()); - artifact.setArtifactId(definition.getArtifactId()); - - Objects.requireNonNull(artifact.getGroupId()); - Objects.requireNonNull(artifact.getArtifactId()); - } - - artifact.addDataformats(definition.getName()); - - return artifact; - }); - } - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateDependencyListMojo.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateDependencyListMojo.java deleted file mode 100644 index 80e63f2a8e..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateDependencyListMojo.java +++ /dev/null @@ -1,104 +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.tooling.maven; - -import java.io.IOException; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.DefaultArtifact; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -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.apache.maven.project.MavenProject; -import org.apache.maven.shared.utils.StringUtils; -import org.yaml.snakeyaml.DumperOptions; -import org.yaml.snakeyaml.Yaml; - -@Mojo( - name = "generate-dependency-list", - defaultPhase = LifecyclePhase.PREPARE_PACKAGE, - threadSafe = true, - requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, - requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME) -public class GenerateDependencyListMojo extends AbstractMojo { - @Parameter(readonly = true, defaultValue = "${project}") - private MavenProject project; - - @Parameter(defaultValue = "${project.build.directory}/dependencies.yaml") - private String outputFile; - - @Parameter(defaultValue = "true") - private boolean includeLocation; - - @Override - public void execute() throws MojoExecutionException, MojoFailureException { - final Path output = Paths.get(this.outputFile); - - try { - if (Files.notExists(output.getParent())) { - Files.createDirectories(output.getParent()); - } - } catch (IOException e) { - throw new MojoExecutionException("Exception while generating dependencies list", e); - } - - try (Writer writer = Files.newBufferedWriter(output, StandardCharsets.UTF_8)) { - List> deps = project.getArtifacts().stream() - .filter(this::isCompileOrRuntime) - .map(this::artifactToMap) - .collect(Collectors.toList()); - - DumperOptions options = new DumperOptions(); - options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); - - Yaml yaml = new Yaml(options); - yaml.dump(Collections.singletonMap("dependencies", deps), writer); - } catch (IOException e) { - throw new MojoExecutionException("Exception while generating dependencies list", e); - } - } - - private boolean isCompileOrRuntime(Artifact artifact) { - return StringUtils.equals(artifact.getScope(), DefaultArtifact.SCOPE_COMPILE) - || StringUtils.equals(artifact.getScope(), DefaultArtifact.SCOPE_RUNTIME); - } - - private Map artifactToMap(Artifact artifact) { - Map dep = new HashMap<>(); - dep.put("id", artifact.getId()); - - if (includeLocation && artifact.getFile() != null) { - dep.put("location", artifact.getFile().getAbsolutePath()); - } - - return dep; - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java deleted file mode 100644 index 11855ba3d7..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateRestXML.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.apache.camel.k.tooling.maven; -/** - * 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. - */ - -import java.io.PrintWriter; -import java.io.Writer; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import io.swagger.models.Swagger; -import io.swagger.parser.SwaggerParser; -import org.apache.camel.CamelContext; -import org.apache.camel.generator.swagger.RestDslXmlGenerator; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -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; - -@Mojo( - name = "generate-rest-xml", - inheritByDefault = false, - defaultPhase = LifecyclePhase.GENERATE_SOURCES, - requiresDependencyResolution = ResolutionScope.COMPILE, - threadSafe = true, - requiresProject = false) -public class GenerateRestXML extends AbstractMojo { - @Parameter(property = "openapi.spec") - private String inputFile; - @Parameter(property = "dsl.out") - private String outputFile; - - @Override - public void execute() throws MojoExecutionException { - if (inputFile == null) { - throw new MojoExecutionException("Missing input file: " + inputFile); - } - - Path input = Paths.get(this.inputFile); - if (!Files.exists(input)) { - throw new MojoExecutionException("Unable to read the input file: " + inputFile); - } - - final SwaggerParser sparser = new SwaggerParser(); - final Swagger swagger = sparser.read(inputFile); - if (swagger == null) { - throw new MojoExecutionException("Unable to read the swagger file: " + inputFile); - } - - try { - final Writer writer; - - if (outputFile != null) { - Path output = Paths.get(this.outputFile); - - if (output.getParent() != null && Files.notExists(output.getParent())) { - Files.createDirectories(output.getParent()); - } - if (Files.exists(output)) { - Files.delete(output); - } - - writer = Files.newBufferedWriter(output); - } else { - writer = new PrintWriter(System.out); - } - - final CamelContext context = new DefaultCamelContext(); - final String dsl = RestDslXmlGenerator.toXml(swagger).generate(context); - - writer.write(dsl); - writer.close(); - } catch (Exception e) { - throw new MojoExecutionException("Exception while generating rest xml", e); - } - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/Artifact.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/Artifact.java deleted file mode 100644 index 852916d00c..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/Artifact.java +++ /dev/null @@ -1,67 +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.tooling.maven.model; - -import java.util.Objects; - -public class Artifact { - private String groupId; - private String artifactId; - private String version; - - public String getGroupId() { - return groupId; - } - - public void setGroupId(String groupId) { - this.groupId = groupId; - } - - public String getArtifactId() { - return artifactId; - } - - public void setArtifactId(String artifactId) { - this.artifactId = artifactId; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Artifact artifact = (Artifact) o; - return Objects.equals(groupId, artifact.groupId) && - Objects.equals(artifactId, artifact.artifactId); - } - - @Override - public int hashCode() { - return Objects.hash(groupId, artifactId); - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CamelArtifact.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CamelArtifact.java deleted file mode 100644 index 68f3816d36..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CamelArtifact.java +++ /dev/null @@ -1,170 +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.tooling.maven.model; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; - -public class CamelArtifact extends Artifact { - private List schemes; - private List languages; - private List dataformats; - private List dependencies; - private List exclusions; - - public CamelArtifact() { - this.schemes = new ArrayList<>(); - this.languages = new ArrayList<>(); - this.dataformats = new ArrayList<>(); - this.dependencies = new ArrayList<>(); - this.exclusions = new ArrayList<>(); - } - - public void setSchemes(List schemes) { - this.schemes = schemes; - } - - public void addScheme(CamelScheme scheme) { - if (!this.schemes.contains(scheme)) { - this.schemes.add(scheme); - } - } - - public List getLanguages() { - return languages; - } - - public void setLanguages(List languages) { - this.languages = languages; - } - - public void addLanguage(String language) { - if (!this.languages.contains(language)) { - this.languages.add(language); - } - } - - public List getDataformats() { - return dataformats; - } - - public void setDataformats(List dataformats) { - this.dataformats = dataformats; - } - - public void addDataformats(String dataformat) { - if (!this.dataformats.contains(dataformat)) { - this.dataformats.add(dataformat); - } - } - - public List getSchemes() { - return schemes; - } - - public Optional getScheme(String id) { - return schemes.stream().filter(s -> Objects.equals(s.getId(), id)).findFirst(); - } - - public CamelScheme createScheme(String id) { - for (CamelScheme scheme: schemes) { - if (scheme.getId().equals(id)) { - return scheme; - } - } - - - CamelScheme answer = new CamelScheme(); - answer.setId(id); - - schemes.add(answer); - - return answer; - } - - public List getDependencies() { - return dependencies; - } - - public void setDependencies(List dependencies) { - this.dependencies = dependencies; - } - - public void addDependency(Artifact dependency) { - if (!this.dependencies.contains(dependency)) { - this.dependencies.add(dependency); - } - } - - public void addDependency(String groupId, String artifactId) { - Artifact artifact = new Artifact(); - artifact.setGroupId(groupId); - artifact.setArtifactId(artifactId); - - addDependency(artifact); - } - - public void addDependency(String groupId, String artifactId, String version) { - Artifact artifact = new Artifact(); - artifact.setGroupId(groupId); - artifact.setArtifactId(artifactId); - artifact.setVersion(version); - - addDependency(artifact); - } - - public List getExclusions() { - return exclusions; - } - - public void setExclusions(List exclusions) { - this.exclusions = exclusions; - } - - public void addExclusion(Artifact exclusion) { - if (!this.exclusions.contains(exclusion)) { - this.exclusions.add(exclusion); - } - } - - public void addExclusion(String groupId, String artifactId) { - Artifact artifact = new Artifact(); - artifact.setGroupId(groupId); - artifact.setArtifactId(artifactId); - - addExclusion(artifact); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CamelArtifact artifact = (CamelArtifact) o; - return Objects.equals(getArtifactId(), artifact.getArtifactId()); - } - - @Override - public int hashCode() { - return Objects.hash(getArtifactId()); - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CamelScheme.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CamelScheme.java deleted file mode 100644 index 36de765918..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CamelScheme.java +++ /dev/null @@ -1,71 +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.tooling.maven.model; - -import java.util.Objects; - -public class CamelScheme { - private String id; - private boolean http; - private boolean passive; - - public CamelScheme() { - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public boolean isHttp() { - return http; - } - - public void setHttp(boolean http) { - this.http = http; - } - - public boolean isPassive() { - return passive; - } - - public void setPassive(boolean passive) { - this.passive = passive; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - CamelScheme scheme = (CamelScheme) o; - return isHttp() == scheme.isHttp() && - isPassive() == scheme.isPassive() && - Objects.equals(getId(), scheme.getId()); - } - - @Override - public int hashCode() { - return Objects.hash(getId(), isHttp(), isPassive()); - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogComponentDefinition.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogComponentDefinition.java deleted file mode 100644 index db16c67e5e..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogComponentDefinition.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.apache.camel.k.tooling.maven.model; - -import java.util.stream.Stream; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.commons.lang3.StringUtils; - -@JsonIgnoreProperties(ignoreUnknown = true) -public final class CatalogComponentDefinition { - private String scheme; - private String groupId; - private String artifactId; - private String version; - private String alternativeSchemes; - - public Stream getSchemes() { - String schemeIDs = StringUtils.trimToEmpty(alternativeSchemes); - - return Stream.concat( - Stream.of(scheme), - Stream.of(StringUtils.split(schemeIDs, ',')) - ); - } - - public String getScheme() { - return scheme; - } - - public void setScheme(String scheme) { - this.scheme = scheme; - } - - public String getGroupId() { - return groupId; - } - - public void setGroupId(String groupId) { - this.groupId = groupId; - } - - public String getArtifactId() { - return artifactId; - } - - public void setArtifactId(String artifactId) { - this.artifactId = artifactId; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getAlternativeSchemes() { - return alternativeSchemes; - } - - public void setAlternativeSchemes(String alternativeSchemes) { - this.alternativeSchemes = alternativeSchemes; - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Container { - private CatalogComponentDefinition delegate; - - @JsonCreator - public Container( - @JsonProperty("component") CatalogComponentDefinition delegate) { - this.delegate = delegate; - } - - public CatalogComponentDefinition unwrap() { - return delegate; - } - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogDataFormatDefinition.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogDataFormatDefinition.java deleted file mode 100644 index 3dd200c798..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogDataFormatDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.apache.camel.k.tooling.maven.model; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -public final class CatalogDataFormatDefinition { - private String name; - private String groupId; - private String artifactId; - private String version; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getGroupId() { - return groupId; - } - - public void setGroupId(String groupId) { - this.groupId = groupId; - } - - public String getArtifactId() { - return artifactId; - } - - public void setArtifactId(String artifactId) { - this.artifactId = artifactId; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Container { - private CatalogDataFormatDefinition delegate; - - @JsonCreator - public Container( - @JsonProperty("dataformat") CatalogDataFormatDefinition delegate) { - this.delegate = delegate; - } - - public CatalogDataFormatDefinition unwrap() { - return delegate; - } - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogLanguageDefinition.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogLanguageDefinition.java deleted file mode 100644 index 3bcca1ef0d..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogLanguageDefinition.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.apache.camel.k.tooling.maven.model; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonProperty; - -@JsonIgnoreProperties(ignoreUnknown = true) -public final class CatalogLanguageDefinition { - private String name; - private String groupId; - private String artifactId; - private String version; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getGroupId() { - return groupId; - } - - public void setGroupId(String groupId) { - this.groupId = groupId; - } - - public String getArtifactId() { - return artifactId; - } - - public void setArtifactId(String artifactId) { - this.artifactId = artifactId; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - @JsonIgnoreProperties(ignoreUnknown = true) - public static final class Container { - private CatalogLanguageDefinition delegate; - - @JsonCreator - public Container( - @JsonProperty("language") CatalogLanguageDefinition delegate) { - this.delegate = delegate; - } - - public CatalogLanguageDefinition unwrap() { - return delegate; - } - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogProcessor.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogProcessor.java deleted file mode 100644 index e8e1622b8e..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogProcessor.java +++ /dev/null @@ -1,42 +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.tooling.maven.model; - -import java.util.Map; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.maven.project.MavenProject; - -public interface CatalogProcessor { - /** - * The highest precedence - */ - int HIGHEST = Integer.MIN_VALUE; - - /** - * The lowest precedence - */ - int LOWEST = Integer.MAX_VALUE; - - boolean accepts(CamelCatalog catalog); - - void process(MavenProject project, CamelCatalog catalog, Map artifacts); - - default int getOrder() { - return LOWEST; - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogSupport.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogSupport.java deleted file mode 100644 index 0fe38aab5f..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/CatalogSupport.java +++ /dev/null @@ -1,47 +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.tooling.maven.model; - -import java.io.IOException; - -import com.fasterxml.jackson.databind.ObjectMapper; - -public final class CatalogSupport { - - private CatalogSupport() { - } - - private static T unmarshall(String json, Class type) { - try { - return new ObjectMapper().readValue(json, type); - } catch (IOException e) { - throw new IllegalArgumentException(e); - } - } - - public static CatalogComponentDefinition unmarshallComponent(String json) { - return unmarshall(json, CatalogComponentDefinition.Container.class).unwrap(); - } - - public static CatalogLanguageDefinition unmarshallLanguage(String json) { - return unmarshall(json, CatalogLanguageDefinition.Container.class).unwrap(); - } - - public static CatalogDataFormatDefinition unmarshallDataFormat(String json) { - return unmarshall(json, CatalogDataFormatDefinition.Container.class).unwrap(); - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/crd/CamelCatalog.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/crd/CamelCatalog.java deleted file mode 100644 index 7e53dc0d9d..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/crd/CamelCatalog.java +++ /dev/null @@ -1,35 +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.tooling.maven.model.crd; - -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.apache.camel.k.tooling.maven.model.k8s.ObjectMeta; -import org.apache.camel.k.tooling.maven.model.k8s.TypeMeta; -import org.immutables.value.Value; - -@Value.Immutable -@JsonDeserialize(builder = CamelCatalog.Builder.class) -@JsonPropertyOrder({ "apiVersion", "kind", "metadata", "spec" }) -public interface CamelCatalog extends TypeMeta { - ObjectMeta getMetadata(); - - CamelCatalogSpec getSpec(); - - class Builder extends ImmutableCamelCatalog.Builder { - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/crd/CamelCatalogSpec.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/crd/CamelCatalogSpec.java deleted file mode 100644 index 6488201cc8..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/crd/CamelCatalogSpec.java +++ /dev/null @@ -1,40 +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.tooling.maven.model.crd; - -import java.util.Collections; -import java.util.SortedMap; - -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.apache.camel.k.tooling.maven.model.CamelArtifact; -import org.immutables.value.Value; - -@Value.Immutable -@JsonDeserialize(builder = CamelCatalogSpec.Builder.class) -@JsonPropertyOrder({ "version", "artifacts" }) -public interface CamelCatalogSpec { - String getVersion(); - - @Value.Default - default SortedMap getArtifacts() { - return Collections.emptySortedMap(); - } - - class Builder extends ImmutableCamelCatalogSpec.Builder { - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/k8s/ObjectMeta.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/k8s/ObjectMeta.java deleted file mode 100644 index 72694fe542..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/k8s/ObjectMeta.java +++ /dev/null @@ -1,37 +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.tooling.maven.model.k8s; - -import java.util.Collections; -import java.util.Map; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.immutables.value.Value; - -@Value.Immutable -@JsonDeserialize(builder = ObjectMeta.Builder.class) -public interface ObjectMeta { - String getName(); - - @Value.Default - default Map getLabels() { - return Collections.emptyMap(); - } - - class Builder extends ImmutableObjectMeta.Builder { - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/k8s/TypeMeta.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/k8s/TypeMeta.java deleted file mode 100644 index 756ccb31ff..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/model/k8s/TypeMeta.java +++ /dev/null @@ -1,37 +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.tooling.maven.model.k8s; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import org.immutables.value.Value; - -@Value.Immutable -@JsonDeserialize(builder = TypeMeta.Builder.class) -public interface TypeMeta { - @Value.Default - default String getApiVersion() { - return "camel.apache.org/v1alpha1"; - } - - @Value.Default - default String getKind() { - return "CamelCatalog"; - } - - class Builder extends ImmutableTypeMeta.Builder { - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java b/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java deleted file mode 100644 index 1a2c4a3e9d..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java +++ /dev/null @@ -1,163 +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.tooling.maven.processors; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import com.vdurmont.semver4j.Semver; - -import org.apache.camel.Ordered; -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.k.tooling.maven.model.CamelArtifact; -import org.apache.camel.k.tooling.maven.model.CatalogProcessor; -import org.apache.maven.project.MavenProject; - -public class CatalogProcessor_2_x implements CatalogProcessor { - private static final List KNOWN_HTTP_URIS = Arrays.asList( - "ahc", - "ahc-ws", - "atmosphere-websocket", - "cxf", - "cxfrs", - "grpc", - "jetty", - "netty-http", - "netty4-http", - "rest", - "restlet", - "servlet", - "spark-rest", - "spring-ws", - "undertow", - "websocket" - ); - - private static final List KNOWN_PASSIVE_URIS = Arrays.asList( - "bean", - "binding", - "browse", - "class", - "controlbus", - "dataformat", - "dataset", - "direct", - "direct-vm", - "language", - "log", - "mock", - "properties", - "ref", - "seda", - "stub", - "test", - "validator", - "vm" - ); - - @Override - public int getOrder() { - return HIGHEST; - } - - @Override - public boolean accepts(CamelCatalog catalog) { - return new Semver(catalog.getCatalogVersion(), Semver.SemverType.IVY).satisfies("[2.18,3]"); - } - - @Override - public void process(MavenProject project, CamelCatalog catalog, Map artifacts) { - - // ************************ - // - // camel-k-runtime-jvm - // - // ************************ - - { - CamelArtifact artifact = new CamelArtifact(); - artifact.setGroupId("org.apache.camel.k"); - artifact.setArtifactId("camel-k-runtime-jvm"); - artifact.setVersion(project.getVersion()); - artifact.addDependency("org.apache.camel", "camel-core"); - - artifacts.put(artifact.getArtifactId(), artifact); - } - - // ************************ - // - // camel-k-runtime-groovy - // - // ************************ - - { - CamelArtifact artifact = new CamelArtifact(); - artifact.setGroupId("org.apache.camel.k"); - artifact.setArtifactId("camel-k-runtime-groovy"); - artifact.setVersion(project.getVersion()); - artifact.addDependency("org.apache.camel", "camel-groovy"); - - artifacts.put(artifact.getArtifactId(), artifact); - } - - // ************************ - // - // camel-k-runtime-kotlin - // - // ************************ - - { - CamelArtifact artifact = new CamelArtifact(); - artifact.setGroupId("org.apache.camel.k"); - artifact.setArtifactId("camel-k-runtime-kotlin"); - artifact.setVersion(project.getVersion()); - - artifacts.put(artifact.getArtifactId(), artifact); - } - - // ************************ - // - // camel-knative - // - // ************************ - - { - CamelArtifact artifact = new CamelArtifact(); - artifact.setGroupId("org.apache.camel.k"); - artifact.setArtifactId("camel-knative"); - artifact.setVersion(project.getVersion()); - artifact.createScheme("knative").setHttp(true); - artifact.addDependency("org.apache.camel", "camel-netty4-http"); - - artifacts.put(artifact.getArtifactId(), artifact); - } - - // ************************ - // - // - // - // ************************ - - for (String scheme: KNOWN_HTTP_URIS) { - artifacts.values().forEach(artifact -> artifact.getScheme(scheme).ifPresent(s -> s.setHttp(true))); - } - for (String scheme: KNOWN_PASSIVE_URIS) { - artifacts.values().forEach(artifact -> artifact.getScheme(scheme).ifPresent(s -> s.setPassive(true))); - } - } -} diff --git a/runtime/camel-k-maven-plugin/src/main/resources/META-INF/LICENSE.txt b/runtime/camel-k-maven-plugin/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b1270ff..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - diff --git a/runtime/camel-k-maven-plugin/src/main/resources/META-INF/NOTICE.txt b/runtime/camel-k-maven-plugin/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf2e6..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. diff --git a/runtime/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.model.CatalogProcessor b/runtime/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.model.CatalogProcessor deleted file mode 100644 index 1531453467..0000000000 --- a/runtime/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.model.CatalogProcessor +++ /dev/null @@ -1 +0,0 @@ -org.apache.camel.k.tooling.maven.processors.CatalogProcessor_2_x diff --git a/runtime/camel-k-runtime-core/pom.xml b/runtime/camel-k-runtime-core/pom.xml deleted file mode 100644 index 6f704df384..0000000000 --- a/runtime/camel-k-runtime-core/pom.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - org.apache.camel.k - camel-k-runtime-parent - 0.3.0-SNAPSHOT - - 4.0.0 - - camel-k-runtime-core - - - - - - - - - - - org.apache.camel - camel-core - provided - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.apache.commons - commons-lang3 - ${commons-lang.version} - - - commons-io - commons-io - ${commons-io.version} - - - - - - - - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - - org.assertj - assertj-core - ${assertj.version} - test - - - - diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Constants.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Constants.java deleted file mode 100644 index d9d2d9d452..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Constants.java +++ /dev/null @@ -1,34 +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; - -public final class Constants { - public static final String ENV_CAMEL_K_ROUTES = "CAMEL_K_ROUTES"; - public static final String ENV_CAMEL_K_CONF = "CAMEL_K_CONF"; - public static final String ENV_CAMEL_K_CONF_D = "CAMEL_K_CONF_D"; - public static final String ENV_CAMEL_K_CUSTOMIZERS = "CAMEL_K_CUSTOMIZERS"; - public static final String SCHEME_CLASSPATH = "classpath:"; - public static final String SCHEME_FILE = "file:"; - public static final String SCHEME_ENV = "env:"; - public static final String LOGGING_LEVEL_PREFIX = "logging.level."; - public static final String ROUTES_LOADER_RESOURCE_PATH = "META-INF/services/org/apache/camel/k/loader/"; - public static final String CONTEXT_CUSTOMIZER_RESOURCE_PATH = "META-INF/services/org/apache/camel/k/customizer/"; - public static final String PROPERTY_CAMEL_K_CUSTOMIZER = "camel.k.customizer"; - - private Constants() { - } -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/ContextCustomizer.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/ContextCustomizer.java deleted file mode 100644 index c6d6b1dbee..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/ContextCustomizer.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; - -import org.apache.camel.CamelContext; - -@FunctionalInterface -public interface ContextCustomizer { - /** - * Perform CamelContext customization. - * - * @param camelContext the camel context to customize. - * @param registry the runtime registry. - */ - void apply(CamelContext camelContext, Runtime.Registry registry); -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/InMemoryRegistry.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/InMemoryRegistry.java deleted file mode 100644 index 1b6c9e66e9..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/InMemoryRegistry.java +++ /dev/null @@ -1,81 +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; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.stream.Collectors; - -import org.apache.camel.NoSuchBeanException; - -public final class InMemoryRegistry implements Runtime.Registry { - private final ConcurrentMap registry; - - public InMemoryRegistry() { - this.registry = new ConcurrentHashMap<>(); - } - - public void bind(String name, Object bean) { - this.registry.put(name, bean); - } - - @Override - public Object lookupByName(String name) { - return registry.get(name); - } - - @Override - public T lookupByNameAndType(String name, Class type) { - final Object answer = lookupByName(name); - - if (answer != null) { - try { - return type.cast(answer); - } catch (Throwable t) { - throw new NoSuchBeanException( - name, - "Found bean: " + name + " in RuntimeRegistry: " + this + " of type: " + answer.getClass().getName() + " expected type was: " + type, - t - ); - } - } - - return null; - } - - @Override - public Map findByTypeWithName(Class type) { - final Map result = new HashMap<>(); - - registry.entrySet().stream() - .filter(entry -> type.isInstance(entry.getValue())) - .forEach(entry -> result.put(entry.getKey(), type.cast(entry.getValue()))); - - return result; - } - - @Override - public Set findByType(Class type) { - return registry.values().stream() - .filter(type::isInstance) - .map(type::cast) - .collect(Collectors.toSet()); - } -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RoutesLoader.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RoutesLoader.java deleted file mode 100644 index 13922640e9..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/RoutesLoader.java +++ /dev/null @@ -1,40 +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; - -import java.util.List; - -import org.apache.camel.builder.RouteBuilder; - -public interface RoutesLoader { - /** - * Provides a list of the languages supported by this loader. - * - * @return the supported languages. - */ - List getSupportedLanguages(); - - /** - * Creates a camel {@link RouteBuilder} from the given resource. - * - * @param registry the runtime registry. - * @param source the source to load. - * @return the RouteBuilder. - * @throws Exception - */ - RouteBuilder load(Runtime.Registry registry, Source source) throws Exception; -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Runtime.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Runtime.java deleted file mode 100644 index 31fbbe5ec7..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Runtime.java +++ /dev/null @@ -1,78 +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; - -import java.util.Map; -import java.util.Properties; - -import org.apache.camel.CamelContext; -import org.apache.camel.component.properties.PropertiesComponent; -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.function.ThrowingConsumer; - -public interface Runtime { - /** - * Returns the context associated to this runtime. - */ - CamelContext getContext(); - - /** - * Returns the registry associated to this runtime. - */ - Registry getRegistry(); - - default void setProperties(Properties properties) { - PropertiesComponent pc = new PropertiesComponent(); - pc.setInitialProperties(properties); - - getRegistry().bind("properties", pc); - } - - enum Phase { - Starting, - ConfigureContext, - ConfigureRoutes, - Started - } - - @FunctionalInterface - interface Listener { - void accept(Phase phase, Runtime runtime); - } - - interface Registry extends org.apache.camel.spi.Registry { - void bind(String name, Object bean); - - @SuppressWarnings("deprecation") - @Override - default public Object lookup(String name) { - return lookupByName(name); - } - - @SuppressWarnings("deprecation") - @Override - default public T lookup(String name, Class type) { - return lookupByNameAndType(name, type); - } - - @SuppressWarnings("deprecation") - @Override - default public Map lookupByType(Class type) { - return findByTypeWithName(type); - } - } -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Source.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Source.java deleted file mode 100644 index ccedd65d51..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/Source.java +++ /dev/null @@ -1,99 +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; - -import java.util.Map; - -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.URISupport; -import org.apache.commons.lang3.StringUtils; - -public class Source { - private final String name; - private final String location; - private final String language; - private final boolean compressed; - - private Source(String name, String location, String language, boolean compression) { - this.name = name; - this.location = location; - this.language = language; - this.compressed = compression; - } - - public String getName() { - return name; - } - - public String getLocation() { - return location; - } - - public String getLanguage() { - return language; - } - - public boolean isCompressed() { - return compressed; - } - - @Override - public String toString() { - return "Source{" + - "location='" + location + '\'' + - ", language=" + language + - ", compressed=" + compressed + - '}'; - } - - public static Source create(String uri) throws Exception { - final String location = StringUtils.substringBefore(uri, "?"); - - if (!location.startsWith(Constants.SCHEME_CLASSPATH) && - !location.startsWith(Constants.SCHEME_FILE) && - !location.startsWith(Constants.SCHEME_ENV)) { - throw new IllegalArgumentException("No valid resource format, expected scheme:path, found " + uri); - } - - final String query = StringUtils.substringAfter(uri, "?"); - final Map params = URISupport.parseQuery(query); - final String languageName = (String) params.get("language"); - final String compression = (String) params.get("compression"); - - - String language = languageName; - if (ObjectHelper.isEmpty(language)) { - language = StringUtils.substringAfterLast(location, ":"); - language = StringUtils.substringAfterLast(language, "."); - } - if (ObjectHelper.isEmpty(language)) { - throw new IllegalArgumentException("Unknown language " + language); - } - - String name = (String) params.get("name"); - if (name == null) { - name = StringUtils.substringAfter(location, ":"); - name = StringUtils.substringBeforeLast(name, "."); - - if (name.contains("/")) { - name = StringUtils.substringAfterLast(name, "/"); - } - } - - return new Source(name, location, language, Boolean.valueOf(compression)); - } -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/AbstractPhaseListener.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/AbstractPhaseListener.java deleted file mode 100644 index 7de4991716..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/AbstractPhaseListener.java +++ /dev/null @@ -1,36 +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.listener; - -import org.apache.camel.k.Runtime; - -public abstract class AbstractPhaseListener implements Runtime.Listener { - private final Runtime.Phase phase; - - protected AbstractPhaseListener(Runtime.Phase phase) { - this.phase = phase; - } - - @Override - public void accept(Runtime.Phase phase, Runtime runtime) { - if (this.phase == phase) { - accept(runtime); - } - } - - protected abstract void accept(Runtime runtime); -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextConfigurer.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextConfigurer.java deleted file mode 100644 index ef02736c29..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextConfigurer.java +++ /dev/null @@ -1,51 +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.listener; - -import org.apache.camel.k.Runtime; -import org.apache.camel.k.support.RuntimeSupport; - -public class ContextConfigurer extends AbstractPhaseListener { - public ContextConfigurer() { - super(Runtime.Phase.ConfigureContext); - } - - @Override - protected void accept(Runtime runtime) { - // - // Configure the camel context using properties in the form: - // - // camel.context.${name} = ${value} - // - RuntimeSupport.bindProperties(runtime.getContext(), runtime.getContext(), "camel.context."); - - // - // Configure the camel rest definition using properties in the form: - // - // camel.rest.${name} = ${value} - // - RuntimeSupport.configureRest(runtime.getContext()); - - // - // Programmatically configure the camel context. - // - // This is useful to configure services such as the ClusterService, - // RouteController, etc - // - RuntimeSupport.configureContext(runtime.getContext(), runtime.getRegistry()); - } -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextLifecycleConfigurer.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextLifecycleConfigurer.java deleted file mode 100644 index 85383c7083..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextLifecycleConfigurer.java +++ /dev/null @@ -1,48 +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.listener; - -import org.apache.camel.Component; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.support.RuntimeSupport; -import org.apache.camel.support.LifecycleStrategySupport; - -public class ContextLifecycleConfigurer extends AbstractPhaseListener { - public ContextLifecycleConfigurer() { - super(Runtime.Phase.ConfigureContext); - } - - @Override - protected void accept(Runtime runtime) { - // - // Configure components upon creation - // - runtime.getContext().addLifecycleStrategy(new LifecycleStrategySupport() { - @SuppressWarnings("unchecked") - @Override - public void onComponentAdd(String name, Component component) { - // The prefix that identifies component properties is the - // same one used by camel-spring-boot to configure components - // using starters: - // - // camel.component.${scheme}.${name} = ${value} - // - RuntimeSupport.bindProperties(runtime.getContext(), component, "camel.component." + name + "."); - } - }); - } -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java deleted file mode 100644 index 8c1b0eb58b..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java +++ /dev/null @@ -1,83 +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.listener; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.k.Constants; -import org.apache.camel.k.RoutesLoader; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.Source; -import org.apache.camel.k.support.RuntimeSupport; -import org.apache.camel.util.ObjectHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RoutesConfigurer extends AbstractPhaseListener { - private static final Logger LOGGER = LoggerFactory.getLogger(RoutesConfigurer.class); - - public RoutesConfigurer() { - super(Runtime.Phase.ConfigureRoutes); - } - - @Override - protected void accept(Runtime runtime) { - final String routes = System.getenv(Constants.ENV_CAMEL_K_ROUTES); - - if (ObjectHelper.isEmpty(routes)) { - LOGGER.warn("No valid routes found in {} environment variable", Constants.ENV_CAMEL_K_ROUTES); - } - - load(runtime, routes.split(",", -1)); - } - - protected void load(Runtime runtime, String[] routes) { - for (String route: routes) { - final Source source; - final RoutesLoader loader; - final RouteBuilder builder; - - try { - source = Source.create(route); - loader = RuntimeSupport.loaderFor(runtime.getContext(), source); - builder = loader.load(runtime.getRegistry(), source); - } catch (Exception e) { - throw ObjectHelper.wrapRuntimeCamelException(e); - } - - if (builder == null) { - throw new IllegalStateException("Unable to load route from: " + route); - } - - LOGGER.info("Loading routes from: {}", route); - - try { - runtime.getContext().addRoutes(builder); - } catch (Exception e) { - throw ObjectHelper.wrapRuntimeCamelException(e); - } - } - } - - public static RoutesConfigurer forRoutes(String... routes) { - return new RoutesConfigurer() { - @Override - protected void accept(Runtime runtime) { - load(runtime, routes); - } - }; - } -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesDumper.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesDumper.java deleted file mode 100644 index 379fc7fde3..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesDumper.java +++ /dev/null @@ -1,57 +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.listener; - -import javax.xml.bind.JAXBException; - -import org.apache.camel.CamelContext; -import org.apache.camel.k.Runtime; -import org.apache.camel.model.ModelHelper; -import org.apache.camel.model.RoutesDefinition; -import org.apache.camel.model.rest.RestsDefinition; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class RoutesDumper extends AbstractPhaseListener { - private static final Logger LOGGER = LoggerFactory.getLogger(RoutesDumper.class); - - public RoutesDumper() { - super(Runtime.Phase.Started); - } - - @Override - protected void accept(Runtime runtime) { - CamelContext context = runtime.getContext(); - - RoutesDefinition routes = new RoutesDefinition(); - routes.setRoutes(context.getRouteDefinitions()); - - RestsDefinition rests = new RestsDefinition(); - rests.setRests(context.getRestDefinitions()); - - try { - if (LOGGER.isDebugEnabled() && !routes.getRoutes().isEmpty()) { - LOGGER.debug("Routes: \n{}", ModelHelper.dumpModelAsXml(context, routes)); - } - if (LOGGER.isDebugEnabled() && !rests.getRests().isEmpty()) { - LOGGER.debug("Rests: \n{}", ModelHelper.dumpModelAsXml(context, rests)); - } - } catch (JAXBException e) { - throw new IllegalArgumentException(e); - } - } -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/PlatformStreamHandler.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/PlatformStreamHandler.java deleted file mode 100644 index fbd0403a63..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/PlatformStreamHandler.java +++ /dev/null @@ -1,116 +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.support; - -import java.io.ByteArrayInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLConnection; -import java.net.URLStreamHandler; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Base64; -import java.util.Map; -import java.util.zip.GZIPInputStream; - -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.URISupport; -import org.apache.commons.lang3.StringUtils; - -public class PlatformStreamHandler extends URLStreamHandler { - public static void configure() { - URL.setURLStreamHandlerFactory(protocol -> "platform".equals(protocol) ? new PlatformStreamHandler() : null); - } - - @Override - protected URLConnection openConnection(URL url) throws IOException { - return new URLConnection(url) { - @Override - public void connect() throws IOException { - } - - @Override - public InputStream getInputStream() throws IOException { - InputStream is = null; - - // check if the file exists - Path path = Paths.get(url.getPath()); - if (Files.exists(path)) { - is = Files.newInputStream(path); - } - - // check if the file exists in classpath - if (is == null) { - is = ObjectHelper.loadResourceAsStream(url.getPath()); - } - - if (is == null) { - String name = getURL().getPath().toUpperCase(); - name = name.replace(" ", "_"); - name = name.replace(".", "_"); - name = name.replace("-", "_"); - - String envName = System.getenv(name); - String envType = StringUtils.substringBefore(envName, ":"); - String envQuery = StringUtils.substringAfter(envName, "?"); - - envName = StringUtils.substringAfter(envName, ":"); - envName = StringUtils.substringBefore(envName, "?"); - - if (envName != null) { - try { - final Map params = URISupport.parseQuery(envQuery); - final boolean compression = Boolean.valueOf((String) params.get("compression")); - - if (StringUtils.equals(envType, "env")) { - String data = System.getenv(envName); - - if (data == null) { - throw new IllegalArgumentException("Unknown env var: " + envName); - } - - is = new ByteArrayInputStream(data.getBytes()); - } else if (StringUtils.equals(envType, "file")) { - Path data = Paths.get(envName); - - if (!Files.exists(data)) { - throw new FileNotFoundException(envName); - } - - is = Files.newInputStream(data); - } else if (StringUtils.equals(envType, "classpath")) { - is = ObjectHelper.loadResourceAsStream(envName); - } - - if (is != null && compression) { - is = new GZIPInputStream(Base64.getDecoder().wrap(is)); - } - } catch (URISyntaxException e) { - throw new IOException(e); - } - } - } - - return is; - } - }; - } -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/RuntimeSupport.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/RuntimeSupport.java deleted file mode 100644 index ce41289d39..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/RuntimeSupport.java +++ /dev/null @@ -1,214 +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.support; - -import java.io.IOException; -import java.io.Reader; -import java.nio.file.FileVisitResult; -import java.nio.file.FileVisitor; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.Objects; -import java.util.Properties; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.camel.CamelContext; -import org.apache.camel.NoFactoryAvailableException; -import org.apache.camel.component.properties.PropertiesComponent; -import org.apache.camel.k.Constants; -import org.apache.camel.k.ContextCustomizer; -import org.apache.camel.k.RoutesLoader; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.Source; -import org.apache.camel.spi.FactoryFinder; -import org.apache.camel.spi.RestConfiguration; -import org.apache.camel.util.IntrospectionSupport; -import org.apache.camel.util.ObjectHelper; -import org.apache.commons.io.FilenameUtils; - - -public final class RuntimeSupport { - - private RuntimeSupport() { - } - - public static void configureContext(CamelContext context, Runtime.Registry registry) { - try { - FactoryFinder finder = context.getFactoryFinder(Constants.CONTEXT_CUSTOMIZER_RESOURCE_PATH); - String customizerIDs = System.getenv().getOrDefault(Constants.ENV_CAMEL_K_CUSTOMIZERS, ""); - - if (ObjectHelper.isEmpty(customizerIDs)) { - PropertiesComponent component = context.getComponent("properties", PropertiesComponent.class); - Properties properties = component.getInitialProperties(); - - if (properties != null) { - customizerIDs = properties.getProperty(Constants.PROPERTY_CAMEL_K_CUSTOMIZER, ""); - } - } - - if (ObjectHelper.isNotEmpty(customizerIDs)) { - for (String customizerId : customizerIDs.split(",", -1)) { - configureContext(context, customizerId, (ContextCustomizer) finder.newInstance(customizerId), registry); - } - } - } catch (NoFactoryAvailableException e) { - // ignored - } - - //this is to initialize all customizers that might be already present in the context injected by other means. - context.getRegistry().findByTypeWithName(ContextCustomizer.class).forEach( - (customizerId, customizer) -> configureContext(context, customizerId, customizer, registry) - ); - } - - public static void configureContext(CamelContext context, String customizerId, ContextCustomizer customizer, Runtime.Registry registry) { - bindProperties(context, customizer, "customizer." + customizerId + "."); - customizer.apply(context, registry); - } - - public static void configureRest(CamelContext context) { - RestConfiguration configuration = new RestConfiguration(); - - if (RuntimeSupport.bindProperties(context, configuration, "camel.rest.") > 0) { - // - // Set the rest configuration if only if at least one - // rest parameter has been set. - // - context.setRestConfiguration(configuration); - } - } - - public static int bindProperties(CamelContext context, Object target, String prefix) { - final PropertiesComponent component = context.getComponent("properties", PropertiesComponent.class); - final Properties properties = component.getInitialProperties(); - - if (properties == null) { - return 0; - } - - return bindProperties(properties, target, prefix); - } - - public static int bindProperties(Properties properties, Object target, String prefix) { - final AtomicInteger count = new AtomicInteger(); - - properties.entrySet().stream() - .filter(entry -> entry.getKey() instanceof String) - .filter(entry -> entry.getValue() != null) - .filter(entry -> ((String)entry.getKey()).startsWith(prefix)) - .forEach(entry -> { - final String key = ((String)entry.getKey()).substring(prefix.length()); - final Object val = entry.getValue(); - - try { - if (IntrospectionSupport.setProperty(target, key, val, false)) { - count.incrementAndGet(); - } - } catch (Exception ex) { - throw new RuntimeException(ex); - } - } - ); - - return count.get(); - } - - public static RoutesLoader loaderFor(CamelContext context, Source source) { - return context.getRegistry().findByType(RoutesLoader.class).stream() - .filter(rl -> rl.getSupportedLanguages().contains(source.getLanguage())) - .findFirst() - .orElseGet(() -> lookupLoaderFromResource(context, source)); - } - - public static RoutesLoader lookupLoaderFromResource(CamelContext context, Source source) { - final FactoryFinder finder; - final RoutesLoader loader; - - try { - finder = context.getFactoryFinder(Constants.ROUTES_LOADER_RESOURCE_PATH); - loader = (RoutesLoader)finder.newInstance(source.getLanguage()); - } catch (NoFactoryAvailableException e) { - throw new IllegalArgumentException("Unable to find loader for: " + source, e); - } - - return loader; - } - - public static Properties loadProperties() { - final String conf = System.getenv(Constants.ENV_CAMEL_K_CONF); - final String confd = System.getenv(Constants.ENV_CAMEL_K_CONF_D); - - return loadProperties(conf, confd); - } - - public static Properties loadProperties(String conf, String confd) { - final Properties properties = new Properties(); - - // Main location - if (ObjectHelper.isNotEmpty(conf)) { - if (conf.startsWith(Constants.SCHEME_ENV)) { - try (Reader reader = URIResolver.resolveEnv(conf)) { - properties.load(reader); - } catch (IOException e) { - throw new RuntimeException(e); - } - } else { - try (Reader reader = Files.newBufferedReader(Paths.get(conf))) { - properties.load(reader); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - - // Additional locations - if (ObjectHelper.isNotEmpty(confd)) { - Path root = Paths.get(confd); - FileVisitor visitor = new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - Objects.requireNonNull(file); - Objects.requireNonNull(attrs); - - String path = file.toFile().getAbsolutePath(); - String ext = FilenameUtils.getExtension(path); - - if (Objects.equals("properties", ext)) { - try (Reader reader = Files.newBufferedReader(Paths.get(path))) { - properties.load(reader); - } - } - - return FileVisitResult.CONTINUE; - } - }; - - if (Files.exists(root)) { - try { - Files.walkFileTree(root, visitor); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - - return properties; - } -} diff --git a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/URIResolver.java b/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/URIResolver.java deleted file mode 100644 index 3b20602d51..0000000000 --- a/runtime/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/URIResolver.java +++ /dev/null @@ -1,66 +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.support; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; -import java.util.Base64; -import java.util.zip.GZIPInputStream; - -import org.apache.camel.CamelContext; -import org.apache.camel.k.Constants; -import org.apache.camel.k.Source; -import org.apache.camel.util.ResourceHelper; -import org.apache.camel.util.StringHelper; - - -public class URIResolver { - - public static InputStream resolve(CamelContext ctx, Source source) throws Exception { - if (source.getLocation() == null) { - throw new IllegalArgumentException("Cannot resolve null URI"); - } - - final InputStream is; - - if (source.getLocation().startsWith(Constants.SCHEME_ENV)) { - final String envvar = StringHelper.after(source.getLocation(), ":"); - final String content = System.getenv(envvar); - - // Using platform encoding on purpose - is = new ByteArrayInputStream(content.getBytes()); - } else { - is = ResourceHelper.resolveMandatoryResourceAsInputStream(ctx, source.getLocation()); - } - - return source.isCompressed() ? new GZIPInputStream(Base64.getDecoder().wrap(is)) : is; - } - - public static Reader resolveEnv(String uri) { - if (!uri.startsWith(Constants.SCHEME_ENV)) { - throw new IllegalArgumentException("The provided content is not env: " + uri); - } - - final String envvar = StringHelper.after(uri, ":"); - final String content = System.getenv(envvar); - - return new StringReader(content); - } - -} diff --git a/runtime/camel-k-runtime-core/src/main/resources/META-INF/LICENSE.txt b/runtime/camel-k-runtime-core/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b1270ff..0000000000 --- a/runtime/camel-k-runtime-core/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - diff --git a/runtime/camel-k-runtime-core/src/main/resources/META-INF/NOTICE.txt b/runtime/camel-k-runtime-core/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf2e6..0000000000 --- a/runtime/camel-k-runtime-core/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. diff --git a/runtime/camel-k-runtime-groovy/pom.xml b/runtime/camel-k-runtime-groovy/pom.xml deleted file mode 100644 index 389d7b114e..0000000000 --- a/runtime/camel-k-runtime-groovy/pom.xml +++ /dev/null @@ -1,117 +0,0 @@ - - - - - org.apache.camel.k - camel-k-runtime-parent - 0.3.0-SNAPSHOT - - 4.0.0 - - camel-k-runtime-groovy - - - - org.apache.camel.k - camel-k-runtime-jvm - ${project.version} - - - org.apache.camel - camel-core - provided - - - org.apache.camel - camel-groovy - - - org.codehaus.groovy - groovy - - - provided - - - org.codehaus.groovy - groovy - ${groovy.version} - provided - - - - - - - - - - - org.codehaus.groovy - groovy-test - ${groovy.version} - test - - - - org.spockframework - spock-core - ${spock.version} - test - - - org.codehaus.groovy - groovy-all - - - - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - - - org.codehaus.gmavenplus - gmavenplus-plugin - ${gmavenplus-plugin.version} - - - - addSources - addTestSources - compile - compileTests - - - - - true - - - - - - diff --git a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy deleted file mode 100644 index bf373274ba..0000000000 --- a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy +++ /dev/null @@ -1,57 +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.groovy - -import org.apache.camel.builder.RouteBuilder -import org.apache.camel.k.RoutesLoader -import org.apache.camel.k.Runtime - -import org.apache.camel.k.Source -import org.apache.camel.k.groovy.dsl.IntegrationConfiguration -import org.apache.camel.k.support.URIResolver -import org.codehaus.groovy.control.CompilerConfiguration - -class GroovyRoutesLoader implements RoutesLoader { - @Override - List getSupportedLanguages() { - return Collections.singletonList("groovy") - } - - @Override - RouteBuilder load(Runtime.Registry registry, Source source) throws Exception { - return new RouteBuilder() { - @Override - void configure() throws Exception { - def cc = new CompilerConfiguration() - cc.setScriptBaseClass(DelegatingScript.class.getName()) - - def cl = Thread.currentThread().getContextClassLoader() - def sh = new GroovyShell(cl, new Binding(), cc) - def is = URIResolver.resolve(context, source) - - is.withCloseable { - def reader = new InputStreamReader(is) - def script = (DelegatingScript) sh.parse(reader) - - // set the delegate target - script.setDelegate(new IntegrationConfiguration(registry, this)) - script.run() - } - } - } - } -} diff --git a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentConfiguration.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentConfiguration.groovy deleted file mode 100644 index 2454e72abf..0000000000 --- a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentConfiguration.groovy +++ /dev/null @@ -1,68 +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.groovy.dsl - -import org.apache.camel.util.IntrospectionSupport - -class ComponentConfiguration { - private final org.apache.camel.Component component - - ComponentConfiguration(org.apache.camel.Component component) { - this.component = component - } - - def methodMissing(String name, arguments) { - final Object value - final Object[] args = arguments as Object[] - - if (args == null) { - value = null - } else if (args.length == 1) { - value = args[0] - } else { - throw new IllegalArgumentException("Unable to set property \"" + name + "\" on component \"" + name + "\"") - } - - if (value instanceof Closure) { - def m = this.component.metaClass.getMetaMethod(name, Closure.class) - if (m) { - m.invoke(component, args) - - // done - return - } - } - - if (!IntrospectionSupport.setProperty(component, name, value, true)) { - throw new MissingMethodException(name, this.component.class, args as Object[]) - } - } - - def propertyMissing(String name, value) { - if (!IntrospectionSupport.setProperty(component, name, value, true)) { - throw new MissingMethodException(name, this.component.class, value) - } - } - - def propertyMissing(String name) { - def properties = [:] - - IntrospectionSupport.getProperties(component, properties, null, false) - - return properties[name] - } -} diff --git a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentsConfiguration.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentsConfiguration.groovy deleted file mode 100644 index 3c6cca658f..0000000000 --- a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentsConfiguration.groovy +++ /dev/null @@ -1,84 +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.groovy.dsl - -import org.apache.camel.CamelContext -import org.apache.camel.Component - -class ComponentsConfiguration { - private final CamelContext context - - ComponentsConfiguration(CamelContext context) { - this.context = context - } - - def component(String name, Closure callable) { - def component = context.getComponent(name, true, false) - - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.delegate = new ComponentConfiguration(component) - callable.call() - } - - def component(String name, Class type, Closure callable) { - def component = context.getComponent(name, true, false) - - // if the component is not found, let's create a new one. This is - // equivalent to create a new named component, useful to create - // multiple instances of the same component but with different setup - if (component == null) { - component = context.injector.newInstance(type) - - // let's the camel context be aware of the new component - context.addComponent(name, component) - } - - if (type.isAssignableFrom(component.class)) { - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.delegate = new ComponentConfiguration(component) - callable.call() - - return - } - - throw new IllegalArgumentException("Type mismatch, expected: " + type + ", got: " + component.class) - } - - def methodMissing(String name, arguments) { - final Object[] args = arguments as Object[] - - if (args != null) { - if (args.length == 1) { - def clos = args[0] - - if (clos instanceof Closure) { - return component(name, clos) - } - } - if (args.length == 2) { - def type = args[0] - def clos = args[1] - - if (type instanceof Class && Component.class.isAssignableFrom(type) && clos instanceof Closure) { - return component(name,type, clos) - } - } - } - - throw new MissingMethodException(name, this, args) - } -} diff --git a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy deleted file mode 100644 index ea63d0a137..0000000000 --- a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy +++ /dev/null @@ -1,42 +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.groovy.dsl - -import org.apache.camel.CamelContext -import org.apache.camel.k.Runtime - -class ContextConfiguration { - private final CamelContext context - private final Runtime.Registry registry - - ContextConfiguration(CamelContext context, Runtime.Registry registry) { - this.context = context - this.registry = registry - } - - def registry(Closure callable) { - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.delegate = new RegistryConfiguration(registry) - callable.call() - } - - def components(Closure callable) { - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.delegate = new ComponentsConfiguration(context) - callable.call() - } -} diff --git a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy deleted file mode 100644 index b71d7df7ab..0000000000 --- a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy +++ /dev/null @@ -1,78 +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.groovy.dsl - -import org.apache.camel.CamelContext -import org.apache.camel.Exchange -import org.apache.camel.Predicate -import org.apache.camel.Processor -import org.apache.camel.builder.RouteBuilder -import org.apache.camel.k.Runtime - -import org.apache.camel.k.jvm.dsl.Components -import org.apache.camel.model.RouteDefinition - -class IntegrationConfiguration { - private final Runtime.Registry registry - - final CamelContext context - final Components components - final RouteBuilder builder - - IntegrationConfiguration(Runtime.Registry registry, RouteBuilder builder) { - this.registry = registry - this.context = builder.getContext() - this.components = new Components(this.context) - this.builder = builder - } - - def context(Closure callable) { - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.delegate = new ContextConfiguration(context, registry) - callable.call() - } - - def rest(Closure callable) { - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.delegate = new RestConfiguration(builder) - callable.call() - } - - RouteDefinition from(String endpoint) { - return builder.from(endpoint) - } - - def processor(Closure callable) { - return new Processor() { - @Override - void process(Exchange exchange) throws Exception { - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.call(exchange) - } - } - } - - def predicate(Closure callable) { - return new Predicate() { - @Override - boolean matches(Exchange exchange) throws Exception { - callable.resolveStrategy = Closure.DELEGATE_FIRST - return callable.call(exchange) - } - } - } -} diff --git a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy deleted file mode 100644 index 14545ef668..0000000000 --- a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy +++ /dev/null @@ -1,35 +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.groovy.dsl - -import org.apache.camel.k.Runtime - -class RegistryConfiguration { - private final Runtime.Registry registry - - RegistryConfiguration(Runtime.Registry registry) { - this.registry = registry - } - - def bind(String name, value) { - registry.bind(name, value) - } - - def propertyMissing(String name, value) { - registry.bind(name, value) - } -} diff --git a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RestConfiguration.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RestConfiguration.groovy deleted file mode 100644 index d0b2fcf6a1..0000000000 --- a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RestConfiguration.groovy +++ /dev/null @@ -1,45 +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.groovy.dsl - -import org.apache.camel.builder.RouteBuilder - -class RestConfiguration { - private final RouteBuilder builder - - RestConfiguration(RouteBuilder builder) { - this.builder = builder - } - - def configuration(Closure callable) { - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.delegate = builder.restConfiguration() - callable.call() - } - - def configuration(String component, Closure callable) { - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.delegate = builder.restConfiguration(component) - callable.call() - } - - def path(String path, Closure callable) { - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.delegate = builder.rest(path) - callable.call() - } -} diff --git a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/extension/LogComponentExtension.groovy b/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/extension/LogComponentExtension.groovy deleted file mode 100644 index dac629ff99..0000000000 --- a/runtime/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/extension/LogComponentExtension.groovy +++ /dev/null @@ -1,33 +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.groovy.extension - -import org.apache.camel.Exchange -import org.apache.camel.component.log.LogComponent -import org.apache.camel.spi.ExchangeFormatter - -class LogComponentExtension { - static void formatter(LogComponent self, Closure callable) { - self.exchangeFormatter = new ExchangeFormatter() { - @Override - String format(Exchange exchange) { - callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.call(exchange) - } - } - } -} diff --git a/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/LICENSE.txt b/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b1270ff..0000000000 --- a/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - diff --git a/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/NOTICE.txt b/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf2e6..0000000000 --- a/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. diff --git a/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule b/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule deleted file mode 100644 index 217436e244..0000000000 --- a/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org.codehaus.groovy.runtime.ExtensionModule +++ /dev/null @@ -1,4 +0,0 @@ -moduleName=camel-k-runtime-groovy -moduleVersion=0.0.3-SNAPSHOT -extensionClasses=org.apache.camel.k.groovy.extension.LogComponentExtension -#staticExtensionClasses=support.StaticStringExtension \ No newline at end of file diff --git a/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org/apache/camel/k/loader/groovy b/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org/apache/camel/k/loader/groovy deleted file mode 100644 index ba7720a424..0000000000 --- a/runtime/camel-k-runtime-groovy/src/main/resources/META-INF/services/org/apache/camel/k/loader/groovy +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.k.groovy.GroovyRoutesLoader \ No newline at end of file diff --git a/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy b/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy deleted file mode 100644 index 72fe2db891..0000000000 --- a/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy +++ /dev/null @@ -1,48 +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.groovy - -import org.apache.camel.impl.DefaultCamelContext -import org.apache.camel.k.InMemoryRegistry -import org.apache.camel.k.Source -import org.apache.camel.k.support.RuntimeSupport -import org.apache.camel.model.ToDefinition -import spock.lang.Specification - -class LoaderTest extends Specification { - - def "load route from classpath"() { - given: - def source = Source.create("classpath:routes.groovy") - - when: - def loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source) - def builder = loader.load(new InMemoryRegistry(), source) - - then: - loader instanceof GroovyRoutesLoader - builder != null - - builder.configure() - - def routes = builder.routeCollection.routes - - routes.size() == 1 - routes[0].inputs[0].endpointUri == 'timer:tick' - routes[0].outputs[0] instanceof ToDefinition - } -} diff --git a/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy b/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy deleted file mode 100644 index 5fbde31b60..0000000000 --- a/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy +++ /dev/null @@ -1,98 +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.groovy.dsl - -import org.apache.camel.Processor -import org.apache.camel.component.log.LogComponent -import org.apache.camel.component.seda.SedaComponent -import org.apache.camel.k.Runtime -import org.apache.camel.k.jvm.ApplicationRuntime -import org.apache.camel.k.listener.RoutesConfigurer -import spock.lang.Specification - -import java.util.concurrent.atomic.AtomicInteger -import java.util.concurrent.atomic.AtomicReference - -class IntegrationTest extends Specification { - def "load integration with rest"() { - when: - def runtime = new ApplicationRuntime() - runtime.addListener(RoutesConfigurer.forRoutes('classpath:routes-with-rest.groovy')) - runtime.addListener(Runtime.Phase.Started, { runtime.stop() }) - runtime.run() - - then: - runtime.context.restConfiguration.host == 'my-host' - runtime.context.restConfiguration.port == 9192 - runtime.context.getRestConfiguration('undertow', false).host == 'my-undertow-host' - runtime.context.getRestConfiguration('undertow', false).port == 9193 - runtime.context.restDefinitions.size() == 1 - runtime.context.restDefinitions[0].path == '/my/path' - } - - def "load integration with bindings"() { - when: - def runtime = new ApplicationRuntime() - runtime.addListener(RoutesConfigurer.forRoutes('classpath:routes-with-bindings.groovy')) - runtime.addListener(Runtime.Phase.Started, { runtime.stop() }) - runtime.run() - - then: - runtime.context.registry.lookupByName('myEntry1') == 'myRegistryEntry1' - runtime.context.registry.lookupByName('myEntry2') == 'myRegistryEntry2' - runtime.context.registry.lookupByName('myEntry3') instanceof Processor - } - - def "load integration with component configuration"() { - given: - def sedaSize = new AtomicInteger() - def sedaConsumers = new AtomicInteger() - def mySedaSize = new AtomicInteger() - def mySedaConsumers = new AtomicInteger() - def format = new AtomicReference() - - when: - def runtime = new ApplicationRuntime() - runtime.addListener(RoutesConfigurer.forRoutes('classpath:routes-with-component-configuration.groovy')) - runtime.addListener(Runtime.Phase.Started, { - def seda = it.context.getComponent('seda', SedaComponent) - def mySeda = it.context.getComponent('mySeda', SedaComponent) - def log = it.context.getComponent('log', LogComponent) - - assert seda != null - assert mySeda != null - assert log != null - - sedaSize = seda.queueSize - sedaConsumers = seda.concurrentConsumers - mySedaSize = mySeda.queueSize - mySedaConsumers = mySeda.concurrentConsumers - format = log.exchangeFormatter - - runtime.stop() - }) - - runtime.run() - - then: - sedaSize == 1234 - sedaConsumers == 12 - mySedaSize == 4321 - mySedaConsumers == 21 - format != null - } -} diff --git a/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy b/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy deleted file mode 100644 index fee6475e9d..0000000000 --- a/runtime/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy +++ /dev/null @@ -1,43 +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.groovy.dsl.extension - -import org.apache.camel.component.log.LogComponent -import org.apache.camel.impl.DefaultCamelContext -import org.apache.camel.impl.DefaultExchange -import spock.lang.Specification - -class LogExtensionTest extends Specification { - - def "invoke extension method - formatter"() { - given: - def ctx = new DefaultCamelContext() - - when: - def log = new LogComponent() - log.formatter { - "body: $it.in.body" - } - - def ex = new DefaultExchange(ctx) - ex.in.body = 'hello' - def result = log.exchangeFormatter.format(ex) - - then: - result == 'body: hello' - } -} diff --git a/runtime/camel-k-runtime-groovy/src/test/resources/log4j2-test.xml b/runtime/camel-k-runtime-groovy/src/test/resources/log4j2-test.xml deleted file mode 100644 index 84d2957293..0000000000 --- a/runtime/camel-k-runtime-groovy/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/runtime/camel-k-runtime-groovy/src/test/resources/routes-with-bindings.groovy b/runtime/camel-k-runtime-groovy/src/test/resources/routes-with-bindings.groovy deleted file mode 100644 index 6595b23b80..0000000000 --- a/runtime/camel-k-runtime-groovy/src/test/resources/routes-with-bindings.groovy +++ /dev/null @@ -1,12 +0,0 @@ -context { - registry { - myEntry1 = 'myRegistryEntry1' - myEntry2 = 'myRegistryEntry2' - myEntry3 = processor { - it.in.headers['test'] = 'value' - } - } -} - -from('timer:tick') - .to('log:info') \ No newline at end of file diff --git a/runtime/camel-k-runtime-groovy/src/test/resources/routes-with-component-configuration.groovy b/runtime/camel-k-runtime-groovy/src/test/resources/routes-with-component-configuration.groovy deleted file mode 100644 index ee6eb245e1..0000000000 --- a/runtime/camel-k-runtime-groovy/src/test/resources/routes-with-component-configuration.groovy +++ /dev/null @@ -1,31 +0,0 @@ -import org.apache.camel.component.seda.SedaComponent - -context { - components { - seda { - // set value as method - queueSize 1234 - - // set value as property - concurrentConsumers = 12 - } - - mySeda(SedaComponent) { - // set value as method - queueSize 4321 - - // set value as property - concurrentConsumers = 21 - } - - log { - formatter { - 'body ==> ' + it.in.body - } - } - } -} - - -from('timer:tick') - .to('log:info') \ No newline at end of file diff --git a/runtime/camel-k-runtime-groovy/src/test/resources/routes-with-rest.groovy b/runtime/camel-k-runtime-groovy/src/test/resources/routes-with-rest.groovy deleted file mode 100644 index 6df9367323..0000000000 --- a/runtime/camel-k-runtime-groovy/src/test/resources/routes-with-rest.groovy +++ /dev/null @@ -1,19 +0,0 @@ - -rest { - configuration { - host 'my-host' - port '9192' - } - - configuration('undertow') { - host 'my-undertow-host' - port '9193' - } - - path('/my/path') { - - } -} - -from('timer:tick') - .to('log:info') \ No newline at end of file diff --git a/runtime/camel-k-runtime-groovy/src/test/resources/routes.groovy b/runtime/camel-k-runtime-groovy/src/test/resources/routes.groovy deleted file mode 100644 index 0f5600d06f..0000000000 --- a/runtime/camel-k-runtime-groovy/src/test/resources/routes.groovy +++ /dev/null @@ -1,3 +0,0 @@ - -from('timer:tick') - .to('log:info') \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/pom.xml b/runtime/camel-k-runtime-jvm/pom.xml deleted file mode 100644 index 4cbaedfe10..0000000000 --- a/runtime/camel-k-runtime-jvm/pom.xml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - org.apache.camel.k - camel-k-runtime-parent - 0.3.0-SNAPSHOT - - 4.0.0 - - camel-k-runtime-jvm - - - - - - - - - - - org.apache.camel - camel-core - provided - - - org.apache.camel.k - camel-k-runtime-core - ${project.version} - - - org.apache.logging.log4j - log4j-core - ${log4j2.version} - - - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j2.version} - runtime - - - org.jooq - joor-java-8 - ${joor.version} - - - commons-io - commons-io - ${commons-io.version} - - - org.apache.commons - commons-lang3 - ${commons-lang.version} - - - - - - - - - - org.apache.camel - camel-undertow - test - - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-params - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - value from env - env:CAMEL_K_RESOURCE_001 - - - - - - - diff --git a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/Application.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/Application.java deleted file mode 100644 index eefed2d105..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/Application.java +++ /dev/null @@ -1,58 +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.jvm; - -import org.apache.camel.k.listener.ContextConfigurer; -import org.apache.camel.k.listener.ContextLifecycleConfigurer; -import org.apache.camel.k.listener.RoutesConfigurer; -import org.apache.camel.k.listener.RoutesDumper; -import org.apache.camel.k.support.PlatformStreamHandler; -import org.apache.camel.k.support.RuntimeSupport; - -public class Application { - static { - // - // Configure the logging subsystem log4j2 using a subset of spring boot - // conventions: - // - // logging.level.${nane} = OFF|FATAL|ERROR|WARN|INFO|DEBUG|TRACE|ALL - // - // We now support setting the logging level only - // - ApplicationSupport.configureLogging(); - - // - // Install a custom protocol handler to support discovering resources - // from the platform i.e. in knative, resources are provided through - // env var as it is not possible to mount config maps / secrets. - // - // TODO: we should remove as soon as we get a knative version that - // includes https://github.com/knative/serving/pull/3061 - // - PlatformStreamHandler.configure(); - } - - public static void main(String[] args) throws Exception { - ApplicationRuntime runtime = new ApplicationRuntime(); - runtime.setProperties(RuntimeSupport.loadProperties()); - runtime.addListener(new ContextConfigurer()); - runtime.addListener(new ContextLifecycleConfigurer()); - runtime.addListener(new RoutesConfigurer()); - runtime.addListener(new RoutesDumper()); - runtime.run(); - } -} diff --git a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationRuntime.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationRuntime.java deleted file mode 100644 index 97cb805cbf..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationRuntime.java +++ /dev/null @@ -1,154 +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.jvm; - -import java.util.LinkedHashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.k.InMemoryRegistry; -import org.apache.camel.k.Runtime; -import org.apache.camel.main.MainSupport; -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.function.ThrowingConsumer; - -public final class ApplicationRuntime implements Runtime { - private final Main main; - private final ConcurrentMap contextMap; - private final Runtime.Registry registry; - private final Set listeners; - - public ApplicationRuntime() { - this.contextMap = new ConcurrentHashMap<>(); - this.registry = new InMemoryRegistry(); - this.listeners = new LinkedHashSet<>(); - - this.main = new Main(); - this.main.addMainListener(new MainListenerAdapter()); - } - - @Override - public CamelContext getContext() { - return contextMap.computeIfAbsent("camel-k", key -> { - DefaultCamelContext context = new DefaultCamelContext(); - context.setName(key); - context.setRegistry(this.registry); - - return context; - }); - } - - @Override - public Runtime.Registry getRegistry() { - return registry; - } - - public void run() throws Exception { - this.main.run(); - } - - public void stop()throws Exception { - this.main.stop(); - } - - public void addListener(Runtime.Listener listener) { - this.listeners.add(listener); - } - - public void addListener(Phase phase, ThrowingConsumer consumer) { - addListener((p, runtime) -> { - if (p == phase) { - try { - consumer.accept(runtime); - } catch (Exception e) { - throw ObjectHelper.wrapRuntimeCamelException(e); - } - } - }); - } - - private class Main extends org.apache.camel.main.MainSupport { - @Override - protected ProducerTemplate findOrCreateCamelTemplate() { - return getContext().createProducerTemplate(); - } - - @Override - protected Map getCamelContextMap() { - getContext(); - - return contextMap; - } - - @Override - protected void doStart() throws Exception { - super.doStart(); - postProcessContext(); - - try { - getContext().start(); - } finally { - if (getContext().isVetoStarted()) { - completed(); - } - } - } - - @Override - protected void doStop() throws Exception { - super.doStop(); - - if (!getCamelContexts().isEmpty()) { - getContext().stop(); - } - } - } - - private class MainListenerAdapter implements org.apache.camel.main.MainListener { - - @Override - public void beforeStart(MainSupport main) { - listeners.forEach(l -> l.accept(Phase.Starting, ApplicationRuntime.this)); - } - - @Override - public void configure(CamelContext context) { - listeners.forEach(l -> l.accept(Phase.ConfigureContext, ApplicationRuntime.this)); - listeners.forEach(l -> l.accept(Phase.ConfigureRoutes, ApplicationRuntime.this)); - } - - @Override - public void afterStart(MainSupport main) { - listeners.forEach(l -> l.accept(Phase.Started, ApplicationRuntime.this)); - } - - @Override - public void beforeStop(MainSupport main) { - - } - - @Override - public void afterStop(MainSupport main) { - - } - } -} diff --git a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationSupport.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationSupport.java deleted file mode 100644 index 3524dd1bb2..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationSupport.java +++ /dev/null @@ -1,53 +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.jvm; - -import java.util.Properties; - -import org.apache.camel.k.Constants; -import org.apache.camel.k.support.RuntimeSupport; -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.core.LoggerContext; -import org.apache.logging.log4j.core.config.LoggerConfig; - - -public final class ApplicationSupport { - private ApplicationSupport() { - } - - public static void configureLogging() { - final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); - final Properties properties = RuntimeSupport.loadProperties(); - - properties.entrySet().stream() - .filter(entry -> entry.getKey() instanceof String) - .filter(entry -> entry.getValue() instanceof String) - .filter(entry -> ((String)entry.getKey()).startsWith(Constants.LOGGING_LEVEL_PREFIX)) - .forEach(entry -> { - String key = ((String)entry.getKey()); - String val = ((String)entry.getValue()); - - String logger = key.substring(Constants.LOGGING_LEVEL_PREFIX.length()); - Level level = Level.getLevel(val); - LoggerConfig config = new LoggerConfig(logger, level, true); - - ctx.getConfiguration().addLogger(logger, config); - } - ); - } -} diff --git a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/dsl/Components.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/dsl/Components.java deleted file mode 100644 index bac13904c6..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/dsl/Components.java +++ /dev/null @@ -1,47 +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.jvm.dsl; - -import org.apache.camel.CamelContext; -import org.apache.camel.Component; - -public class Components { - private CamelContext context; - - public Components(CamelContext context) { - this.context = context; - } - - public Component get(String scheme) { - return context.getComponent(scheme, true); - } - - public Component put(String scheme, Component instance) { - context.addComponent(scheme, instance); - - return instance; - } - - public Component make(String scheme, String type) { - final Class clazz = context.getClassResolver().resolveClass(type); - final Component instance = (Component)context.getInjector().newInstance(clazz); - - context.addComponent(scheme, instance); - - return instance; - } -} diff --git a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaClassLoader.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaClassLoader.java deleted file mode 100644 index eb400ba181..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaClassLoader.java +++ /dev/null @@ -1,47 +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.jvm.loader; - -import java.util.Collections; -import java.util.List; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.k.RoutesLoader; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.Source; -import org.apache.commons.lang3.StringUtils; - -public class JavaClassLoader implements RoutesLoader { - @Override - public List getSupportedLanguages() { - return Collections.singletonList("class"); - } - - @Override - public RouteBuilder load(Runtime.Registry registry, Source source) throws Exception { - String name = source.getName(); - name = StringUtils.removeEnd(name, ".class"); - - Class type = Class.forName(name); - - if (!RouteBuilder.class.isAssignableFrom(type)) { - throw new IllegalStateException("The class provided (" + source.getLocation() + ") is not a org.apache.camel.builder.RouteBuilder"); - } - - return (RouteBuilder)type.newInstance(); - } -} diff --git a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaScriptLoader.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaScriptLoader.java deleted file mode 100644 index 5362b46726..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaScriptLoader.java +++ /dev/null @@ -1,73 +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.jvm.loader; - -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.Collections; -import java.util.List; -import java.util.function.Function; -import java.util.function.Supplier; -import javax.script.Bindings; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.SimpleBindings; - -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.k.RoutesLoader; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.Source; -import org.apache.camel.k.jvm.dsl.Components; -import org.apache.camel.k.support.URIResolver; -import org.apache.camel.model.RouteDefinition; -import org.apache.camel.model.rest.RestConfigurationDefinition; -import org.apache.camel.model.rest.RestDefinition; - -public class JavaScriptLoader implements RoutesLoader { - @Override - public List getSupportedLanguages() { - return Collections.singletonList("js"); - } - - @Override - public RouteBuilder load(Runtime.Registry registry, Source source) throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - final CamelContext context = getContext(); - final ScriptEngineManager manager = new ScriptEngineManager(); - final ScriptEngine engine = manager.getEngineByName("nashorn"); - final Bindings bindings = new SimpleBindings(); - - // Exposed to the underlying script, but maybe better to have - // a nice dsl - bindings.put("builder", this); - bindings.put("context", context); - bindings.put("components", new Components(context)); - bindings.put("registry", registry); - bindings.put("from", (Function) uri -> from(uri)); - bindings.put("rest", (Supplier) () -> rest()); - bindings.put("restConfiguration", (Supplier) () -> restConfiguration()); - - try (InputStream is = URIResolver.resolve(context, source)) { - engine.eval(new InputStreamReader(is), bindings); - } - } - }; - } -} diff --git a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaSourceLoader.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaSourceLoader.java deleted file mode 100644 index 6d67166803..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaSourceLoader.java +++ /dev/null @@ -1,105 +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.jvm.loader; - -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.apache.camel.CamelContext; -import org.apache.camel.RoutesBuilder; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.k.RoutesLoader; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.Source; -import org.apache.camel.k.support.URIResolver; -import org.apache.camel.model.rest.RestConfigurationDefinition; -import org.apache.camel.spi.RestConfiguration; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.StringUtils; -import org.joor.Reflect; - -public class JavaSourceLoader implements RoutesLoader { - @Override - public List getSupportedLanguages() { - return Collections.singletonList("java"); - } - - @Override - public RouteBuilder load(Runtime.Registry registry, Source source) throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - final CamelContext context = getContext(); - - try (InputStream is = URIResolver.resolve(context, source)) { - // compile the source in memory - String content = IOUtils.toString(is, StandardCharsets.UTF_8); - String name = determineQualifiedName(source, content); - Reflect compiled = Reflect.compile(name, content); - - // create the builder - RoutesBuilder builder = compiled.create().get(); - - // Wrap routes builder - includeRoutes(builder); - - if (builder instanceof RouteBuilder) { - Map configurations = ((RouteBuilder) builder).getRestConfigurations(); - - // - // TODO: RouteBuilder.getRestConfigurations() should not - // return null - // - if (configurations != null) { - for (RestConfigurationDefinition definition : configurations.values()) { - RestConfiguration conf = definition.asRestConfiguration(context); - - // - // this is an hack to copy routes configuration - // to the camel context - // - // TODO: fix RouteBuilder.includeRoutes to include - // rest configurations - // - context.addRestConfiguration(conf); - } - } - } - } - } - }; - } - - private static String determineQualifiedName(Source source, String content) throws Exception { - String name = source.getName(); - name = StringUtils.removeEnd(name, ".java"); - - Pattern pattern = Pattern.compile("^\\s*package\\s+([a-zA_Z_][\\.\\w]*)\\s*;.*"); - Matcher matcher = pattern.matcher(content); - - if (matcher.find()) { - name = matcher.group(1) + "." + name; - } - - return name; - } -} diff --git a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/XmlLoader.java b/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/XmlLoader.java deleted file mode 100644 index 6880e3e764..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/XmlLoader.java +++ /dev/null @@ -1,75 +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.jvm.loader; - -import java.io.InputStream; -import java.util.Collections; -import java.util.List; -import javax.xml.bind.UnmarshalException; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.k.RoutesLoader; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.Source; -import org.apache.camel.k.support.URIResolver; -import org.apache.camel.model.RoutesDefinition; -import org.apache.camel.model.rest.RestsDefinition; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class XmlLoader implements RoutesLoader { - private static final Logger LOGGER = LoggerFactory.getLogger(XmlLoader.class); - - @Override - public List getSupportedLanguages() { - return Collections.singletonList("xml"); - } - - @Override - public RouteBuilder load(Runtime.Registry registry, Source source) throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - try (InputStream is = URIResolver.resolve(getContext(), source)) { - try { - RoutesDefinition definition = getContext().loadRoutesDefinition(is); - LOGGER.debug("Loaded {} routes from {}", definition.getRoutes().size(), source); - - setRouteCollection(definition); - } catch (IllegalArgumentException e) { - // ignore - } catch (UnmarshalException e) { - LOGGER.debug("Unable to load RoutesDefinition: {}", e.getMessage()); - } - } - - try (InputStream is = URIResolver.resolve(getContext(), source)) { - try { - RestsDefinition definition = getContext().loadRestsDefinition(is); - LOGGER.debug("Loaded {} rests from {}", definition.getRests().size(), source); - - setRestCollection(definition); - } catch(IllegalArgumentException e) { - // ignore - } catch (UnmarshalException e) { - LOGGER.debug("Unable to load RestsDefinition: {}", e.getMessage()); - } - } - } - }; - } -} diff --git a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/LICENSE.txt b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b1270ff..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - diff --git a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/NOTICE.txt b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf2e6..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. diff --git a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/class b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/class deleted file mode 100644 index 2d85f95eda..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/class +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.k.jvm.loader.JavaClassLoader \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/java b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/java deleted file mode 100644 index 3bf8297220..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/java +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.k.jvm.loader.JavaSourceLoader \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/js b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/js deleted file mode 100644 index 45227e82e7..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/js +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.k.jvm.loader.JavaScriptLoader \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/xml b/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/xml deleted file mode 100644 index e30ce1eba7..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/resources/META-INF/services/org/apache/camel/k/loader/xml +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.k.jvm.loader.XmlLoader \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/main/resources/log4j2.properties b/runtime/camel-k-runtime-jvm/src/main/resources/log4j2.properties deleted file mode 100644 index 9f0f4b18f1..0000000000 --- a/runtime/camel-k-runtime-jvm/src/main/resources/log4j2.properties +++ /dev/null @@ -1,7 +0,0 @@ -appender.console.type = Console -appender.console.name = console -appender.console.layout.type = PatternLayout -appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} %highlight{%-5level} [%t] %c{1} - %msg%n - -rootLogger.level = INFO -rootLogger.appenderRef.stdout.ref = console \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/MyRoutes.java b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/MyRoutes.java deleted file mode 100644 index 2fecf51006..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/MyRoutes.java +++ /dev/null @@ -1,27 +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.jvm; - -import org.apache.camel.builder.RouteBuilder; - -public class MyRoutes extends RouteBuilder { - @Override - public void configure() throws Exception { - from("timer:tick") - .to("log:info"); - } -} diff --git a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java deleted file mode 100644 index cd82ef740c..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java +++ /dev/null @@ -1,169 +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.jvm; - -import java.util.Properties; -import java.util.concurrent.ThreadLocalRandom; - -import org.apache.camel.CamelContext; -import org.apache.camel.component.seda.SedaComponent; -import org.apache.camel.k.Constants; -import org.apache.camel.k.ContextCustomizer; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.listener.ContextConfigurer; -import org.apache.camel.k.listener.ContextLifecycleConfigurer; -import org.apache.camel.k.support.RuntimeSupport; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class PropertiesTest { - - @Test - public void testLoadProperties() throws Exception { - Properties properties = RuntimeSupport.loadProperties("src/test/resources/conf.properties", "src/test/resources/conf.d"); - - ApplicationRuntime runtime = new ApplicationRuntime(); - runtime.setProperties(properties); - runtime.addListener(new ContextConfigurer()); - runtime.addListener(new ContextLifecycleConfigurer()); - runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); - assertThat(context.resolvePropertyPlaceholders("{{root.key}}")).isEqualTo("root.value"); - assertThat(context.resolvePropertyPlaceholders("{{001.key}}")).isEqualTo("001.value"); - assertThat(context.resolvePropertyPlaceholders("{{002.key}}")).isEqualTo("002.value"); - assertThat(context.resolvePropertyPlaceholders("{{a.key}}")).isEqualTo("a.002"); - runtime.stop(); - }); - - runtime.run(); - } - - @Test - public void testSystemProperties() throws Exception { - System.setProperty("my.property", "my.value"); - - try { - ApplicationRuntime runtime = new ApplicationRuntime(); - runtime.setProperties(System.getProperties()); - runtime.addListener(new ContextConfigurer()); - runtime.addListener(new ContextLifecycleConfigurer()); - runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); - String value = context.resolvePropertyPlaceholders("{{my.property}}"); - - assertThat(value).isEqualTo("my.value"); - runtime.stop(); - }); - - runtime.run(); - } finally { - System.getProperties().remove("my.property"); - } - } - - @Test - public void testComponentConfiguration() throws Exception { - int queueSize1 = ThreadLocalRandom.current().nextInt(10, 100); - int queueSize2 = ThreadLocalRandom.current().nextInt(10, 100); - - System.setProperty("camel.component.seda.queueSize", Integer.toString(queueSize1)); - System.setProperty("camel.component.my-seda.queueSize", Integer.toString(queueSize2)); - - try { - ApplicationRuntime runtime = new ApplicationRuntime(); - runtime.setProperties(System.getProperties()); - runtime.getRegistry().bind("my-seda", new SedaComponent()); - runtime.addListener(new ContextConfigurer()); - runtime.addListener(new ContextLifecycleConfigurer()); - runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); - assertThat(context.getComponent("seda", true)).hasFieldOrPropertyWithValue("queueSize", queueSize1); - assertThat(context.getComponent("my-seda", true)).hasFieldOrPropertyWithValue("queueSize", queueSize2); - runtime.stop(); - }); - - runtime.run(); - } finally { - System.getProperties().remove("camel.component.seda.queueSize"); - System.getProperties().remove("camel.component.my-seda.queueSize"); - } - } - - @Test - public void testContextConfiguration() throws Exception { - System.setProperty("camel.context.messageHistory", "false"); - System.setProperty("camel.context.loadTypeConverters", "false"); - - try { - ApplicationRuntime runtime = new ApplicationRuntime(); - runtime.setProperties(System.getProperties()); - runtime.addListener(new ContextConfigurer()); - runtime.addListener(new ContextLifecycleConfigurer()); - runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); - assertThat(context.isMessageHistory()).isFalse(); - assertThat(context.isLoadTypeConverters()).isFalse(); - runtime.stop(); - }); - - runtime.run(); - } finally { - System.getProperties().remove("camel.context.messageHistory"); - System.getProperties().remove("camel.context.loadTypeConverters"); - } - } - - @Test - public void testContextCustomizerFromProperty() throws Exception { - System.setProperty(Constants.PROPERTY_CAMEL_K_CUSTOMIZER, "test"); - System.setProperty("customizer.test.messageHistory", "false"); - - ApplicationRuntime runtime = new ApplicationRuntime(); - runtime.setProperties(System.getProperties()); - runtime.addListener(new ContextConfigurer()); - runtime.addListener(new ContextLifecycleConfigurer()); - runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); - assertThat(context.isMessageHistory()).isFalse(); - assertThat(context.isLoadTypeConverters()).isFalse(); - runtime.stop(); - }); - - runtime.run(); - } - - @Test - public void testContextCustomizerFromRegistry() throws Exception { - ApplicationRuntime runtime = new ApplicationRuntime(); - runtime.setProperties(System.getProperties()); - runtime.addListener(new ContextConfigurer()); - runtime.addListener(new ContextLifecycleConfigurer()); - runtime.getRegistry().bind("c1", (ContextCustomizer) (camelContext, registry) -> { - camelContext.setMessageHistory(false); - camelContext.setLoadTypeConverters(false); - }); - runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); - assertThat(context.isMessageHistory()).isFalse(); - assertThat(context.isLoadTypeConverters()).isFalse(); - runtime.stop(); - }); - - runtime.run(); - } -} diff --git a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersCommonTest.java b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersCommonTest.java deleted file mode 100644 index f4c4f4af1f..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersCommonTest.java +++ /dev/null @@ -1,71 +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.jvm; - -import java.util.List; -import java.util.stream.Stream; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.k.InMemoryRegistry; -import org.apache.camel.k.RoutesLoader; -import org.apache.camel.k.Source; -import org.apache.camel.k.jvm.loader.JavaClassLoader; -import org.apache.camel.k.jvm.loader.JavaScriptLoader; -import org.apache.camel.k.jvm.loader.JavaSourceLoader; -import org.apache.camel.k.jvm.loader.XmlLoader; -import org.apache.camel.k.support.RuntimeSupport; -import org.apache.camel.model.RouteDefinition; -import org.apache.camel.model.ToDefinition; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -import static org.assertj.core.api.Assertions.assertThat; - -public class RoutesLoadersCommonTest { - @ParameterizedTest - @MethodSource("parameters") - void testLoaders(String location, Class type) throws Exception{ - Source source = Source.create(location); - RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source); - RouteBuilder builder = loader.load(new InMemoryRegistry(), source); - - assertThat(loader).isInstanceOf(type); - assertThat(builder).isNotNull(); - - builder.configure(); - - List routes = builder.getRouteCollection().getRoutes(); - assertThat(routes).hasSize(1); - assertThat(routes.get(0).getInputs().get(0).getEndpointUri()).isEqualTo("timer:tick"); - assertThat(routes.get(0).getOutputs().get(0)).isInstanceOf(ToDefinition.class); - } - - static Stream parameters() { - return Stream.of( - Arguments.arguments("classpath:" + MyRoutes.class.getName() + ".class", JavaClassLoader.class), - Arguments.arguments("classpath:MyRoutes.java", JavaSourceLoader.class), - Arguments.arguments("classpath:MyRoutesWithNameOverride.java?name=MyRoutes.java", JavaSourceLoader.class), - Arguments.arguments("classpath:MyRoutesWithPackage.java", JavaSourceLoader.class), - Arguments.arguments("classpath:routes.js", JavaScriptLoader.class), - Arguments.arguments("classpath:routes-compressed.js.gz.b64?language=js&compression=true", JavaScriptLoader.class), - Arguments.arguments("classpath:routes.mytype?language=js", JavaScriptLoader.class), - Arguments.arguments("classpath:routes.xml", XmlLoader.class) - ); - } -} diff --git a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java deleted file mode 100644 index e5a0b2212c..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java +++ /dev/null @@ -1,112 +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.jvm; - -import java.util.List; - -import org.apache.camel.CamelContext; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.k.InMemoryRegistry; -import org.apache.camel.k.RoutesLoader; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.Source; -import org.apache.camel.k.jvm.loader.JavaClassLoader; -import org.apache.camel.k.jvm.loader.JavaSourceLoader; -import org.apache.camel.k.support.RuntimeSupport; -import org.apache.camel.model.ProcessDefinition; -import org.apache.camel.model.RouteDefinition; -import org.apache.camel.model.SetBodyDefinition; -import org.apache.camel.model.ToDefinition; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; - -public class RoutesLoadersTest { - - @Test - public void testLoaderFromRegistry() throws Exception { - RoutesLoader myLoader = new JavaClassLoader(); - Runtime.Registry registry = new InMemoryRegistry(); - registry.bind("my-loader", myLoader); - - Source source = Source.create("classpath:" + MyRoutes.class.getName() + ".class"); - RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(registry), source); - - assertThat(loader).isInstanceOf(JavaClassLoader.class); - assertThat(loader).isSameAs(myLoader); - } - - @Test - public void testLoadJavaWithNestedClass() throws Exception { - Source source = Source.create("classpath:MyRoutesWithNestedClass.java"); - RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source); - RouteBuilder builder = loader.load(new InMemoryRegistry(), source); - - assertThat(loader).isInstanceOf(JavaSourceLoader.class); - assertThat(builder).isNotNull(); - - builder.configure(); - - List routes = builder.getRouteCollection().getRoutes(); - assertThat(routes).hasSize(1); - assertThat(routes.get(0).getInputs().get(0).getEndpointUri()).isEqualTo("timer:tick"); - assertThat(routes.get(0).getOutputs().get(0)).isInstanceOf(SetBodyDefinition.class); - assertThat(routes.get(0).getOutputs().get(1)).isInstanceOf(ProcessDefinition.class); - assertThat(routes.get(0).getOutputs().get(2)).isInstanceOf(ToDefinition.class); - } - - @Test - public void testLoadJavaWithRestConfiguration() throws Exception { - CamelContext context = new DefaultCamelContext(); - Source source = Source.create("classpath:MyRoutesWithRestConfiguration.java"); - RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source); - RouteBuilder builder = loader.load(new InMemoryRegistry(), source); - - assertThat(loader).isInstanceOf(JavaSourceLoader.class); - assertThat(builder).isNotNull(); - - builder.setContext(context); - builder.configure(); - - assertThat(context.getRestConfigurations()).hasSize(1); - assertThat(context.getRestConfigurations().iterator().next()).hasFieldOrPropertyWithValue("component", "restlet"); - } - - @Test - public void testResourceWithoutScheme() { - assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy( - () -> Source.create("routes.js") - ); - } - - @Test - public void testResourceWithIllegalScheme() { - assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy( - () -> Source.create("http:routes.js") - ); - } - - @Test - public void testUnsupportedLanguage() { - assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy( - () -> Source.create(" test") - ); - } - -} diff --git a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTest.java b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTest.java deleted file mode 100644 index b86bbb9166..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTest.java +++ /dev/null @@ -1,106 +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.jvm; - -import java.io.InputStream; -import java.nio.charset.Charset; -import java.util.List; - -import org.apache.camel.CamelContext; -import org.apache.camel.Route; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.listener.ContextConfigurer; -import org.apache.camel.k.listener.ContextLifecycleConfigurer; -import org.apache.camel.k.listener.RoutesConfigurer; -import org.apache.camel.k.support.PlatformStreamHandler; -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.ResourceHelper; -import org.apache.commons.io.IOUtils; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Java6Assertions.assertThat; - -public class RuntimeTest { - - @Test - void testLoadMultipleRoutes() throws Exception { - ApplicationRuntime runtime = new ApplicationRuntime(); - - try { - runtime.addListener(new ContextConfigurer()); - runtime.addListener(new ContextLifecycleConfigurer()); - runtime.addListener(RoutesConfigurer.forRoutes("classpath:r1.js", "classpath:r2.mytype?language=js")); - runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); - List routes = context.getRoutes(); - - assertThat(routes).hasSize(2); - assertThat(routes).anyMatch(p -> ObjectHelper.equal("r1", p.getId())); - assertThat(routes).anyMatch(p -> ObjectHelper.equal("r2", p.getId())); - - runtime.stop(); - }); - - runtime.run(); - } finally { - runtime.stop(); - } - } - - - @Test - void testLoadRouteAndRest() throws Exception { - ApplicationRuntime runtime = new ApplicationRuntime(); - try { - runtime.addListener(new ContextConfigurer()); - runtime.addListener(new ContextLifecycleConfigurer()); - runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes.xml", "classpath:rests.xml")); - runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); - - assertThat(context.getRouteDefinitions()).isNotEmpty(); - assertThat(context.getRestDefinitions()).isNotEmpty(); - - runtime.stop(); - }); - - runtime.run(); - } finally { - runtime.stop(); - } - } - - - @Test - void testLoadResource() throws Exception { - PlatformStreamHandler.configure(); - - CamelContext context = new ApplicationRuntime().getContext(); - - try (InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, "platform:my-resource.txt")) { - String content = IOUtils.toString(is, Charset.defaultCharset()); - - assertThat(content).isEqualTo("value from file resource"); - } - - try (InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, "platform:my-other-resource.txt")) { - String content = IOUtils.toString(is, Charset.defaultCharset()); - - assertThat(content).isEqualTo("value from env"); - } - } -} diff --git a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/TestCustomizer.java b/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/TestCustomizer.java deleted file mode 100644 index 7cd61abdfa..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/TestCustomizer.java +++ /dev/null @@ -1,39 +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.jvm; - -import org.apache.camel.CamelContext; -import org.apache.camel.k.ContextCustomizer; -import org.apache.camel.k.Runtime; - -public class TestCustomizer implements ContextCustomizer { - private boolean messageHistory = true; - - public boolean isMessageHistory() { - return messageHistory; - } - - public void setMessageHistory(boolean messageHistory) { - this.messageHistory = messageHistory; - } - - @Override - public void apply(CamelContext camelContext, Runtime.Registry registry) { - camelContext.setMessageHistory(messageHistory); - camelContext.setLoadTypeConverters(false); - } -} diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/META-INF/services/org/apache/camel/k/customizer/test b/runtime/camel-k-runtime-jvm/src/test/resources/META-INF/services/org/apache/camel/k/customizer/test deleted file mode 100644 index dc0dd227c3..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/META-INF/services/org/apache/camel/k/customizer/test +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.k.jvm.TestCustomizer \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutes.java b/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutes.java deleted file mode 100644 index 513ec31450..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutes.java +++ /dev/null @@ -1,25 +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. - */ -import org.apache.camel.builder.RouteBuilder; - -public class MyRoutes extends RouteBuilder { - @Override - public void configure() throws Exception { - from("timer:tick") - .to("log:info"); - } -} \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithNameOverride.java b/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithNameOverride.java deleted file mode 100644 index 513ec31450..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithNameOverride.java +++ /dev/null @@ -1,25 +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. - */ -import org.apache.camel.builder.RouteBuilder; - -public class MyRoutes extends RouteBuilder { - @Override - public void configure() throws Exception { - from("timer:tick") - .to("log:info"); - } -} \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithNestedClass.java b/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithNestedClass.java deleted file mode 100644 index da2e542b01..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithNestedClass.java +++ /dev/null @@ -1,39 +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. - */ -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.builder.RouteBuilder; - -public class MyRoutesWithNestedClass extends RouteBuilder { - @Override - public void configure() throws Exception { - Processor toUpper = new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - String body = exchange.getIn().getBody(String.class); - body = body.toUpperCase(); - - exchange.getOut().setBody(body); - } - }; - - from("timer:tick") - .setBody().constant("test") - .process(toUpper) - .to("log:info"); - } -} \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithPackage.java b/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithPackage.java deleted file mode 100644 index 714c2dea75..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithPackage.java +++ /dev/null @@ -1,11 +0,0 @@ -package my.roytes; - -import org.apache.camel.builder.RouteBuilder; - -public class MyRoutesWithPackage extends RouteBuilder { - @Override - public void configure() throws Exception { - from("timer:tick") - .to("log:info"); - } -} \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithRestConfiguration.java b/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithRestConfiguration.java deleted file mode 100644 index 8c7e46fecb..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/MyRoutesWithRestConfiguration.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. - */ -import org.apache.camel.builder.RouteBuilder; - -public class MyRoutesWithRestConfiguration extends RouteBuilder { - @Override - public void configure() throws Exception { - restConfiguration() - .component("restlet") - .host("localhost") - .port("8080"); - - from("timer:tick") - .to("log:info"); - } -} \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/conf.d/001/conf.properties b/runtime/camel-k-runtime-jvm/src/test/resources/conf.d/001/conf.properties deleted file mode 100644 index f0832c7e4c..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/conf.d/001/conf.properties +++ /dev/null @@ -1 +0,0 @@ -001.key = 001.value \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/conf.d/002/conf.properties b/runtime/camel-k-runtime-jvm/src/test/resources/conf.d/002/conf.properties deleted file mode 100644 index dfa6ce18e2..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/conf.d/002/conf.properties +++ /dev/null @@ -1,2 +0,0 @@ -002.key = 002.value -a.key = a.002 \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/conf.properties b/runtime/camel-k-runtime-jvm/src/test/resources/conf.properties deleted file mode 100644 index 4486a9d34d..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/conf.properties +++ /dev/null @@ -1,2 +0,0 @@ -root.key = root.value -a.key = a.root \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/log4j2-test.xml b/runtime/camel-k-runtime-jvm/src/test/resources/log4j2-test.xml deleted file mode 100644 index 9af8521cc7..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/my-resource.txt b/runtime/camel-k-runtime-jvm/src/test/resources/my-resource.txt deleted file mode 100644 index 817b31fc46..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/my-resource.txt +++ /dev/null @@ -1 +0,0 @@ -value from file resource \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/r1.js b/runtime/camel-k-runtime-jvm/src/test/resources/r1.js deleted file mode 100644 index f6ca4254d2..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/r1.js +++ /dev/null @@ -1,4 +0,0 @@ - -from('timer:tick1') - .id('r1') - .to('log:info1') \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/r2.mytype b/runtime/camel-k-runtime-jvm/src/test/resources/r2.mytype deleted file mode 100644 index a0b33cc8e5..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/r2.mytype +++ /dev/null @@ -1,4 +0,0 @@ - -from('timer:tick2') - .id('r2') - .to('log:info2') \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/rests.xml b/runtime/camel-k-runtime-jvm/src/test/resources/rests.xml deleted file mode 100644 index 3fac242d80..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/rests.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/routes-compressed.js.gz.b64 b/runtime/camel-k-runtime-jvm/src/test/resources/routes-compressed.js.gz.b64 deleted file mode 100644 index 3937f29173..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/routes-compressed.js.gz.b64 +++ /dev/null @@ -1 +0,0 @@ -H4sIAAAAAAAA/+JKK8rP1VAvycxNLbIqyUzOVtfkUlBQUNAryddQz8lPt8rMS8tX1+QCAAAA//8BAAD//3wZ4pUoAAAA \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/routes.js b/runtime/camel-k-runtime-jvm/src/test/resources/routes.js deleted file mode 100644 index a6cca45eff..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/routes.js +++ /dev/null @@ -1,2 +0,0 @@ -from('timer:tick') - .to('log:info') \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/routes.mytype b/runtime/camel-k-runtime-jvm/src/test/resources/routes.mytype deleted file mode 100644 index 0f5600d06f..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/routes.mytype +++ /dev/null @@ -1,3 +0,0 @@ - -from('timer:tick') - .to('log:info') \ No newline at end of file diff --git a/runtime/camel-k-runtime-jvm/src/test/resources/routes.xml b/runtime/camel-k-runtime-jvm/src/test/resources/routes.xml deleted file mode 100644 index b6672f187a..0000000000 --- a/runtime/camel-k-runtime-jvm/src/test/resources/routes.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/pom.xml b/runtime/camel-k-runtime-kotlin/pom.xml deleted file mode 100644 index 6d4bfc8f85..0000000000 --- a/runtime/camel-k-runtime-kotlin/pom.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - - org.apache.camel.k - camel-k-runtime-parent - 0.3.0-SNAPSHOT - - 4.0.0 - - camel-k-runtime-kotlin - - - - org.apache.camel - camel-core - provided - - - org.apache.camel.k - camel-k-runtime-jvm - ${project.version} - - - org.jetbrains.kotlin - kotlin-stdlib-jdk8 - ${kotlin.version} - - - org.jetbrains.kotlin - kotlin-script-util - ${kotlin.version} - - - org.jetbrains.kotlin - kotlin-scripting-jvm - ${kotlin.version} - - - org.jetbrains.kotlin - kotlin-scripting-jvm-host - ${kotlin.version} - - - - - - - - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - ${project.basedir}/src/main/kotlin - ${project.basedir}/src/test/kotlin - - - kotlin-maven-plugin - org.jetbrains.kotlin - ${kotlin.version} - - - compile - - compile - - - - test-compile - - test-compile - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - false - 0 - - - - - - diff --git a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt deleted file mode 100644 index 38be3d287e..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt +++ /dev/null @@ -1,87 +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.kotlin - -import org.apache.camel.builder.RouteBuilder -import org.apache.camel.k.RoutesLoader -import org.apache.camel.k.Runtime.Registry -import org.apache.camel.k.Source -import org.apache.camel.k.kotlin.dsl.IntegrationConfiguration -import org.apache.camel.k.support.URIResolver -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import java.io.InputStreamReader -import kotlin.script.experimental.api.* -import kotlin.script.experimental.host.toScriptSource -import kotlin.script.experimental.jvm.dependenciesFromClassloader -import kotlin.script.experimental.jvm.jvm -import kotlin.script.experimental.jvmhost.BasicJvmScriptEvaluator -import kotlin.script.experimental.jvmhost.BasicJvmScriptingHost -import kotlin.script.experimental.jvmhost.JvmScriptCompiler - -class KotlinRoutesLoader : RoutesLoader { - companion object { - val LOGGER : Logger = LoggerFactory.getLogger(KotlinRoutesLoader::class.java) - } - - override fun getSupportedLanguages(): List { - return listOf("kts") - } - - @Throws(Exception::class) - override fun load(registry: Registry, source: Source): RouteBuilder? { - return object : RouteBuilder() { - @Throws(Exception::class) - override fun configure() { - val builder = this - val compiler = JvmScriptCompiler() - val evaluator = BasicJvmScriptEvaluator() - val host = BasicJvmScriptingHost(compiler = compiler, evaluator = evaluator) - - URIResolver.resolve(context, source).use { `is` -> - val result = host.eval( - InputStreamReader(`is`).readText().toScriptSource(), - ScriptCompilationConfiguration { - baseClass(IntegrationConfiguration::class) - jvm { - // - // The Kotlin script compiler does not inherit - // the classpath by default - // - dependenciesFromClassloader(wholeClasspath = true) - } - }, - ScriptEvaluationConfiguration { - // - // Arguments used to initialize the script base class - // - constructorArgs(registry, builder) - } - ) - - for (report in result.reports) { - when { - report.severity == ScriptDiagnostic.Severity.ERROR -> LOGGER.error("{}", report.message, report.exception) - report.severity == ScriptDiagnostic.Severity.WARNING -> LOGGER.warn("{}", report.message, report.exception) - else -> LOGGER.info("{}", report.message) - } - } - } - } - } - } -} diff --git a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ComponentsConfiguration.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ComponentsConfiguration.kt deleted file mode 100644 index 97e81033a0..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ComponentsConfiguration.kt +++ /dev/null @@ -1,43 +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.kotlin.dsl - -import org.apache.camel.CamelContext -import org.apache.camel.Component - -class ComponentsConfiguration(val context: CamelContext) { - inline fun component(name: String, block: T.() -> Unit) : T { - var component = context.getComponent(name, true, false) - - // if the component is not found, let's create a new one. This is - // equivalent to create a new named component, useful to create - // multiple instances of the same component but with different setup - if (component == null) { - component = T::class.java.newInstance() - - // let's the camel context be aware of the new component - context.addComponent(name, component) - } - - if (component is T) { - component.block() - return component - } - - throw IllegalArgumentException("Type mismatch, expected: " + T::class.java + ", got: " + component.javaClass) - } -} \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt deleted file mode 100644 index ce3e8c10dd..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt +++ /dev/null @@ -1,35 +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.kotlin.dsl - -import org.apache.camel.CamelContext -import org.apache.camel.k.Runtime.Registry - -class ContextConfiguration (val registry: Registry, val context: CamelContext) { - - fun registry(block: RegistryConfiguration.() -> Unit): RegistryConfiguration { - val delegate = RegistryConfiguration(registry) - delegate.block() - return delegate - } - - fun components(block: ComponentsConfiguration.() -> Unit): ComponentsConfiguration { - val delegate = ComponentsConfiguration(context) - delegate.block() - return delegate - } -} \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt deleted file mode 100644 index 576e8d4e2b..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt +++ /dev/null @@ -1,54 +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.kotlin.dsl - -import org.apache.camel.Exchange -import org.apache.camel.Predicate -import org.apache.camel.Processor -import org.apache.camel.builder.RouteBuilder -import org.apache.camel.k.Runtime.Registry -import org.apache.camel.model.RouteDefinition - -abstract class IntegrationConfiguration( - private val registry : Registry, - private val builder : RouteBuilder) { - - fun rest(block: RestConfiguration.() -> Unit) { - val delegate = RestConfiguration(builder) - delegate.block() - } - - fun context(block: ContextConfiguration.() -> Unit) { - val delegate = ContextConfiguration( - context = builder.context, - registry = registry - ) - - delegate.block() - } - - fun from(uri: String): RouteDefinition { - return builder.from(uri) - } - - fun processor(fn: (Exchange) -> Unit) : Processor { - return Processor { exchange -> fn(exchange) } - } - fun predicate(fn: (Exchange) -> Boolean) : Predicate { - return Predicate { exchange -> fn(exchange) } - } -} \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt deleted file mode 100644 index 1e1b091948..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt +++ /dev/null @@ -1,25 +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.kotlin.dsl - -import org.apache.camel.k.Runtime.Registry - -class RegistryConfiguration(val registry: Registry) { - fun bind(name: String, value: Any) { - registry.bind(name, value) - } -} diff --git a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RestConfiguration.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RestConfiguration.kt deleted file mode 100644 index 9f9f490ba1..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RestConfiguration.kt +++ /dev/null @@ -1,39 +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.kotlin.dsl - -import org.apache.camel.builder.RouteBuilder -import org.apache.camel.model.rest.RestConfigurationDefinition -import org.apache.camel.model.rest.RestDefinition - -class RestConfiguration(val builder: RouteBuilder) { - - fun configuration(block: RestConfigurationDefinition.() -> Unit) { - val delegate = builder.restConfiguration() - delegate.block() - } - - fun configuration(component: String, block: RestConfigurationDefinition.() -> Unit) { - val delegate = builder.restConfiguration(component) - delegate.block() - } - - fun path(path: String, block: RestDefinition.() -> Unit) { - val delegate = builder.rest(path) - delegate.block() - } -} \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/extension/LogComponentExtensions.kt b/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/extension/LogComponentExtensions.kt deleted file mode 100644 index 7d948c4315..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/extension/LogComponentExtensions.kt +++ /dev/null @@ -1,24 +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.kotlin.extension - -import org.apache.camel.Exchange -import org.apache.camel.component.log.LogComponent - -fun LogComponent.formatter(fmt : (Exchange) -> String) { - this.setExchangeFormatter(fmt) -} \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/LICENSE.txt b/runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b1270ff..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - diff --git a/runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/NOTICE.txt b/runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf2e6..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. diff --git a/runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/services/org/apache/camel/k/loader/kts b/runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/services/org/apache/camel/k/loader/kts deleted file mode 100644 index d4bcde13d9..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/main/resources/META-INF/services/org/apache/camel/k/loader/kts +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.k.kotlin.KotlinRoutesLoader \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt b/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt deleted file mode 100644 index 8b09000777..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt +++ /dev/null @@ -1,47 +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.kotlin - -import org.apache.camel.impl.DefaultCamelContext -import org.apache.camel.k.InMemoryRegistry -import org.apache.camel.k.Source -import org.apache.camel.k.support.RuntimeSupport -import org.apache.camel.model.ProcessDefinition -import org.apache.camel.model.ToDefinition -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class LoaderTest { - - @Test - fun `load route from classpath`() { - var source = Source.create("classpath:routes.kts") - val loader = RuntimeSupport.loaderFor(DefaultCamelContext(), source) - val builder = loader.load(InMemoryRegistry(), source) - - assertThat(loader).isInstanceOf(KotlinRoutesLoader::class.java) - assertThat(builder).isNotNull - - builder.configure() - - val routes = builder.routeCollection.routes - assertThat(routes).hasSize(1) - assertThat(routes[0].inputs[0].endpointUri).isEqualTo("timer:tick") - assertThat(routes[0].outputs[0]).isInstanceOf(ProcessDefinition::class.java) - assertThat(routes[0].outputs[1]).isInstanceOf(ToDefinition::class.java) - } -} diff --git a/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationTest.kt b/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationTest.kt deleted file mode 100644 index ca1f73c6da..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationTest.kt +++ /dev/null @@ -1,74 +0,0 @@ -package org.apache.camel.k.kotlin.dsl - -import org.apache.camel.Processor -import org.apache.camel.component.log.LogComponent -import org.apache.camel.component.seda.SedaComponent -import org.apache.camel.k.Runtime -import org.apache.camel.k.jvm.ApplicationRuntime -import org.apache.camel.k.listener.RoutesConfigurer -import org.apache.camel.spi.ExchangeFormatter -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import java.util.concurrent.atomic.AtomicInteger -import java.util.concurrent.atomic.AtomicReference - -class IntegrationTest { - @Test - fun `load integration with rest`() { - var runtime = ApplicationRuntime() - runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-rest.kts")) - runtime.addListener(Runtime.Phase.Started) { runtime.stop() } - runtime.run() - - assertThat(runtime.context.restConfiguration.host).isEqualTo("my-host") - assertThat(runtime.context.restConfiguration.port).isEqualTo(9192) - assertThat(runtime.context.getRestConfiguration("undertow", false).host).isEqualTo("my-undertow-host") - assertThat(runtime.context.getRestConfiguration("undertow", false).port).isEqualTo(9193) - assertThat(runtime.context.restDefinitions.size).isEqualTo(1) - assertThat(runtime.context.restDefinitions[0].path).isEqualTo("/my/path") - } - - @Test - fun `load integration with binding`() { - var runtime = ApplicationRuntime() - runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-bindings.kts")) - runtime.addListener(Runtime.Phase.Started) { runtime.stop() } - runtime.run() - - assertThat(runtime.context.registry.lookupByName("my-entry")).isEqualTo("myRegistryEntry1") - assertThat(runtime.context.registry.lookupByName("my-proc")).isInstanceOf(Processor::class.java) - } - - @Test - fun `load integration with component configuration`() { - val sedaSize = AtomicInteger() - val sedaConsumers = AtomicInteger() - val mySedaSize = AtomicInteger() - val mySedaConsumers = AtomicInteger() - val format = AtomicReference() - - var runtime = ApplicationRuntime() - runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes-with-component-configuration.kts")) - runtime.addListener(Runtime.Phase.Started) { - val seda = runtime.context.getComponent("seda", SedaComponent::class.java) - val mySeda = runtime.context.getComponent("mySeda", SedaComponent::class.java) - val log = runtime.context.getComponent("log", LogComponent::class.java) - - sedaSize.set(seda!!.queueSize) - sedaConsumers.set(seda.concurrentConsumers) - mySedaSize.set(mySeda!!.queueSize) - mySedaConsumers.set(mySeda.concurrentConsumers) - format.set(log!!.exchangeFormatter) - - runtime.stop() - } - - runtime.run() - - assertThat(sedaSize.get()).isEqualTo(1234) - assertThat(sedaConsumers.get()).isEqualTo(12) - assertThat(mySedaSize.get()).isEqualTo(4321) - assertThat(mySedaConsumers.get()).isEqualTo(21) - assertThat(format.get()).isNotNull - } -} \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/extension/LogExtensionTest.kt b/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/extension/LogExtensionTest.kt deleted file mode 100644 index 9d9a32845d..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/extension/LogExtensionTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package org.apache.camel.k.kotlin.extension - -import org.apache.camel.component.log.LogComponent -import org.apache.camel.impl.DefaultCamelContext -import org.apache.camel.impl.DefaultExchange -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -class LogExtensionTest { - @Test - fun `invoke extension method - formatter`() { - val ctx = DefaultCamelContext() - - var log = LogComponent() - log.formatter { - e -> "body: " + e.getIn().body - } - - var ex = DefaultExchange(ctx) - ex.getIn().body = "hello" - - assertThat(log.exchangeFormatter.format(ex)).isEqualTo("body: hello") - } -} \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/src/test/resources/log4j2-test.xml b/runtime/camel-k-runtime-kotlin/src/test/resources/log4j2-test.xml deleted file mode 100644 index a505fd9185..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/src/test/resources/routes-new.kts b/runtime/camel-k-runtime-kotlin/src/test/resources/routes-new.kts deleted file mode 100644 index af6ac2946a..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/test/resources/routes-new.kts +++ /dev/null @@ -1,2 +0,0 @@ - -println("test") \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-bindings.kts b/runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-bindings.kts deleted file mode 100644 index b4feaeb2ba..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-bindings.kts +++ /dev/null @@ -1,16 +0,0 @@ - -context { - registry { - bind("my-entry", "myRegistryEntry1") - bind("my-proc", processor { - e -> e.getIn().body = "Hello" - }) - } -} - - -from("timer:tick") - .process().message { - m -> m.headers["MyHeader"] = "MyHeaderValue" - } - .to("log:info") \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-component-configuration.kts b/runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-component-configuration.kts deleted file mode 100644 index a93be0c046..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-component-configuration.kts +++ /dev/null @@ -1,28 +0,0 @@ -import org.apache.camel.Exchange -import org.apache.camel.component.log.LogComponent -import org.apache.camel.component.seda.SedaComponent - -context { - - components { - - component("log") { - setExchangeFormatter { - e: Exchange -> "" + e.getIn().body - } - } - - component("seda") { - queueSize = 1234 - concurrentConsumers = 12 - } - - component("mySeda") { - queueSize = 4321 - concurrentConsumers = 21 - } - } -} - -from("timer:tick") - .to("log:info") \ No newline at end of file diff --git a/runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-rest.kts b/runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-rest.kts deleted file mode 100644 index c94ccb5cea..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/test/resources/routes-with-rest.kts +++ /dev/null @@ -1,22 +0,0 @@ - -rest { - configuration { - host = "my-host" - port = "9192" - } - - configuration("undertow") { - host = "my-undertow-host" - port = "9193" - } - - path("/my/path") { - } -} - - -from("timer:tick") - .process().message { - m -> m.headers["MyHeader"] = "MyHeaderValue" - } - .to("log:info") diff --git a/runtime/camel-k-runtime-kotlin/src/test/resources/routes.kts b/runtime/camel-k-runtime-kotlin/src/test/resources/routes.kts deleted file mode 100644 index 5bf9c94616..0000000000 --- a/runtime/camel-k-runtime-kotlin/src/test/resources/routes.kts +++ /dev/null @@ -1,6 +0,0 @@ - -from("timer:tick") - .process().message { - m -> m.headers["MyHeader"] = "MyHeaderValue" - } - .to("log:info") \ No newline at end of file diff --git a/runtime/camel-k-runtime-spring-boot-layout/pom.xml b/runtime/camel-k-runtime-spring-boot-layout/pom.xml deleted file mode 100644 index 2471e5527d..0000000000 --- a/runtime/camel-k-runtime-spring-boot-layout/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - org.apache.camel.k - camel-k-runtime-parent - 0.3.0-SNAPSHOT - - - 4.0.0 - camel-k-runtime-spring-boot-layout - - - - org.springframework.boot - spring-boot-loader-tools - ${spring-boot.version} - - - diff --git a/runtime/camel-k-runtime-spring-boot-layout/src/main/java/org/apache/camel/k/spring/boot/layout/Factory.java b/runtime/camel-k-runtime-spring-boot-layout/src/main/java/org/apache/camel/k/spring/boot/layout/Factory.java deleted file mode 100644 index 3367ec64e4..0000000000 --- a/runtime/camel-k-runtime-spring-boot-layout/src/main/java/org/apache/camel/k/spring/boot/layout/Factory.java +++ /dev/null @@ -1,49 +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.spring.boot.layout; - -import java.io.File; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import org.springframework.boot.loader.tools.Layout; -import org.springframework.boot.loader.tools.Layouts; -import org.springframework.boot.loader.tools.LibraryScope; - -public class Factory implements org.springframework.boot.loader.tools.LayoutFactory { - private static final Set SCOPES = new HashSet<>( - Arrays.asList( - LibraryScope.COMPILE, - LibraryScope.RUNTIME, - LibraryScope.CUSTOM) - ); - - @Override - public Layout getLayout(File source) { - return new Layouts.Jar() { - @Override - public String getLibraryDestination(String libraryName, LibraryScope scope) { - if (SCOPES.contains(scope)) { - return super.getLibraryDestination(libraryName, scope); - } - - return null; - } - }; - } -} diff --git a/runtime/camel-k-runtime-spring-boot-layout/src/main/resources/META-INF/LICENSE.txt b/runtime/camel-k-runtime-spring-boot-layout/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b1270ff..0000000000 --- a/runtime/camel-k-runtime-spring-boot-layout/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - diff --git a/runtime/camel-k-runtime-spring-boot-layout/src/main/resources/META-INF/NOTICE.txt b/runtime/camel-k-runtime-spring-boot-layout/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf2e6..0000000000 --- a/runtime/camel-k-runtime-spring-boot-layout/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. diff --git a/runtime/camel-k-runtime-spring-boot-layout/src/main/resources/META-INF/spring.factories b/runtime/camel-k-runtime-spring-boot-layout/src/main/resources/META-INF/spring.factories deleted file mode 100644 index d4c5848906..0000000000 --- a/runtime/camel-k-runtime-spring-boot-layout/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.loader.tools.LayoutFactory=\ - org.apache.camel.k.spring.boot.layout.Factory \ No newline at end of file diff --git a/runtime/camel-k-runtime-spring-boot/pom.xml b/runtime/camel-k-runtime-spring-boot/pom.xml deleted file mode 100644 index 70bb80bf53..0000000000 --- a/runtime/camel-k-runtime-spring-boot/pom.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - org.apache.camel.k - camel-k-runtime-parent - 0.3.0-SNAPSHOT - - - 4.0.0 - camel-k-runtime-spring-boot - - - ${project.build.directory}/${project.build.finalName}.jar - - - - - - - - - - - - org.apache.camel.k - camel-k-runtime-jvm - ${project.version} - - - org.apache.logging.log4j - log4j-core - - - org.apache.logging.log4j - log4j-slf4j-impl - - - - - - org.apache.camel - camel-spring-boot-starter - - - org.springframework.boot - spring-boot-starter-logging - - - - - - org.springframework.boot - spring-boot-starter-log4j2 - ${spring-boot.version} - - - org.springframework.boot - spring-boot-loader-tools - ${spring-boot.version} - true - - - - - - - - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - - org.assertj - assertj-core - ${assertj.version} - test - - - - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring-boot.version} - - - - repackage - - - - - org.apache.camel.k.spring.boot.Application - - - - - org.apache.camel.k - camel-k-runtime-spring-boot-layout - ${project.version} - - - - - - diff --git a/runtime/camel-k-runtime-spring-boot/src/main/java/org/apache/camel/k/spring/boot/Application.java b/runtime/camel-k-runtime-spring-boot/src/main/java/org/apache/camel/k/spring/boot/Application.java deleted file mode 100644 index c5e8e37561..0000000000 --- a/runtime/camel-k-runtime-spring-boot/src/main/java/org/apache/camel/k/spring/boot/Application.java +++ /dev/null @@ -1,65 +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.spring.boot; - -import java.util.Properties; - -import org.apache.camel.k.support.PlatformStreamHandler; -import org.apache.camel.k.support.RuntimeSupport; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; - -@SpringBootApplication -public class Application { - static { - // - // Install a custom protocol handler to support discovering resources - // from the platform i.e. in knative, resources are provided through - // env var as it is not possible to mount config maps / secrets. - // - // TODO: we should remove as soon as we get a knative version that - // includes https://github.com/knative/serving/pull/3061 - // - PlatformStreamHandler.configure(); - } - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - - @Bean - public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { - // load properties using default behaviour - final Properties properties = RuntimeSupport.loadProperties(); - - // set spring boot specific properties - properties.put("camel.springboot.main-run-controller", "true"); - properties.put("camel.springboot.name", "camel-k"); - properties.put("camel.springboot.streamCachingEnabled", "true"); - properties.put("camel.springboot.xml-routes", "false"); - properties.put("camel.springboot.xml-rests", "false"); - properties.put("camel.springboot.jmx-enabled", "false"); - - // set loaded properties as default properties - PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer(); - configurer.setProperties(properties); - - return configurer; - } -} diff --git a/runtime/camel-k-runtime-spring-boot/src/main/java/org/apache/camel/k/spring/boot/ApplicationAutoConfiguration.java b/runtime/camel-k-runtime-spring-boot/src/main/java/org/apache/camel/k/spring/boot/ApplicationAutoConfiguration.java deleted file mode 100644 index 7182add8a8..0000000000 --- a/runtime/camel-k-runtime-spring-boot/src/main/java/org/apache/camel/k/spring/boot/ApplicationAutoConfiguration.java +++ /dev/null @@ -1,132 +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.spring.boot; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.apache.camel.CamelContext; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.listener.ContextConfigurer; -import org.apache.camel.k.listener.RoutesConfigurer; -import org.apache.camel.k.listener.RoutesDumper; -import org.apache.camel.k.support.RuntimeSupport; -import org.apache.camel.spring.boot.CamelContextConfiguration; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; - -@Configuration -public class ApplicationAutoConfiguration { - - @Bean - public CamelContextConfiguration routesConfiguration(ConfigurableApplicationContext applicationContext) throws Exception { - return new CamelContextConfigurer(applicationContext, Arrays.asList(new ContextConfigurer(), new RoutesConfigurer(), new RoutesDumper())); - } - - // ***************************** - // - // - // - // ***************************** - - private static class CamelContextConfigurer implements CamelContextConfiguration { - private final ConfigurableApplicationContext applicationContext; - private final List listeners; - - public CamelContextConfigurer(ConfigurableApplicationContext applicationContext, List listeners) { - this.applicationContext = applicationContext; - this.listeners = listeners; - } - - @Override - public void beforeApplicationStart(CamelContext context) { - final Runtime.Registry registry = new RuntimeApplicationContextRegistry(applicationContext, context.getRegistry()); - final Runtime runtime = new Runtime() { - @Override - public CamelContext getContext() { - return context; - } - @Override - public Registry getRegistry() { - return registry; - } - }; - - listeners.forEach(l -> l.accept(Runtime.Phase.Starting, runtime)); - listeners.forEach(l -> l.accept(Runtime.Phase.ConfigureContext, runtime)); - listeners.forEach(l -> l.accept(Runtime.Phase.ConfigureRoutes, runtime)); - } - - @Override - public void afterApplicationStart(CamelContext context) { - final Runtime.Registry registry = new RuntimeApplicationContextRegistry(applicationContext, context.getRegistry()); - final Runtime runtime = new Runtime() { - @Override - public CamelContext getContext() { - return context; - } - @Override - public Registry getRegistry() { - return registry; - } - }; - - listeners.forEach(l -> l.accept(Runtime.Phase.Started, runtime)); - - } - } - - private static class RuntimeApplicationContextRegistry implements Runtime.Registry { - private final ConfigurableApplicationContext applicationContext; - private final org.apache.camel.spi.Registry registry; - - public RuntimeApplicationContextRegistry(ConfigurableApplicationContext applicationContext, org.apache.camel.spi.Registry registry) { - this.applicationContext = applicationContext; - this.registry = registry; - } - - @Override - public Object lookupByName(String name) { - return registry.lookupByName(name); - } - - @Override - public T lookupByNameAndType(String name, Class type) { - return registry.lookupByNameAndType(name, type); - } - - @Override - public Map findByTypeWithName(Class type) { - return registry.findByTypeWithName(type); - } - - @Override - public Set findByType(Class type) { - return registry.findByType(type); - } - @Override - public void bind(String name, Object bean) { - applicationContext.getBeanFactory().registerSingleton(name, bean); - } - } - -} diff --git a/runtime/camel-k-runtime-spring-boot/src/main/resources/META-INF/LICENSE.txt b/runtime/camel-k-runtime-spring-boot/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b1270ff..0000000000 --- a/runtime/camel-k-runtime-spring-boot/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - diff --git a/runtime/camel-k-runtime-spring-boot/src/main/resources/META-INF/NOTICE.txt b/runtime/camel-k-runtime-spring-boot/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf2e6..0000000000 --- a/runtime/camel-k-runtime-spring-boot/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. diff --git a/runtime/camel-k-runtime-spring-boot/src/main/resources/META-INF/spring.factories b/runtime/camel-k-runtime-spring-boot/src/main/resources/META-INF/spring.factories deleted file mode 100644 index f6df31c271..0000000000 --- a/runtime/camel-k-runtime-spring-boot/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,2 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - org.apache.camel.k.spring.boot.ApplicationAutoConfiguration \ No newline at end of file diff --git a/runtime/camel-k-runtime-yaml/pom.xml b/runtime/camel-k-runtime-yaml/pom.xml deleted file mode 100644 index dac0cef42e..0000000000 --- a/runtime/camel-k-runtime-yaml/pom.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - org.apache.camel.k - camel-k-runtime-parent - 0.3.0-SNAPSHOT - - 4.0.0 - - camel-k-runtime-yaml - - - - - - - - - - - org.apache.camel - camel-core - provided - - - org.apache.camel.k - camel-k-runtime-jvm - ${project.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.dataformat - jackson-dataformat-yaml - ${jackson.version} - - - - - - - - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - - org.assertj - assertj-core - ${assertj.version} - test - - - - diff --git a/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/YamlFlowLoader.java b/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/YamlFlowLoader.java deleted file mode 100644 index 98ecd5a20e..0000000000 --- a/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/YamlFlowLoader.java +++ /dev/null @@ -1,103 +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.yaml; - -import java.io.InputStream; -import java.util.Collections; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.databind.jsontype.NamedType; -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import com.fasterxml.jackson.dataformat.yaml.YAMLGenerator; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.k.RoutesLoader; -import org.apache.camel.k.Runtime; -import org.apache.camel.k.Source; -import org.apache.camel.k.support.URIResolver; -import org.apache.camel.k.yaml.model.Endpoint; -import org.apache.camel.k.yaml.model.Flow; -import org.apache.camel.k.yaml.model.Step; -import org.apache.camel.k.yaml.model.StepHandler; -import org.apache.camel.model.ProcessorDefinition; -import org.apache.camel.spi.FactoryFinder; - -public class YamlFlowLoader implements RoutesLoader { - private final ObjectMapper mapper; - - public YamlFlowLoader() { - YAMLFactory yamlFactory = new YAMLFactory() - .configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true) - .configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, true) - .configure(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID, false); - - this.mapper = new ObjectMapper(yamlFactory) - .setSerializationInclusion(JsonInclude.Include.NON_EMPTY) - .enable(SerializationFeature.INDENT_OUTPUT); - - mapper.registerSubtypes(new NamedType(Endpoint.class, Endpoint.KIND)); - } - - @Override - public List getSupportedLanguages() { - return Collections.singletonList("flow"); - } - - @SuppressWarnings("uncheked") - @Override - public RouteBuilder load(Runtime.Registry registry, Source source) throws Exception { - return new RouteBuilder() { - @Override - public void configure() throws Exception { - try (InputStream is = URIResolver.resolve(getContext(), source)) { - for (Flow flow: mapper.readValue(is, Flow[].class)) { - final List steps = flow.getSteps(); - final int size = steps.size(); - final FactoryFinder finder = getContext().getFactoryFinder(Step.RESOURCE_PATH); - - ProcessorDefinition definition = null; - - for (int i = 0; i < size; i++) { - Step step = steps.get(i); - - if (i == 0) { - // force the cast so it will fail at runtime - // if the step is not of the right type - definition = from(((Endpoint) step).getUri()); - - continue; - } - - if (definition == null) { - throw new IllegalStateException("No route definition"); - } - - StepHandler handler = (StepHandler)finder.newInstance(step.getKind()); - if (handler == null) { - throw new IllegalStateException("No handler for step with kind: " + step.getKind()); - } - - definition = handler.handle(step, definition); - } - } - } - } - }; - } -} diff --git a/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/Endpoint.java b/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/Endpoint.java deleted file mode 100644 index 6ad07ee755..0000000000 --- a/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/Endpoint.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.yaml.model; - -public class Endpoint extends Step { - public static final String KIND = "endpoint"; - - private String uri; - - public Endpoint() { - super(KIND); - } - - public Endpoint(String uri) { - super(KIND); - - this.uri = uri; - } - - @Override - public String toString() { - return "Endpoint: " + uri; - } - - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } -} diff --git a/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/Flow.java b/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/Flow.java deleted file mode 100644 index 89031dd0f6..0000000000 --- a/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/Flow.java +++ /dev/null @@ -1,31 +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.yaml.model; - -import java.util.List; - -public class Flow { - private List steps; - - public List getSteps() { - return steps; - } - - public void setSteps(List steps) { - this.steps = steps; - } -} diff --git a/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/Step.java b/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/Step.java deleted file mode 100644 index f2e8a2eafc..0000000000 --- a/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/Step.java +++ /dev/null @@ -1,38 +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.yaml.model; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "kind") -public abstract class Step { - public static final String RESOURCE_PATH = "META-INF/services/org/apache/camel/k/yaml/flow/"; - - private final String kind; - - public Step(String kind) { - this.kind = kind; - } - - @JsonIgnore - public String getKind() { - return kind; - } -} diff --git a/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/StepHandler.java b/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/StepHandler.java deleted file mode 100644 index 8a260306a0..0000000000 --- a/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/StepHandler.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.yaml.model; - -import org.apache.camel.model.ProcessorDefinition; - -@FunctionalInterface -public interface StepHandler { - - /** - * @param step the step - * @param route the handler - * @return - */ - ProcessorDefinition handle(T step, ProcessorDefinition route); -} diff --git a/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/handler/EndpointHandler.java b/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/handler/EndpointHandler.java deleted file mode 100644 index 25b80b505b..0000000000 --- a/runtime/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/model/handler/EndpointHandler.java +++ /dev/null @@ -1,36 +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.yaml.model.handler; - -import org.apache.camel.k.yaml.model.Endpoint; -import org.apache.camel.k.yaml.model.StepHandler; -import org.apache.camel.model.ProcessorDefinition; -import org.apache.camel.util.ObjectHelper; - -public class EndpointHandler implements StepHandler { - @Override - public ProcessorDefinition handle(Endpoint step, ProcessorDefinition route) { - String uri = step.getUri(); - - if (!ObjectHelper.isEmpty(uri)) { - route = route.to(uri); - } - - return route; - } -} - diff --git a/runtime/camel-k-runtime-yaml/src/main/resources/META-INF/LICENSE.txt b/runtime/camel-k-runtime-yaml/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b1270ff..0000000000 --- a/runtime/camel-k-runtime-yaml/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - diff --git a/runtime/camel-k-runtime-yaml/src/main/resources/META-INF/NOTICE.txt b/runtime/camel-k-runtime-yaml/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf2e6..0000000000 --- a/runtime/camel-k-runtime-yaml/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. diff --git a/runtime/camel-k-runtime-yaml/src/main/resources/META-INF/services/org/apache/camel/k/loader/flow b/runtime/camel-k-runtime-yaml/src/main/resources/META-INF/services/org/apache/camel/k/loader/flow deleted file mode 100644 index 242f87417a..0000000000 --- a/runtime/camel-k-runtime-yaml/src/main/resources/META-INF/services/org/apache/camel/k/loader/flow +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.k.yaml.YamlFlowLoader \ No newline at end of file diff --git a/runtime/camel-k-runtime-yaml/src/main/resources/META-INF/services/org/apache/camel/k/yaml/flow/endpoint b/runtime/camel-k-runtime-yaml/src/main/resources/META-INF/services/org/apache/camel/k/yaml/flow/endpoint deleted file mode 100644 index 6af1c19340..0000000000 --- a/runtime/camel-k-runtime-yaml/src/main/resources/META-INF/services/org/apache/camel/k/yaml/flow/endpoint +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.k.yaml.model.handler.EndpointHandler \ No newline at end of file diff --git a/runtime/camel-k-runtime-yaml/src/test/java/org/apache/camel/k/yaml/RoutesLoaderTest.java b/runtime/camel-k-runtime-yaml/src/test/java/org/apache/camel/k/yaml/RoutesLoaderTest.java deleted file mode 100644 index 1035306fad..0000000000 --- a/runtime/camel-k-runtime-yaml/src/test/java/org/apache/camel/k/yaml/RoutesLoaderTest.java +++ /dev/null @@ -1,51 +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.yaml; - -import java.util.List; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.k.RoutesLoader; -import org.apache.camel.k.Source; -import org.apache.camel.k.InMemoryRegistry; -import org.apache.camel.k.support.RuntimeSupport; -import org.apache.camel.model.RouteDefinition; -import org.apache.camel.model.ToDefinition; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class RoutesLoaderTest { - - @Test - public void testLoadYamlFlow() throws Exception { - Source source = Source.create("classpath:routes.flow"); - RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source); - RouteBuilder builder = loader.load(new InMemoryRegistry(), source); - - assertThat(loader).isInstanceOf(YamlFlowLoader.class); - assertThat(builder).isNotNull(); - - builder.configure(); - - List routes = builder.getRouteCollection().getRoutes(); - assertThat(routes).hasSize(1); - assertThat(routes.get(0).getInputs().get(0).getEndpointUri()).isEqualTo("timer:tick"); - assertThat(routes.get(0).getOutputs().get(0)).isInstanceOf(ToDefinition.class); - } -} diff --git a/runtime/camel-k-runtime-yaml/src/test/resources/log4j2-test.xml b/runtime/camel-k-runtime-yaml/src/test/resources/log4j2-test.xml deleted file mode 100644 index a505fd9185..0000000000 --- a/runtime/camel-k-runtime-yaml/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/runtime/camel-k-runtime-yaml/src/test/resources/routes.flow b/runtime/camel-k-runtime-yaml/src/test/resources/routes.flow deleted file mode 100644 index 19645350ea..0000000000 --- a/runtime/camel-k-runtime-yaml/src/test/resources/routes.flow +++ /dev/null @@ -1,5 +0,0 @@ -- steps: - - kind: "endpoint" - uri: "timer:tick" - - kind: "endpoint" - uri: "log:info" \ No newline at end of file diff --git a/runtime/camel-knative-http/pom.xml b/runtime/camel-knative-http/pom.xml deleted file mode 100644 index b0a955eacd..0000000000 --- a/runtime/camel-knative-http/pom.xml +++ /dev/null @@ -1,108 +0,0 @@ - - - - - org.apache.camel.k - camel-k-runtime-parent - 0.3.0-SNAPSHOT - - 4.0.0 - - camel-knative-http - - - - - - - - - - - org.slf4j - slf4j-api - ${slf4j.version} - - - - org.apache.camel - camel-core - provided - - - org.apache.camel - camel-netty4-http - provided - - - - - - - - - - org.apache.camel - camel-test - - - junit - junit - - - test - - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - - org.assertj - assertj-core - ${assertj.version} - test - - - - org.apache.logging.log4j - log4j-core - ${log4j2.version} - test - - - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j2.version} - test - - - - - diff --git a/runtime/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttp.java b/runtime/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttp.java deleted file mode 100644 index 82fd12b03d..0000000000 --- a/runtime/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttp.java +++ /dev/null @@ -1,22 +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.component.knative.http; - -public final class KnativeHttp { - private KnativeHttp() { - } -} diff --git a/runtime/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpComponent.java b/runtime/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpComponent.java deleted file mode 100644 index 7287122514..0000000000 --- a/runtime/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpComponent.java +++ /dev/null @@ -1,263 +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.component.knative.http; - -import java.net.URI; -import java.nio.channels.ClosedChannelException; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArraySet; - -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.SimpleChannelInboundHandler; -import io.netty.handler.codec.http.DefaultHttpResponse; -import io.netty.handler.codec.http.HttpContent; -import io.netty.handler.codec.http.HttpHeaders; -import io.netty.handler.codec.http.HttpRequest; -import io.netty.handler.codec.http.HttpResponse; -import io.netty.util.Attribute; -import io.netty.util.AttributeKey; -import org.apache.camel.Exchange; -import org.apache.camel.component.netty4.http.HttpServerConsumerChannelFactory; -import org.apache.camel.component.netty4.http.NettyHttpComponent; -import org.apache.camel.component.netty4.http.NettyHttpConsumer; -import org.apache.camel.component.netty4.http.handlers.HttpServerChannelHandler; -import org.apache.camel.http.common.CamelServlet; -import org.apache.camel.support.RestConsumerContextPathMatcher; -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.ServiceHelper; -import org.apache.camel.util.URISupport; -import org.apache.camel.util.UnsafeUriCharactersEncoder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import static io.netty.handler.codec.http.HttpResponseStatus.METHOD_NOT_ALLOWED; -import static io.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND; -import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; - -public class KnativeHttpComponent extends NettyHttpComponent { - private final Map handlers = new ConcurrentHashMap<>(); - - @Override - public synchronized HttpServerConsumerChannelFactory getMultiplexChannelHandler(int port) { - return handlers.computeIfAbsent(port, Handler::new); - } - - @Override - protected void doStop() throws Exception { - super.doStop(); - - ServiceHelper.stopService(handlers.values()); - handlers.clear(); - } - - @ChannelHandler.Sharable - private static class Handler extends SimpleChannelInboundHandler implements HttpServerConsumerChannelFactory { - private static final Logger LOG = LoggerFactory.getLogger(Handler.class); - private static final AttributeKey SERVER_HANDLER_KEY = AttributeKey.valueOf("serverHandler"); - - private final Set consumers; - private final int port; - private final String token; - private final int len; - - public Handler(int port) { - this.consumers = new CopyOnWriteArraySet<>(); - this.port = port; - this.token = ":" + port; - this.len = token.length(); - } - - public void init(int port) { - } - - public void addConsumer(NettyHttpConsumer consumer) { - consumers.add(new HttpServerChannelHandler(consumer)); - } - - public void removeConsumer(NettyHttpConsumer consumer) { - consumers.removeIf(h -> h.getConsumer() == consumer); - } - - public int consumers() { - return consumers.size(); - } - - public int getPort() { - return port; - } - - public ChannelHandler getChannelHandler() { - return this; - } - - @Override - protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { - // store request, as this channel handler is created per pipeline - HttpRequest request = (HttpRequest) msg; - - LOG.debug("Message received: {}", request); - - HttpServerChannelHandler handler = getHandler(request, request.method().name()); - if (handler != null) { - Attribute attr = ctx.channel().attr(SERVER_HANDLER_KEY); - // store handler as attachment - attr.set(handler); - if (msg instanceof HttpContent) { - // need to hold the reference of content - HttpContent httpContent = (HttpContent) msg; - httpContent.content().retain(); - } - handler.channelRead(ctx, request); - } else { - // okay we cannot process this requires so return either 404 or 405. - // to know if its 405 then we need to check if any other HTTP method would have a consumer for the "same" request - boolean hasAnyMethod = CamelServlet.METHODS.stream().anyMatch(m -> isHttpMethodAllowed(request, m)); - HttpResponse response = null; - if (hasAnyMethod) { - //method match error, return 405 - response = new DefaultHttpResponse(HTTP_1_1, METHOD_NOT_ALLOWED); - } else { - // this resource is not found, return 404 - response = new DefaultHttpResponse(HTTP_1_1, NOT_FOUND); - } - response.headers().set(Exchange.CONTENT_TYPE, "text/plain"); - response.headers().set(Exchange.CONTENT_LENGTH, 0); - ctx.writeAndFlush(response); - ctx.close(); - } - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - Attribute attr = ctx.channel().attr(SERVER_HANDLER_KEY); - HttpServerChannelHandler handler = attr.get(); - if (handler != null) { - handler.exceptionCaught(ctx, cause); - } else { - if (cause instanceof ClosedChannelException) { - // The channel is closed so we do nothing here - LOG.debug("Channel already closed. Ignoring this exception."); - return; - } else { - // we cannot throw the exception here - LOG.warn("HttpServerChannelHandler is not found as attachment to handle exception, send 404 back to the client.", cause); - // Now we just send 404 back to the client - HttpResponse response = new DefaultHttpResponse(HTTP_1_1, NOT_FOUND); - response.headers().set(Exchange.CONTENT_TYPE, "text/plain"); - response.headers().set(Exchange.CONTENT_LENGTH, 0); - ctx.writeAndFlush(response); - ctx.close(); - } - } - } - - private boolean isHttpMethodAllowed(HttpRequest request, String method) { - return getHandler(request, method) != null; - } - - @SuppressWarnings("unchecked") - private HttpServerChannelHandler getHandler(HttpRequest request, String method) { - HttpServerChannelHandler answer = null; - - // need to strip out host and port etc, as we only need the context-path for matching - if (method == null) { - return null; - } - - String path = request.uri(); - int idx = path.indexOf(token); - if (idx > -1) { - path = path.substring(idx + len); - } - // use the path as key to find the consumer handler to use - path = pathAsKey(path); - - /* - List paths = new ArrayList<>(); - for (final HttpServerChannelHandler handler : consumers) { - paths.add(new HttpRestConsumerPath(handler)); - } - - RestConsumerContextPathMatcher.ConsumerPath best = RestConsumerContextPathMatcher.matchBestPath(method, path, paths); - if (best != null) { - answer = best.getConsumer(); - } - */ - - // fallback to regular matching - if (answer == null) { - for (final HttpServerChannelHandler handler : consumers) { - try { - final NettyHttpConsumer consumer = handler.getConsumer(); - final HttpHeaders headers = request.headers(); - final String uri = consumer.getEndpoint().getEndpointUri(); - final Map params = URISupport.parseParameters(URI.create(uri)); - - if (params.containsKey("filter.headerName") && params.containsKey("filter.headerValue")) { - final String filterKey = (String) params.get("filter.headerName"); - final String filterVal = (String) params.get("filter.headerValue"); - final String headerVal = headers.get(filterKey); - - if (ObjectHelper.isEmpty(headerVal)) { - continue; - } - if (!ObjectHelper.equal(filterVal, headerVal)) { - continue; - } - } - - String consumerPath = consumer.getConfiguration().getPath(); - boolean matchOnUriPrefix = consumer.getEndpoint().getConfiguration().isMatchOnUriPrefix(); - // Just make sure the we get the right consumer path first - if (RestConsumerContextPathMatcher.matchPath(path, consumerPath, matchOnUriPrefix)) { - answer = handler; - break; - } - } catch (Exception e) { - throw ObjectHelper.wrapRuntimeCamelException(e); - } - } - } - - return answer; - } - - private static String pathAsKey(String path) { - // cater for default path - if (path == null || path.equals("/")) { - path = ""; - } - - // strip out query parameters - int idx = path.indexOf('?'); - if (idx > -1) { - path = path.substring(0, idx); - } - - // strip of ending / - if (path.endsWith("/")) { - path = path.substring(0, path.length() - 1); - } - - return UnsafeUriCharactersEncoder.encodeHttpURI(path); - } - - } -} diff --git a/runtime/camel-knative-http/src/main/resources/META-INF/LICENSE.txt b/runtime/camel-knative-http/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b1270ff..0000000000 --- a/runtime/camel-knative-http/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - diff --git a/runtime/camel-knative-http/src/main/resources/META-INF/NOTICE.txt b/runtime/camel-knative-http/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf2e6..0000000000 --- a/runtime/camel-knative-http/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. diff --git a/runtime/camel-knative-http/src/main/resources/META-INF/services/org/apache/camel/component/knative-http b/runtime/camel-knative-http/src/main/resources/META-INF/services/org/apache/camel/component/knative-http deleted file mode 100644 index 439d7643a4..0000000000 --- a/runtime/camel-knative-http/src/main/resources/META-INF/services/org/apache/camel/component/knative-http +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.component.knative.http.KnativeHttpComponent \ No newline at end of file diff --git a/runtime/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpMain.java b/runtime/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpMain.java deleted file mode 100644 index ba4099ff3c..0000000000 --- a/runtime/camel-knative-http/src/test/java/org/apache/camel/component/knative/http/KnativeHttpMain.java +++ /dev/null @@ -1,52 +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.component.knative.http; - -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.impl.SimpleRegistry; - -public class KnativeHttpMain { - public static void main(String[] args) throws Exception { - SimpleRegistry registry = new SimpleRegistry(); - DefaultCamelContext context = new DefaultCamelContext(registry); - - try { - context.disableJMX(); - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("knative-http:http://0.0.0.0:8080?filter.headerName=CE-Source&filter.headerValue=CH1") - .convertBodyTo(String.class) - .to("log:ch-11?showAll=true&multiline=true") - .setBody().constant("Hello from CH1"); - from("knative-http:http://0.0.0.0:8080?filter.headerName=CE-Source&filter.headerValue=CH2") - .convertBodyTo(String.class) - .to("log:ch-2?showAll=true&multiline=true") - .setBody().constant("Hello from CH2"); - } - }); - - context.start(); - - Thread.sleep(Integer.MAX_VALUE); - } finally { - context.stop(); - } - - } -} diff --git a/runtime/camel-knative-http/src/test/resources/log4j2-test.xml b/runtime/camel-knative-http/src/test/resources/log4j2-test.xml deleted file mode 100644 index b31e8b43ea..0000000000 --- a/runtime/camel-knative-http/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/runtime/camel-knative/pom.xml b/runtime/camel-knative/pom.xml deleted file mode 100644 index f845ac6b9a..0000000000 --- a/runtime/camel-knative/pom.xml +++ /dev/null @@ -1,140 +0,0 @@ - - - - - org.apache.camel.k - camel-k-runtime-parent - 0.3.0-SNAPSHOT - - 4.0.0 - - camel-knative - - - - - - - - - - - org.slf4j - slf4j-api - ${slf4j.version} - - - - org.apache.camel - camel-core - provided - - - org.apache.camel - camel-netty4-http - provided - - - org.apache.camel.k - camel-knative-http - ${project.version} - - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - com.fasterxml.jackson.datatype - jackson-datatype-jdk8 - ${jackson.version} - - - - org.apache.commons - commons-collections4 - ${commons-collections4.version} - - - org.apache.commons - commons-lang3 - ${commons-lang.version} - - - - - - - - - - org.apache.camel - camel-test - - - junit - junit - - - test - - - org.apache.camel - camel-http4 - test - - - - org.junit.jupiter - junit-jupiter-api - ${junit-jupiter.version} - test - - - org.junit.jupiter - junit-jupiter-engine - ${junit-jupiter.version} - test - - - - org.assertj - assertj-core - ${assertj.version} - test - - - - org.apache.logging.log4j - log4j-core - ${log4j2.version} - test - - - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j2.version} - test - - - - - diff --git a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/Knative.java b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/Knative.java deleted file mode 100644 index ce701efabf..0000000000 --- a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/Knative.java +++ /dev/null @@ -1,47 +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.component.knative; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; - -public final class Knative { - public static final ObjectMapper MAPPER = new ObjectMapper().registerModule(new Jdk8Module()); - - - public static final String HTTP_COMPONENT = "knative-http"; - public static final String KNATIVE_PROTOCOL = "knative.protocol"; - public static final String KNATIVE_TYPE = "knative.type"; - public static final String KNATIVE_EVENT_TYPE = "knative.event.type"; - public static final String FILTER_HEADER_NAME = "filter.header.name"; - public static final String FILTER_HEADER_VALUE = "filter.header.value"; - public static final String CONTENT_TYPE = "content.type"; - public static final String MIME_STRUCTURED_CONTENT_MODE = "application/cloudevents+json"; - - private Knative() { - } - - public enum Type { - endpoint, - channel - } - - public enum Protocol { - http, - https - } -} diff --git a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java deleted file mode 100644 index 60b7835e3f..0000000000 --- a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java +++ /dev/null @@ -1,135 +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.component.knative; - -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.Endpoint; -import org.apache.camel.impl.DefaultComponent; -import org.apache.camel.util.IntrospectionSupport; -import org.apache.camel.util.StringHelper; - -public class KnativeComponent extends DefaultComponent { - public static final String CONFIGURATION_ENV_VARIABLE = "CAMEL_KNATIVE_CONFIGURATION"; - - private final KnativeConfiguration configuration; - private String environmentPath; - - public KnativeComponent() { - this(null); - } - - public KnativeComponent(CamelContext context) { - super(context); - - this.configuration = new KnativeConfiguration(); - } - - // ************************ - // - // Properties - // - // ************************ - - public String getEnvironmentPath() { - return environmentPath; - } - - /** - * The path ot the environment definition - */ - public void setEnvironmentPath(String environmentPath) { - this.environmentPath = environmentPath; - } - - public KnativeConfiguration getConfiguration() { - return configuration; - } - - public KnativeEnvironment getEnvironment() { - return configuration.getEnvironment(); - } - - /** - * The environment - */ - public void setEnvironment(KnativeEnvironment environment) { - configuration.setEnvironment(environment); - } - - public boolean isJsonSerializationEnabled() { - return configuration.isJsonSerializationEnabled(); - } - - public void setJsonSerializationEnabled(boolean jsonSerializationEnabled) { - configuration.setJsonSerializationEnabled(jsonSerializationEnabled); - } - - public String getCloudEventsSpecVersion() { - return configuration.getCloudEventsSpecVersion(); - } - - public void setCloudEventsSpecVersion(String cloudEventSpecVersion) { - configuration.setCloudEventsSpecVersion(cloudEventSpecVersion); - } - - // ************************ - // - // - // - // ************************ - - @Override - protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws Exception { - final String type = StringHelper.before(remaining, "/"); - final String target = StringHelper.after(remaining, "/"); - final KnativeConfiguration conf = getKnativeConfiguration(); - - // set properties from the endpoint uri - IntrospectionSupport.setProperties(getCamelContext().getTypeConverter(), conf, parameters); - - return new KnativeEndpoint(uri, this, Knative.Type.valueOf(type), target, conf); - } - - // ************************ - // - // Helpers - // - // ************************ - - private KnativeConfiguration getKnativeConfiguration() throws Exception { - KnativeConfiguration conf = configuration.copy(); - - if (conf.getEnvironment() == null) { - String envConfig = System.getenv(CONFIGURATION_ENV_VARIABLE); - if (environmentPath != null) { - conf.setEnvironment( - KnativeEnvironment.mandatoryLoadFromResource(getCamelContext(), this.environmentPath) - ); - } else if (envConfig != null) { - conf.setEnvironment( - KnativeEnvironment.mandatoryLoadFromSerializedString(getCamelContext(), envConfig) - ); - } else { - throw new IllegalStateException("Cannot load Knative configuration from file or env variable"); - } - } - - return conf; - } -} diff --git a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java deleted file mode 100644 index 967f7dd2a2..0000000000 --- a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java +++ /dev/null @@ -1,83 +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.component.knative; - -import org.apache.camel.RuntimeCamelException; -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.UriParam; - -public class KnativeConfiguration implements Cloneable { - @UriParam - @Metadata(required = "true") - private KnativeEnvironment environment; - - @UriParam(defaultValue = "false") - private boolean jsonSerializationEnabled; - - @UriParam(defaultValue = "0.1", enums = "0.1,0.2") - private String cloudEventsSpecVersion = "0.1"; - - public KnativeConfiguration() { - } - - // ************************ - // - // Properties - // - // ************************ - - public KnativeEnvironment getEnvironment() { - return environment; - } - - /** - * The environment - */ - public void setEnvironment(KnativeEnvironment environment) { - this.environment = environment; - } - - public boolean isJsonSerializationEnabled() { - return jsonSerializationEnabled; - } - - public void setJsonSerializationEnabled(boolean jsonSerializationEnabled) { - this.jsonSerializationEnabled = jsonSerializationEnabled; - } - - public String getCloudEventsSpecVersion() { - return cloudEventsSpecVersion; - } - - public void setCloudEventsSpecVersion(String cloudEventsSpecVersion) { - this.cloudEventsSpecVersion = cloudEventsSpecVersion; - } - - // ************************ - // - // Cloneable - // - // ************************ - - public KnativeConfiguration copy() { - try { - return (KnativeConfiguration)super.clone(); - } catch (CloneNotSupportedException e) { - throw new RuntimeCamelException(e); - } - } -} diff --git a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConversionProcessor.java b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConversionProcessor.java deleted file mode 100644 index 6ff5830a36..0000000000 --- a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConversionProcessor.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.apache.camel.component.knative; - -import org.apache.camel.Exchange; -import org.apache.camel.Processor; - -/** - * Converts objects prior to serializing them to external endpoints or channels - */ -public class KnativeConversionProcessor implements Processor { - - private boolean enabled; - - public KnativeConversionProcessor(boolean enabled) { - this.enabled = enabled; - } - - @Override - public void process(Exchange exchange) throws Exception { - if (enabled) { - Object body = exchange.getIn().getBody(); - if (body != null) { - byte[] newBody = Knative.MAPPER.writeValueAsBytes(body); - exchange.getIn().setBody(newBody); - exchange.getIn().setHeader("CE-ContentType", "application/json"); - } - } - } -} diff --git a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java deleted file mode 100644 index cceb218e6a..0000000000 --- a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java +++ /dev/null @@ -1,212 +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.component.knative; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.Consumer; -import org.apache.camel.DelegateEndpoint; -import org.apache.camel.Endpoint; -import org.apache.camel.Processor; -import org.apache.camel.Producer; -import org.apache.camel.cloud.ServiceDefinition; -import org.apache.camel.component.knative.ce.CloudEventsProcessors; -import org.apache.camel.impl.DefaultEndpoint; -import org.apache.camel.processor.Pipeline; -import org.apache.camel.spi.Metadata; -import org.apache.camel.spi.UriEndpoint; -import org.apache.camel.spi.UriParam; -import org.apache.camel.spi.UriPath; -import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.ServiceHelper; -import org.apache.camel.util.StringHelper; -import org.apache.camel.util.URISupport; - - -@UriEndpoint( - firstVersion = "3.0.0", - scheme = "knative", - syntax = "knative:type/target", - title = "Knative", - label = "cloud,eventing") -public class KnativeEndpoint extends DefaultEndpoint implements DelegateEndpoint { - @UriPath(description = "The Knative type") - @Metadata(required = "true") - private final Knative.Type type; - - @UriPath(description = "The Knative name") - @Metadata(required = "true") - private final String name; - - @UriParam - private final KnativeConfiguration configuration; - - private final KnativeEnvironment environment; - private final KnativeEnvironment.KnativeServiceDefinition service; - private final Endpoint endpoint; - - public KnativeEndpoint(String uri, KnativeComponent component, Knative.Type targetType, String remaining, KnativeConfiguration configuration) { - super(uri, component); - - this.type = targetType; - this.name = remaining.indexOf('/') != -1 ? StringHelper.before(remaining, "/") : remaining; - this.configuration = configuration; - this.environment = this.configuration.getEnvironment(); - this.service = this.environment.lookupServiceOrDefault(targetType, remaining); - - switch (service.getProtocol()) { - case http: - case https: - this.endpoint = http(component.getCamelContext(), service); - break; - default: - throw new IllegalArgumentException("unsupported protocol: " + this.service.getProtocol()); - } - } - - @Override - protected void doStart() throws Exception { - super.doStart(); - ServiceHelper.startService(endpoint); - } - - @Override - protected void doStop() throws Exception { - ServiceHelper.stopService(endpoint); - super.doStop(); - } - - @Override - public KnativeComponent getComponent() { - return (KnativeComponent) super.getComponent(); - } - - @Override - public Producer createProducer() throws Exception { - final String version = configuration.getCloudEventsSpecVersion(); - final Processor ceProcessor = CloudEventsProcessors.forSpecversion(version).producerProcessor(this); - final Processor ceConverter = new KnativeConversionProcessor(configuration.isJsonSerializationEnabled()); - - return new KnativeProducer(this, ceProcessor, ceConverter, endpoint.createProducer()); - } - - @Override - public Consumer createConsumer(Processor processor) throws Exception { - final String version = configuration.getCloudEventsSpecVersion(); - final Processor ceProcessor = CloudEventsProcessors.forSpecversion(version).consumerProcessor(this); - final Processor pipeline = Pipeline.newInstance(getCamelContext(), ceProcessor, processor); - final Consumer consumer = endpoint.createConsumer(pipeline); - - configureConsumer(consumer); - - return consumer; - } - - @Override - public boolean isSingleton() { - return true; - } - - @Override - public Endpoint getEndpoint() { - return this.endpoint; - } - - public Knative.Type getType() { - return type; - } - - public String getName() { - return name; - } - - public KnativeEnvironment.KnativeServiceDefinition getService() { - return service; - } - - // ***************************** - // - // Helpers - // - // ***************************** - - private static Endpoint http(CamelContext context, ServiceDefinition definition) { - try { - final String scheme = Knative.HTTP_COMPONENT; - final String protocol = definition.getMetadata().getOrDefault(Knative.KNATIVE_PROTOCOL, "http"); - - String host = definition.getHost(); - int port = definition.getPort(); - - if (ObjectHelper.isEmpty(host)) { - String name = definition.getName(); - String zone = definition.getMetadata().get(ServiceDefinition.SERVICE_META_ZONE); - - if (ObjectHelper.isNotEmpty(zone)) { - try { - zone = context.resolvePropertyPlaceholders(zone); - } catch (IllegalArgumentException e) { - zone = null; - } - } - if (ObjectHelper.isNotEmpty(zone)) { - name = name + "." + zone; - } - - host = name; - } - - ObjectHelper.notNull(host, ServiceDefinition.SERVICE_META_HOST); - ObjectHelper.notNull(protocol, Knative.KNATIVE_PROTOCOL); - - String uri = String.format("%s:%s://%s", scheme, protocol, host); - if (port != -1) { - uri = uri + ":" + port; - } - - String path = definition.getMetadata().get(ServiceDefinition.SERVICE_META_PATH); - if (path != null) { - if (!path.startsWith("/")) { - uri += "/"; - } - - uri += path; - } - - final String filterKey = definition.getMetadata().get(Knative.FILTER_HEADER_NAME); - final String filterVal = definition.getMetadata().get(Knative.FILTER_HEADER_VALUE); - final Map parameters = new HashMap<>(); - - if (ObjectHelper.isNotEmpty(filterKey) && ObjectHelper.isNotEmpty(filterVal)) { - parameters.put("filter.headerName", filterKey); - parameters.put("filter.headerValue", filterVal); - } - - // configure netty to use relative path instead of full - // path that is the default to make istio working - parameters.put("useRelativePath", "true"); - - uri = URISupport.appendParametersToURI(uri, parameters); - - return context.getEndpoint(uri); - } catch (Exception e) { - throw ObjectHelper.wrapRuntimeCamelException(e); - } - } -} diff --git a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEnvironment.java b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEnvironment.java deleted file mode 100644 index efef0ca790..0000000000 --- a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEnvironment.java +++ /dev/null @@ -1,210 +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.component.knative; - -import java.io.InputStream; -import java.io.Reader; -import java.io.StringReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; -import java.util.stream.Stream; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.camel.CamelContext; -import org.apache.camel.cloud.ServiceDefinition; -import org.apache.camel.impl.cloud.DefaultServiceDefinition; -import org.apache.camel.util.CollectionHelper; -import org.apache.camel.util.ResourceHelper; -import org.apache.camel.util.StringHelper; - -/* - * Assuming it is loaded from a json for now - */ -public class KnativeEnvironment { - private final List services; - - @JsonCreator - public KnativeEnvironment( - @JsonProperty(value = "services", required = true) List services) { - - this.services = new ArrayList<>(services); - } - - public Stream stream() { - return services.stream(); - } - - public Optional lookupService(Knative.Type type, String name) { - final String contextPath = StringHelper.after(name, "/"); - final String serviceName = (contextPath == null) ? name : StringHelper.before(name, "/"); - - return services.stream() - .filter(definition -> { - return Objects.equals(type.name(), definition.getMetadata().get(Knative.KNATIVE_TYPE)) - && Objects.equals(serviceName, definition.getName()); - }) - .map(definition -> { - // - // The context path set on the endpoint overrides the one - // eventually provided by the service definition. - // - if (contextPath != null) { - return new KnativeServiceDefinition( - definition.getType(), - definition.getProtocol(), - definition.getName(), - definition.getHost(), - definition.getPort(), - KnativeSupport.mergeMaps( - definition.getMetadata(), - Collections.singletonMap(ServiceDefinition.SERVICE_META_PATH, "/" + contextPath) - ) - ); - } - - return definition; - }) - .findFirst(); - } - - public KnativeServiceDefinition mandatoryLookupService(Knative.Type type, String name) { - return lookupService(type, name).orElseThrow( - () -> new IllegalArgumentException("Unable to find the service \"" + name + "\" with type \"" + type + "\"") - ); - } - - - public KnativeServiceDefinition lookupServiceOrDefault(Knative.Type type, String name) { - return lookupService(type, name).orElseGet(() -> { - String contextPath = StringHelper.after(name, "/"); - String serviceName = (contextPath == null) ? name : StringHelper.before(name, "/"); - Map meta = new HashMap<>(); - - if (type == Knative.Type.channel && !serviceName.endsWith(".channel")) { - serviceName += "-channel"; - - } - if (contextPath != null) { - meta.put(ServiceDefinition.SERVICE_META_PATH, "/" + contextPath); - } - - return new KnativeEnvironment.KnativeServiceDefinition( - type, - Knative.Protocol.http, - serviceName, - "", - -1, - meta - ); - }); - } - - // ************************ - // - // Helpers - // - // ************************ - - public static KnativeEnvironment mandatoryLoadFromSerializedString(CamelContext context, String configuration) throws Exception { - try (Reader reader = new StringReader(configuration)) { - return Knative.MAPPER.readValue(reader, KnativeEnvironment.class); - } - } - - public static KnativeEnvironment mandatoryLoadFromResource(CamelContext context, String path) throws Exception { - try (InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, path)) { - - // - // read the knative environment from a file formatted as json, i.e. : - // - // { - // "services": [ - // { - // "type": "channel|endpoint", - // "protocol": "http", - // "name": "", - // "host": "", - // "port": "", - // "metadata": { - // "service.path": "", - // "knative.event.type": "", - // "filter.header.name": "", - // "filter.header.value": "" - // } - // }, - // ] - // } - // - // - return Knative.MAPPER.readValue(is, KnativeEnvironment.class); - } - } - - // ************************ - // - // Types - // - // ************************ - - public final static class KnativeServiceDefinition extends DefaultServiceDefinition { - @JsonCreator - public KnativeServiceDefinition( - @JsonProperty(value = "type", required = true) Knative.Type type, - @JsonProperty(value = "protocol", required = true) Knative.Protocol protocol, - @JsonProperty(value = "name", required = true) String name, - @JsonProperty(value = "host", required = true) String host, - @JsonProperty(value = "port", required = true) int port, - @JsonProperty(value = "metadata", required = false) Map metadata) { - - super( - UUID.randomUUID().toString(), - name, - host, - port, - KnativeSupport.mergeMaps( - metadata, - CollectionHelper.mapOf( - Knative.KNATIVE_TYPE, type.name(), - Knative.KNATIVE_PROTOCOL, protocol.name()) - ) - ); - } - - public Knative.Type getType() { - return Knative.Type.valueOf(getMetadata().get(Knative.KNATIVE_TYPE)); - } - - public Knative.Protocol getProtocol() { - return Knative.Protocol.valueOf(getMetadata().get(Knative.KNATIVE_PROTOCOL)); - } - - public String getPath() { - return getMetadata().get(ServiceDefinition.SERVICE_META_PATH); - } - - public String getEventType() { - return getMetadata().get(Knative.KNATIVE_EVENT_TYPE); - } - } -} diff --git a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeProducer.java b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeProducer.java deleted file mode 100644 index 740455f87f..0000000000 --- a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeProducer.java +++ /dev/null @@ -1,79 +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.component.knative; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.camel.AsyncCallback; -import org.apache.camel.AsyncProcessor; -import org.apache.camel.Endpoint; -import org.apache.camel.Exchange; -import org.apache.camel.Processor; -import org.apache.camel.impl.DefaultAsyncProducer; -import org.apache.camel.processor.Pipeline; -import org.apache.camel.util.AsyncProcessorConverterHelper; -import org.apache.camel.util.ServiceHelper; -import org.apache.commons.collections4.CollectionUtils; - -public class KnativeProducer extends DefaultAsyncProducer { - final AsyncProcessor processor; - - public KnativeProducer(Endpoint endpoint, Processor processor, Processor... processors) { - super(endpoint); - - List elements = new ArrayList<>(1 + processors.length); - - CollectionUtils.addAll(elements, processor); - CollectionUtils.addAll(elements, processors); - - Processor pipeline = Pipeline.newInstance(endpoint.getCamelContext(), elements); - - this.processor = AsyncProcessorConverterHelper.convert(pipeline); - } - - @Override - public boolean process(Exchange exchange, AsyncCallback callback) { - return processor.process(exchange, callback); - } - - @Override - protected void doStart() throws Exception { - ServiceHelper.startServices(processor); - } - - @Override - protected void doStop() throws Exception { - ServiceHelper.stopServices(processor); - } - - @Override - protected void doSuspend() throws Exception { - ServiceHelper.suspendService(processor); - } - - @Override - protected void doResume() throws Exception { - ServiceHelper.resumeService(processor); - } - - @Override - protected void doShutdown() throws Exception { - ServiceHelper.stopAndShutdownServices(processor); - } - -} diff --git a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeSupport.java b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeSupport.java deleted file mode 100644 index 9c6c049a03..0000000000 --- a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeSupport.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.component.knative; - -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -import org.apache.camel.Exchange; - -public final class KnativeSupport { - private KnativeSupport() { - } - - public static boolean hasStructuredContent(Exchange exchange) { - return Objects.equals(exchange.getIn().getHeader(Exchange.CONTENT_TYPE), Knative.MIME_STRUCTURED_CONTENT_MODE); - } - - public static Map mergeMaps(Map map, Map... maps) { - Map answer = new HashMap<>(); - - if (map != null) { - answer.putAll(map); - } - - for (Map m : maps) { - answer.putAll(m); - } - - return answer; - } -} diff --git a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/ce/CloudEventsProcessors.java b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/ce/CloudEventsProcessors.java deleted file mode 100644 index 49ebee4da3..0000000000 --- a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/ce/CloudEventsProcessors.java +++ /dev/null @@ -1,65 +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.component.knative.ce; - -import java.util.function.Function; - -import org.apache.camel.Processor; -import org.apache.camel.component.knative.KnativeEndpoint; - -public enum CloudEventsProcessors { - v01("0.1", V01.PRODUCER, V01.CONSUMER), - v02("0.2", V02.PRODUCER, V02.CONSUMER); - - private final String version; - private final Function producer; - private final Function consumer; - - CloudEventsProcessors(String version, Function producer, Function consumer) { - this.version = version; - this.producer = producer; - this.consumer = consumer; - } - - public String getVersion() { - return version; - } - - public Processor producerProcessor(KnativeEndpoint endpoint) { - return this.producer.apply(endpoint); - } - - public Processor consumerProcessor(KnativeEndpoint endpoint) { - return this.consumer.apply(endpoint); - } - - // ************************** - // - // Helpers - // - // ************************** - - public static CloudEventsProcessors forSpecversion(String version) { - for (CloudEventsProcessors ce : CloudEventsProcessors.values()) { - if (ce.version.equals(version)) { - return ce; - } - } - - throw new IllegalArgumentException("Unable to find processors for spec version: " + version); - } -} diff --git a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/ce/V01.java b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/ce/V01.java deleted file mode 100644 index 4505d8ecf9..0000000000 --- a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/ce/V01.java +++ /dev/null @@ -1,102 +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.component.knative.ce; - -import java.io.InputStream; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Map; -import java.util.function.Function; - -import org.apache.camel.Exchange; -import org.apache.camel.Message; -import org.apache.camel.Processor; -import org.apache.camel.component.knative.Knative; -import org.apache.camel.component.knative.KnativeEndpoint; -import org.apache.camel.component.knative.KnativeEnvironment; -import org.apache.camel.component.knative.KnativeSupport; -import org.apache.commons.lang3.StringUtils; - -import static org.apache.camel.util.ObjectHelper.ifNotEmpty; - -final class V01 { - private V01() { - } - - public static final Function PRODUCER = (KnativeEndpoint endpoint) -> { - KnativeEnvironment.KnativeServiceDefinition service = endpoint.getService(); - String uri = endpoint.getEndpointUri(); - - return exchange -> { - final String eventType = service.getMetadata().get(Knative.KNATIVE_EVENT_TYPE); - final String contentType = service.getMetadata().get(Knative.CONTENT_TYPE); - final ZonedDateTime created = exchange.getCreated().toInstant().atZone(ZoneId.systemDefault()); - final String eventTime = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(created); - final Map headers = exchange.getIn().getHeaders(); - - headers.putIfAbsent("CE-CloudEventsVersion", "0.1"); - headers.putIfAbsent("CE-EventType", eventType); - headers.putIfAbsent("CE-EventID", exchange.getExchangeId()); - headers.putIfAbsent("CE-EventTime", eventTime); - headers.putIfAbsent("CE-Source", uri); - headers.putIfAbsent(Exchange.CONTENT_TYPE, contentType); - - // Always remove host so it's always computed from the URL and not inherited from the exchange - headers.remove("Host"); - }; - }; - - public static final Function CONSUMER = (KnativeEndpoint endpoint) -> { - return exchange -> { - if (!KnativeSupport.hasStructuredContent(exchange)) { - // - // The event is not in the form of Structured Content Mode - // then leave it as it is. - // - // Note that this is true for http binding only. - // - // More info: - // - // https://github.com/cloudevents/spec/blob/master/http-transport-binding.md#32-structured-content-mode - // - return; - } - - try (InputStream is = exchange.getIn().getBody(InputStream.class)) { - final Message message = exchange.getIn(); - final Map ce = Knative.MAPPER.readValue(is, Map.class); - - ifNotEmpty(ce.remove("contentType"), val -> message.setHeader(Exchange.CONTENT_TYPE, val)); - ifNotEmpty(ce.remove("data"), val -> message.setBody(val)); - - // - // Map extensions to standard camel headers - // - ifNotEmpty(ce.remove("extensions"), val -> { - if (val instanceof Map) { - ((Map) val).forEach(message::setHeader); - } - }); - - ce.forEach((key, val) -> { - message.setHeader("CE-" + StringUtils.capitalize(key), val); - }); - } - }; - }; -} diff --git a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/ce/V02.java b/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/ce/V02.java deleted file mode 100644 index 321c502983..0000000000 --- a/runtime/camel-knative/src/main/java/org/apache/camel/component/knative/ce/V02.java +++ /dev/null @@ -1,102 +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.component.knative.ce; - -import java.io.InputStream; -import java.time.ZoneId; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Map; -import java.util.function.Function; - -import org.apache.camel.Exchange; -import org.apache.camel.Message; -import org.apache.camel.Processor; -import org.apache.camel.component.knative.Knative; -import org.apache.camel.component.knative.KnativeEndpoint; -import org.apache.camel.component.knative.KnativeEnvironment; -import org.apache.camel.component.knative.KnativeSupport; -import org.apache.commons.lang3.StringUtils; - -import static org.apache.camel.util.ObjectHelper.ifNotEmpty; - -final class V02 { - private V02() { - } - - public static final Function PRODUCER = (KnativeEndpoint endpoint) -> { - KnativeEnvironment.KnativeServiceDefinition service = endpoint.getService(); - String uri = endpoint.getEndpointUri(); - - return exchange -> { - final String eventType = service.getMetadata().get(Knative.KNATIVE_EVENT_TYPE); - final String contentType = service.getMetadata().get(Knative.CONTENT_TYPE); - final ZonedDateTime created = exchange.getCreated().toInstant().atZone(ZoneId.systemDefault()); - final String eventTime = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(created); - final Map headers = exchange.getIn().getHeaders(); - - headers.putIfAbsent("ce-specversion", "0.2"); - headers.putIfAbsent("ce-type", eventType); - headers.putIfAbsent("ce-id", exchange.getExchangeId()); - headers.putIfAbsent("ce-time", eventTime); - headers.putIfAbsent("ce-source", uri); - headers.putIfAbsent(Exchange.CONTENT_TYPE, contentType); - - // Always remove host so it's always computed from the URL and not inherited from the exchange - headers.remove("Host"); - }; - }; - - public static final Function CONSUMER = (KnativeEndpoint endpoint) -> { - return exchange -> { - if (!KnativeSupport.hasStructuredContent(exchange)) { - // - // The event is not in the form of Structured Content Mode - // then leave it as it is. - // - // Note that this is true for http binding only. - // - // More info: - // - // https://github.com/cloudevents/spec/blob/master/http-transport-binding.md#32-structured-content-mode - // - return; - } - - try (InputStream is = exchange.getIn().getBody(InputStream.class)) { - final Message message = exchange.getIn(); - final Map ce = Knative.MAPPER.readValue(is, Map.class); - - ifNotEmpty(ce.remove("contentType"), val -> message.setHeader(Exchange.CONTENT_TYPE, val)); - ifNotEmpty(ce.remove("data"), val -> message.setBody(val)); - - // - // Map extensions to standard camel headers - // - ifNotEmpty(ce.remove("extensions"), val -> { - if (val instanceof Map) { - ((Map) val).forEach(message::setHeader); - } - }); - - ce.forEach((key, val) -> { - message.setHeader("ce-" + StringUtils.lowerCase(key), val); - }); - } - }; - }; -} diff --git a/runtime/camel-knative/src/main/resources/META-INF/LICENSE.txt b/runtime/camel-knative/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index 6b0b1270ff..0000000000 --- a/runtime/camel-knative/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,203 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. - diff --git a/runtime/camel-knative/src/main/resources/META-INF/NOTICE.txt b/runtime/camel-knative/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf2e6..0000000000 --- a/runtime/camel-knative/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. diff --git a/runtime/camel-knative/src/main/resources/META-INF/services/org/apache/camel/component/knative b/runtime/camel-knative/src/main/resources/META-INF/services/org/apache/camel/component/knative deleted file mode 100644 index 3d6881258b..0000000000 --- a/runtime/camel-knative/src/main/resources/META-INF/services/org/apache/camel/component/knative +++ /dev/null @@ -1,18 +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. -# - -class=org.apache.camel.component.knative.KnativeComponent \ No newline at end of file diff --git a/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/CloudEventsV01Test.java b/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/CloudEventsV01Test.java deleted file mode 100644 index f5a9eccab7..0000000000 --- a/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/CloudEventsV01Test.java +++ /dev/null @@ -1,349 +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.component.knative; - -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Arrays; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.cloud.ServiceDefinition; -import org.apache.camel.component.knative.ce.CloudEventsProcessors; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.test.AvailablePortFinder; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.apache.camel.util.CollectionHelper.mapOf; - -public class CloudEventsV01Test { - - private CamelContext context; - - // ************************** - // - // Setup - // - // ************************** - - @BeforeEach - public void before() { - this.context = new DefaultCamelContext(); - } - - @AfterEach - public void after() throws Exception { - if (this.context != null) { - this.context.stop(); - } - } - - // ************************** - // - // Tests - // - // ************************** - - @Test - void testInvokeEndpoint() throws Exception { - final int port = AvailablePortFinder.getNextAvailable(); - - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "localhost", - port, - mapOf( - ServiceDefinition.SERVICE_META_PATH, "/a/path", - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain" - )) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setCloudEventsSpecVersion(CloudEventsProcessors.v01.getVersion()); - component.setEnvironment(env); - - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:source") - .to("knative:endpoint/myEndpoint"); - - fromF("netty4-http:http://localhost:%d/a/path", port) - .to("mock:ce"); - } - }); - - context.start(); - - MockEndpoint mock = context.getEndpoint("mock:ce", MockEndpoint.class); - mock.expectedMessageCount(1); - mock.expectedHeaderReceived("CE-CloudEventsVersion", CloudEventsProcessors.v01.getVersion()); - mock.expectedHeaderReceived("CE-EventType", "org.apache.camel.event"); - mock.expectedHeaderReceived("CE-Source", "knative://endpoint/myEndpoint"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, "text/plain"); - mock.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("CE-EventTime")); - mock.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("CE-EventID")); - mock.expectedBodiesReceived("test"); - - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setBody("test"); - } - ); - - mock.assertIsSatisfied(); - } - - @Test - void testConsumeStructuredContent() throws Exception { - final int port = AvailablePortFinder.getNextAvailable(); - - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "localhost", - port, - mapOf( - ServiceDefinition.SERVICE_META_PATH, "/a/path", - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain" - )) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setCloudEventsSpecVersion(CloudEventsProcessors.v01.getVersion()); - component.setEnvironment(env); - - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("knative:endpoint/myEndpoint") - .to("mock:ce"); - - from("direct:source") - .toF("netty4-http:http://localhost:%d/a/path", port); - } - }); - - context.start(); - - MockEndpoint mock = context.getEndpoint("mock:ce", MockEndpoint.class); - mock.expectedMessageCount(1); - mock.expectedHeaderReceived("CE-CloudEventsVersion", CloudEventsProcessors.v01.getVersion()); - mock.expectedHeaderReceived("CE-EventType", "org.apache.camel.event"); - mock.expectedHeaderReceived("CE-EventID", "myEventID"); - mock.expectedHeaderReceived("CE-Source", "/somewhere"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, Knative.MIME_STRUCTURED_CONTENT_MODE); - mock.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("CE-EventTime")); - mock.expectedBodiesReceived("test"); - - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setHeader(Exchange.CONTENT_TYPE, Knative.MIME_STRUCTURED_CONTENT_MODE); - e.getIn().setBody(new ObjectMapper().writeValueAsString(mapOf( - "cloudEventsVersion", CloudEventsProcessors.v01.getVersion(), - "eventType", "org.apache.camel.event", - "eventID", "myEventID", - "eventTime", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now()), - "source", "/somewhere", - "data", "test" - ))); - } - ); - - mock.assertIsSatisfied(); - } - - @Test - void testConsumeContent() throws Exception { - final int port = AvailablePortFinder.getNextAvailable(); - - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "localhost", - port, - mapOf( - ServiceDefinition.SERVICE_META_PATH, "/a/path", - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain" - )) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setCloudEventsSpecVersion(CloudEventsProcessors.v01.getVersion()); - component.setEnvironment(env); - - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("knative:endpoint/myEndpoint") - .to("mock:ce"); - - from("direct:source") - .toF("http4://localhost:%d/a/path", port); - } - }); - - context.start(); - - MockEndpoint mock = context.getEndpoint("mock:ce", MockEndpoint.class); - mock.expectedMessageCount(1); - mock.expectedHeaderReceived("CE-CloudEventsVersion", CloudEventsProcessors.v01.getVersion()); - mock.expectedHeaderReceived("CE-EventType", "org.apache.camel.event"); - mock.expectedHeaderReceived("CE-EventID", "myEventID"); - mock.expectedHeaderReceived("CE-Source", "/somewhere"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, "text/plain"); - mock.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("CE-EventTime")); - mock.expectedBodiesReceived("test"); - - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setHeader(Exchange.CONTENT_TYPE, "text/plain"); - e.getIn().setHeader("CE-CloudEventsVersion", CloudEventsProcessors.v01.getVersion()); - e.getIn().setHeader("CE-EventType", "org.apache.camel.event"); - e.getIn().setHeader("CE-EventID", "myEventID"); - e.getIn().setHeader("CE-EventTime", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now())); - e.getIn().setHeader("CE-Source", "/somewhere"); - e.getIn().setBody("test"); - } - ); - - mock.assertIsSatisfied(); - } - - @Test - void testConsumeContentWithFilter() throws Exception { - final int port = AvailablePortFinder.getNextAvailable(); - - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "ep1", - "localhost", - port, - mapOf( - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain", - Knative.FILTER_HEADER_NAME, "CE-Source", - Knative.FILTER_HEADER_VALUE, "CE1" - )), - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "ep2", - "localhost", - port, - mapOf( - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain", - Knative.FILTER_HEADER_NAME, "CE-Source", - Knative.FILTER_HEADER_VALUE, "CE2" - )) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setCloudEventsSpecVersion(CloudEventsProcessors.v01.getVersion()); - component.setEnvironment(env); - - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("knative:endpoint/ep1") - .convertBodyTo(String.class) - .to("log:ce1?showAll=true&multiline=true") - .to("mock:ce1"); - from("knative:endpoint/ep2") - .convertBodyTo(String.class) - .to("log:ce2?showAll=true&multiline=true") - .to("mock:ce2"); - - from("direct:source") - .setBody() - .constant("test") - .setHeader(Exchange.HTTP_METHOD) - .constant("POST") - .setHeader(Exchange.HTTP_QUERY) - .simple("filter.headerName=CE-Source&filter.headerValue=${header.FilterVal}") - .toD("http4://localhost:" + port); - } - }); - - context.start(); - - MockEndpoint mock1 = context.getEndpoint("mock:ce1", MockEndpoint.class); - mock1.expectedMessageCount(1); - mock1.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("CE-EventTime")); - mock1.expectedHeaderReceived("CE-CloudEventsVersion", CloudEventsProcessors.v01.getVersion()); - mock1.expectedHeaderReceived("CE-EventType", "org.apache.camel.event"); - mock1.expectedHeaderReceived("CE-EventID", "myEventID1"); - mock1.expectedHeaderReceived("CE-Source", "CE1"); - mock1.expectedBodiesReceived("test"); - - MockEndpoint mock2 = context.getEndpoint("mock:ce2", MockEndpoint.class); - mock2.expectedMessageCount(1); - mock2.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("CE-EventTime")); - mock2.expectedHeaderReceived("CE-CloudEventsVersion", CloudEventsProcessors.v01.getVersion()); - mock2.expectedHeaderReceived("CE-EventType", "org.apache.camel.event"); - mock2.expectedHeaderReceived("CE-EventID", "myEventID2"); - mock2.expectedHeaderReceived("CE-Source", "CE2"); - mock2.expectedBodiesReceived("test"); - - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setHeader("FilterVal", "CE1"); - e.getIn().setHeader("CE-CloudEventsVersion", CloudEventsProcessors.v01.getVersion()); - e.getIn().setHeader("CE-EventType", "org.apache.camel.event"); - e.getIn().setHeader("CE-EventID", "myEventID1"); - e.getIn().setHeader("CE-EventTime", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now())); - e.getIn().setHeader("CE-Source", "CE1"); - } - ); - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setHeader("FilterVal", "CE2"); - e.getIn().setHeader("CE-CloudEventsVersion", CloudEventsProcessors.v01.getVersion()); - e.getIn().setHeader("CE-EventType", "org.apache.camel.event"); - e.getIn().setHeader("CE-EventID", "myEventID2"); - e.getIn().setHeader("CE-EventTime", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now())); - e.getIn().setHeader("CE-Source", "CE2"); - } - ); - - mock1.assertIsSatisfied(); - mock2.assertIsSatisfied(); - } -} diff --git a/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/CloudEventsV02Test.java b/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/CloudEventsV02Test.java deleted file mode 100644 index 3c32915cb7..0000000000 --- a/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/CloudEventsV02Test.java +++ /dev/null @@ -1,349 +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.component.knative; - -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Arrays; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.cloud.ServiceDefinition; -import org.apache.camel.component.knative.ce.CloudEventsProcessors; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.test.AvailablePortFinder; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.apache.camel.util.CollectionHelper.mapOf; - -public class CloudEventsV02Test { - - private CamelContext context; - - // ************************** - // - // Setup - // - // ************************** - - @BeforeEach - public void before() { - this.context = new DefaultCamelContext(); - } - - @AfterEach - public void after() throws Exception { - if (this.context != null) { - this.context.stop(); - } - } - - // ************************** - // - // Tests - // - // ************************** - - @Test - void testInvokeEndpoint() throws Exception { - final int port = AvailablePortFinder.getNextAvailable(); - - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "localhost", - port, - mapOf( - ServiceDefinition.SERVICE_META_PATH, "/a/path", - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain" - )) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setCloudEventsSpecVersion(CloudEventsProcessors.v02.getVersion()); - component.setEnvironment(env); - - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:source") - .to("knative:endpoint/myEndpoint"); - - fromF("netty4-http:http://localhost:%d/a/path", port) - .to("mock:ce"); - } - }); - - context.start(); - - MockEndpoint mock = context.getEndpoint("mock:ce", MockEndpoint.class); - mock.expectedMessageCount(1); - mock.expectedHeaderReceived("ce-specversion", CloudEventsProcessors.v02.getVersion()); - mock.expectedHeaderReceived("ce-type", "org.apache.camel.event"); - mock.expectedHeaderReceived("ce-source", "knative://endpoint/myEndpoint"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, "text/plain"); - mock.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("ce-time")); - mock.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("ce-id")); - mock.expectedBodiesReceived("test"); - - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setBody("test"); - } - ); - - mock.assertIsSatisfied(); - } - - @Test - void testConsumeStructuredContent() throws Exception { - final int port = AvailablePortFinder.getNextAvailable(); - - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "localhost", - port, - mapOf( - ServiceDefinition.SERVICE_META_PATH, "/a/path", - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain" - )) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setCloudEventsSpecVersion(CloudEventsProcessors.v02.getVersion()); - component.setEnvironment(env); - - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("knative:endpoint/myEndpoint") - .to("mock:ce"); - - from("direct:source") - .toF("netty4-http:http://localhost:%d/a/path", port); - } - }); - - context.start(); - - MockEndpoint mock = context.getEndpoint("mock:ce", MockEndpoint.class); - mock.expectedMessageCount(1); - mock.expectedHeaderReceived("ce-specversion", CloudEventsProcessors.v02.getVersion()); - mock.expectedHeaderReceived("ce-type", "org.apache.camel.event"); - mock.expectedHeaderReceived("ce-id", "myEventID"); - mock.expectedHeaderReceived("ce-source", "/somewhere"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, Knative.MIME_STRUCTURED_CONTENT_MODE); - mock.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("ce-time")); - mock.expectedBodiesReceived("test"); - - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setHeader(Exchange.CONTENT_TYPE, Knative.MIME_STRUCTURED_CONTENT_MODE); - e.getIn().setBody(new ObjectMapper().writeValueAsString(mapOf( - "specversion", CloudEventsProcessors.v02.getVersion(), - "type", "org.apache.camel.event", - "id", "myEventID", - "time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now()), - "source", "/somewhere", - "data", "test" - ))); - } - ); - - mock.assertIsSatisfied(); - } - - @Test - void testConsumeContent() throws Exception { - final int port = AvailablePortFinder.getNextAvailable(); - - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "localhost", - port, - mapOf( - ServiceDefinition.SERVICE_META_PATH, "/a/path", - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain" - )) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setCloudEventsSpecVersion(CloudEventsProcessors.v02.getVersion()); - component.setEnvironment(env); - - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("knative:endpoint/myEndpoint") - .to("mock:ce"); - - from("direct:source") - .toF("http4://localhost:%d/a/path", port); - } - }); - - context.start(); - - MockEndpoint mock = context.getEndpoint("mock:ce", MockEndpoint.class); - mock.expectedMessageCount(1); - mock.expectedHeaderReceived("ce-specversion", CloudEventsProcessors.v02.getVersion()); - mock.expectedHeaderReceived("ce-type", "org.apache.camel.event"); - mock.expectedHeaderReceived("ce-id", "myEventID"); - mock.expectedHeaderReceived("ce-source", "/somewhere"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, "text/plain"); - mock.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("ce-time")); - mock.expectedBodiesReceived("test"); - - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setHeader(Exchange.CONTENT_TYPE, "text/plain"); - e.getIn().setHeader("ce-specversion", CloudEventsProcessors.v02.getVersion()); - e.getIn().setHeader("ce-type", "org.apache.camel.event"); - e.getIn().setHeader("ce-id", "myEventID"); - e.getIn().setHeader("ce-time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now())); - e.getIn().setHeader("ce-source", "/somewhere"); - e.getIn().setBody("test"); - } - ); - - mock.assertIsSatisfied(); - } - - @Test - void testConsumeContentWithFilter() throws Exception { - final int port = AvailablePortFinder.getNextAvailable(); - - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "ep1", - "localhost", - port, - mapOf( - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain", - Knative.FILTER_HEADER_NAME, "ce-source", - Knative.FILTER_HEADER_VALUE, "CE1" - )), - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "ep2", - "localhost", - port, - mapOf( - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain", - Knative.FILTER_HEADER_NAME, "ce-source", - Knative.FILTER_HEADER_VALUE, "CE2" - )) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setCloudEventsSpecVersion(CloudEventsProcessors.v02.getVersion()); - component.setEnvironment(env); - - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("knative:endpoint/ep1") - .convertBodyTo(String.class) - .to("log:ce1?showAll=true&multiline=true") - .to("mock:ce1"); - from("knative:endpoint/ep2") - .convertBodyTo(String.class) - .to("log:ce2?showAll=true&multiline=true") - .to("mock:ce2"); - - from("direct:source") - .setBody() - .constant("test") - .setHeader(Exchange.HTTP_METHOD) - .constant("POST") - .setHeader(Exchange.HTTP_QUERY) - .simple("filter.headerName=ce-source&filter.headerValue=${header.FilterVal}") - .toD("http4://localhost:" + port); - } - }); - - context.start(); - - MockEndpoint mock1 = context.getEndpoint("mock:ce1", MockEndpoint.class); - mock1.expectedMessageCount(1); - mock1.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("ce-time")); - mock1.expectedHeaderReceived("ce-specversion", CloudEventsProcessors.v02.getVersion()); - mock1.expectedHeaderReceived("ce-type", "org.apache.camel.event"); - mock1.expectedHeaderReceived("ce-id", "myEventID1"); - mock1.expectedHeaderReceived("ce-source", "CE1"); - mock1.expectedBodiesReceived("test"); - - MockEndpoint mock2 = context.getEndpoint("mock:ce2", MockEndpoint.class); - mock2.expectedMessageCount(1); - mock2.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("ce-time")); - mock2.expectedHeaderReceived("ce-specversion", CloudEventsProcessors.v02.getVersion()); - mock2.expectedHeaderReceived("ce-type", "org.apache.camel.event"); - mock2.expectedHeaderReceived("ce-id", "myEventID2"); - mock2.expectedHeaderReceived("ce-source", "CE2"); - mock2.expectedBodiesReceived("test"); - - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setHeader("FilterVal", "CE1"); - e.getIn().setHeader("ce-specversion", CloudEventsProcessors.v02.getVersion()); - e.getIn().setHeader("ce-type", "org.apache.camel.event"); - e.getIn().setHeader("ce-id", "myEventID1"); - e.getIn().setHeader("ce-time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now())); - e.getIn().setHeader("ce-source", "CE1"); - } - ); - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setHeader("FilterVal", "CE2"); - e.getIn().setHeader("ce-specversion", CloudEventsProcessors.v02.getVersion()); - e.getIn().setHeader("ce-type", "org.apache.camel.event"); - e.getIn().setHeader("ce-id", "myEventID2"); - e.getIn().setHeader("ce-time", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now())); - e.getIn().setHeader("ce-source", "CE2"); - } - ); - - mock1.assertIsSatisfied(); - mock2.assertIsSatisfied(); - } -} diff --git a/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java b/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java deleted file mode 100644 index 56f4df387a..0000000000 --- a/runtime/camel-knative/src/test/java/org/apache/camel/component/knative/KnativeComponentTest.java +++ /dev/null @@ -1,585 +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.component.knative; - -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; -import java.util.Arrays; -import java.util.Collections; -import java.util.Properties; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.apache.camel.CamelContext; -import org.apache.camel.Exchange; -import org.apache.camel.builder.RouteBuilder; -import org.apache.camel.cloud.ServiceDefinition; -import org.apache.camel.component.mock.MockEndpoint; -import org.apache.camel.component.netty4.NettyEndpoint; -import org.apache.camel.component.properties.PropertiesComponent; -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.test.AvailablePortFinder; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.apache.camel.component.knative.KnativeEnvironment.mandatoryLoadFromResource; -import static org.apache.camel.util.CollectionHelper.mapOf; -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -public class KnativeComponentTest { - - private CamelContext context; - - // ************************** - // - // Setup - // - // ************************** - - @BeforeEach - public void before() { - this.context = new DefaultCamelContext(); - } - - @AfterEach - public void after() throws Exception { - if (this.context != null) { - this.context.stop(); - } - } - - // ************************** - // - // Tests - // - // ************************** - - @Test - void testLoadEnvironment() throws Exception { - KnativeEnvironment env = mandatoryLoadFromResource(context, "classpath:/environment.json"); - - assertThat(env.stream()).hasSize(2); - assertThat(env.stream()).anyMatch(s -> s.getType() == Knative.Type.channel); - assertThat(env.stream()).anyMatch(s -> s.getType() == Knative.Type.endpoint); - - assertThat(env.lookupService(Knative.Type.channel, "c1")).isPresent(); - assertThat(env.lookupService(Knative.Type.channel, "e1")).isNotPresent(); - assertThat(env.lookupService(Knative.Type.endpoint, "e1")).isPresent(); - assertThat(env.lookupService(Knative.Type.endpoint, "c1")).isNotPresent(); - - assertThatThrownBy(() -> env.mandatoryLookupService(Knative.Type.endpoint, "unknown")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Unable to find the service \"unknown\" with type \"endpoint\""); - - assertThatThrownBy(() -> env.mandatoryLookupService(Knative.Type.channel, "unknown")) - .isInstanceOf(IllegalArgumentException.class) - .hasMessage("Unable to find the service \"unknown\" with type \"channel\""); - } - - @Test - void testCreateComponent() throws Exception { - context.start(); - - assertThat(context.getComponent("knative")).isNotNull(); - assertThat(context.getComponent("knative")).isInstanceOf(KnativeComponent.class); - } - - @Test - void testCreateEndpoint() throws Exception { - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "my-node", - 9001, - mapOf(ServiceDefinition.SERVICE_META_PATH, "/a/path")) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setEnvironment(env); - - context.start(); - - // - // Endpoint with context path derived from service definition - // - - KnativeEndpoint e1 = context.getEndpoint("knative:endpoint/myEndpoint", KnativeEndpoint.class); - - assertThat(e1).isNotNull(); - assertThat(e1.getService()).isNotNull(); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("name", "myEndpoint"); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("host", "my-node"); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("port", 9001); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("type", Knative.Type.endpoint); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("protocol", Knative.Protocol.http); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("path", "/a/path"); - assertThat(e1.getEndpoint()).isInstanceOf(NettyEndpoint.class); - assertThat(e1.getEndpoint()).hasFieldOrPropertyWithValue("endpointUri", "http://my-node:9001/a/path"); - - // - // Endpoint with context path overridden by endpoint uri - // - - KnativeEndpoint e2 = context.getEndpoint("knative:endpoint/myEndpoint/another/path", KnativeEndpoint.class); - - assertThat(e2).isNotNull(); - assertThat(e2.getService()).isNotNull(); - assertThat(e2.getService()).hasFieldOrPropertyWithValue("name", "myEndpoint"); - assertThat(e2.getService()).hasFieldOrPropertyWithValue("host", "my-node"); - assertThat(e2.getService()).hasFieldOrPropertyWithValue("port", 9001); - assertThat(e2.getService()).hasFieldOrPropertyWithValue("type", Knative.Type.endpoint); - assertThat(e2.getService()).hasFieldOrPropertyWithValue("protocol", Knative.Protocol.http); - assertThat(e2.getService()).hasFieldOrPropertyWithValue("path", "/another/path"); - assertThat(e2.getEndpoint()).isInstanceOf(NettyEndpoint.class); - assertThat(e2.getEndpoint()).hasFieldOrPropertyWithValue("endpointUri", "http://my-node:9001/another/path"); - } - - @Test - void testCreateEndpointWithComputedHost() throws Exception { - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "", - -1, - mapOf(ServiceDefinition.SERVICE_META_PATH, "/a/path")) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setEnvironment(env); - - context.start(); - - // - // Endpoint with context path derived from service definition - // - - KnativeEndpoint e1 = context.getEndpoint("knative:endpoint/myEndpoint", KnativeEndpoint.class); - - assertThat(e1).isNotNull(); - assertThat(e1.getService()).isNotNull(); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("name", "myEndpoint"); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("type", Knative.Type.endpoint); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("protocol", Knative.Protocol.http); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("path", "/a/path"); - assertThat(e1.getEndpoint()).isInstanceOf(NettyEndpoint.class); - assertThat(e1.getEndpoint()).hasFieldOrPropertyWithValue("endpointUri", "http://myEndpoint/a/path"); - } - - @Test - void testCreateEndpointWithComputedHostAndNamespace() throws Exception { - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "", - -1, - mapOf( - ServiceDefinition.SERVICE_META_PATH, "/a/path", - ServiceDefinition.SERVICE_META_ZONE, "myNamespace")) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setEnvironment(env); - - context.start(); - - // - // Endpoint with context path derived from service definition - // - - KnativeEndpoint e1 = context.getEndpoint("knative:endpoint/myEndpoint", KnativeEndpoint.class); - - assertThat(e1).isNotNull(); - assertThat(e1.getService()).isNotNull(); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("name", "myEndpoint"); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("type", Knative.Type.endpoint); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("protocol", Knative.Protocol.http); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("path", "/a/path"); - assertThat(e1.getEndpoint()).isInstanceOf(NettyEndpoint.class); - assertThat(e1.getEndpoint()).hasFieldOrPropertyWithValue("endpointUri", "http://myEndpoint.myNamespace/a/path"); - } - - @Test - void testCreateEndpointWithComputedHostAndNamespaceWithProperty() throws Exception { - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "", - -1, - mapOf( - ServiceDefinition.SERVICE_META_PATH, "/a/path", - ServiceDefinition.SERVICE_META_ZONE, "{{myNamespaceKey}}")) - )); - - Properties properties = new Properties(); - properties.setProperty("myNamespaceKey", "myNamespace"); - - PropertiesComponent pc = context.getComponent("properties", PropertiesComponent.class); - pc.setInitialProperties(properties); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setEnvironment(env); - - context.start(); - - // - // Endpoint with context path derived from service definition - // - - KnativeEndpoint e1 = context.getEndpoint("knative:endpoint/myEndpoint", KnativeEndpoint.class); - - assertThat(e1).isNotNull(); - assertThat(e1.getService()).isNotNull(); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("name", "myEndpoint"); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("type", Knative.Type.endpoint); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("protocol", Knative.Protocol.http); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("path", "/a/path"); - assertThat(e1.getEndpoint()).isInstanceOf(NettyEndpoint.class); - assertThat(e1.getEndpoint()).hasFieldOrPropertyWithValue("endpointUri", "http://myEndpoint.myNamespace/a/path"); - } - - @Test - void testCreateEndpointWithDefaults() throws Exception { - KnativeEnvironment env = new KnativeEnvironment(Collections.emptyList()); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setEnvironment(env); - - context.start(); - - // - // Endpoint with context path derived from service definition - // - - KnativeEndpoint e1 = context.getEndpoint("knative:endpoint/myEndpoint/my/path", KnativeEndpoint.class); - - assertThat(e1).isNotNull(); - assertThat(e1.getService()).isNotNull(); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("name", "myEndpoint"); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("type", Knative.Type.endpoint); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("protocol", Knative.Protocol.http); - assertThat(e1.getService()).hasFieldOrPropertyWithValue("path", "/my/path"); - assertThat(e1.getEndpoint()).isInstanceOf(NettyEndpoint.class); - assertThat(e1.getEndpoint()).hasFieldOrPropertyWithValue("endpointUri", "http://myEndpoint/my/path"); - - // - // Endpoint with context path overridden by endpoint uri - // - - KnativeEndpoint e2 = context.getEndpoint("knative:channel/myChannel/another/path", KnativeEndpoint.class); - - assertThat(e2).isNotNull(); - assertThat(e2.getService()).isNotNull(); - assertThat(e2.getService()).hasFieldOrPropertyWithValue("name", "myChannel-channel"); - assertThat(e2.getService()).hasFieldOrPropertyWithValue("type", Knative.Type.channel); - assertThat(e2.getService()).hasFieldOrPropertyWithValue("protocol", Knative.Protocol.http); - assertThat(e2.getService()).hasFieldOrPropertyWithValue("path", "/another/path"); - assertThat(e2.getEndpoint()).isInstanceOf(NettyEndpoint.class); - assertThat(e2.getEndpoint()).hasFieldOrPropertyWithValue("endpointUri", "http://myChannel-channel/another/path"); - - - } - - @Test - void testInvokeEndpoint() throws Exception { - final int port = AvailablePortFinder.getNextAvailable(); - - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "localhost", - port, - mapOf( - ServiceDefinition.SERVICE_META_PATH, "/a/path", - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain" - )) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setEnvironment(env); - - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("direct:source") - .to("knative:endpoint/myEndpoint"); - - fromF("netty4-http:http://localhost:%d/a/path", port) - .to("mock:ce"); - } - }); - - context.start(); - - MockEndpoint mock = context.getEndpoint("mock:ce", MockEndpoint.class); - mock.expectedMessageCount(1); - mock.expectedHeaderReceived("CE-CloudEventsVersion", "0.1"); - mock.expectedHeaderReceived("CE-EventType", "org.apache.camel.event"); - mock.expectedHeaderReceived("CE-Source", "knative://endpoint/myEndpoint"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, "text/plain"); - mock.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("CE-EventTime")); - mock.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("CE-EventID")); - mock.expectedBodiesReceived("test"); - - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setBody("test"); - } - ); - - mock.assertIsSatisfied(); - } - - @Test - void testConsumeStructuredContent() throws Exception { - final int port = AvailablePortFinder.getNextAvailable(); - - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "localhost", - port, - mapOf( - ServiceDefinition.SERVICE_META_PATH, "/a/path", - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain" - )) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setEnvironment(env); - - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("knative:endpoint/myEndpoint") - .to("mock:ce"); - - from("direct:source") - .toF("netty4-http:http://localhost:%d/a/path", port); - } - }); - - context.start(); - - MockEndpoint mock = context.getEndpoint("mock:ce", MockEndpoint.class); - mock.expectedMessageCount(1); - mock.expectedHeaderReceived("CE-CloudEventsVersion", "0.1"); - mock.expectedHeaderReceived("CE-EventType", "org.apache.camel.event"); - mock.expectedHeaderReceived("CE-EventID", "myEventID"); - mock.expectedHeaderReceived("CE-Source", "/somewhere"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, "text/plain"); - mock.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("CE-EventTime")); - mock.expectedBodiesReceived("test"); - - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setHeader(Exchange.CONTENT_TYPE, Knative.MIME_STRUCTURED_CONTENT_MODE); - e.getIn().setBody(new ObjectMapper().writeValueAsString(mapOf( - "cloudEventsVersion", "0.1", - "eventType", "org.apache.camel.event", - "eventID", "myEventID", - "eventTime", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now()), - "source", "/somewhere", - "contentType", "text/plain", - "data", "test" - ))); - } - ); - - mock.assertIsSatisfied(); - } - - @Test - void testConsumeContent() throws Exception { - final int port = AvailablePortFinder.getNextAvailable(); - - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "myEndpoint", - "localhost", - port, - mapOf( - ServiceDefinition.SERVICE_META_PATH, "/a/path", - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain" - )) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setEnvironment(env); - - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("knative:endpoint/myEndpoint") - .to("mock:ce"); - - from("direct:source") - .toF("http4://localhost:%d/a/path", port); - } - }); - - context.start(); - - MockEndpoint mock = context.getEndpoint("mock:ce", MockEndpoint.class); - mock.expectedMessageCount(1); - mock.expectedHeaderReceived("CE-CloudEventsVersion", "0.1"); - mock.expectedHeaderReceived("CE-EventType", "org.apache.camel.event"); - mock.expectedHeaderReceived("CE-EventID", "myEventID"); - mock.expectedHeaderReceived("CE-Source", "/somewhere"); - mock.expectedHeaderReceived(Exchange.CONTENT_TYPE, "text/plain"); - mock.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("CE-EventTime")); - mock.expectedBodiesReceived("test"); - - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setHeader(Exchange.CONTENT_TYPE, "text/plain"); - e.getIn().setHeader("CE-CloudEventsVersion", "0.1"); - e.getIn().setHeader("CE-EventType", "org.apache.camel.event"); - e.getIn().setHeader("CE-EventID", "myEventID"); - e.getIn().setHeader("CE-EventTime", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now())); - e.getIn().setHeader("CE-Source", "/somewhere"); - e.getIn().setBody("test"); - } - ); - - mock.assertIsSatisfied(); - } - - @Test - void testConsumeContentWithFilter() throws Exception { - final int port = AvailablePortFinder.getNextAvailable(); - - KnativeEnvironment env = new KnativeEnvironment(Arrays.asList( - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "ep1", - "localhost", - port, - mapOf( - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain", - Knative.FILTER_HEADER_NAME, "CE-Source", - Knative.FILTER_HEADER_VALUE, "CE1" - )), - new KnativeEnvironment.KnativeServiceDefinition( - Knative.Type.endpoint, - Knative.Protocol.http, - "ep2", - "localhost", - port, - mapOf( - Knative.KNATIVE_EVENT_TYPE, "org.apache.camel.event", - Knative.CONTENT_TYPE, "text/plain", - Knative.FILTER_HEADER_NAME, "CE-Source", - Knative.FILTER_HEADER_VALUE, "CE2" - )) - )); - - KnativeComponent component = context.getComponent("knative", KnativeComponent.class); - component.setEnvironment(env); - - context.addRoutes(new RouteBuilder() { - @Override - public void configure() throws Exception { - from("knative:endpoint/ep1") - .convertBodyTo(String.class) - .to("log:ce1?showAll=true&multiline=true") - .to("mock:ce1"); - from("knative:endpoint/ep2") - .convertBodyTo(String.class) - .to("log:ce2?showAll=true&multiline=true") - .to("mock:ce2"); - - from("direct:source") - .setBody() - .constant("test") - .setHeader(Exchange.HTTP_METHOD) - .constant("POST") - .setHeader(Exchange.HTTP_QUERY) - .simple("filter.headerName=CE-Source&filter.headerValue=${header.FilterVal}") - .toD("http4://localhost:" + port); - } - }); - - context.start(); - - MockEndpoint mock1 = context.getEndpoint("mock:ce1", MockEndpoint.class); - mock1.expectedMessageCount(1); - mock1.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("CE-EventTime")); - mock1.expectedHeaderReceived("CE-CloudEventsVersion", "0.1"); - mock1.expectedHeaderReceived("CE-EventType", "org.apache.camel.event"); - mock1.expectedHeaderReceived("CE-EventID", "myEventID1"); - mock1.expectedHeaderReceived("CE-Source", "CE1"); - mock1.expectedBodiesReceived("test"); - - MockEndpoint mock2 = context.getEndpoint("mock:ce2", MockEndpoint.class); - mock2.expectedMessageCount(1); - mock2.expectedMessagesMatches(e -> e.getIn().getHeaders().containsKey("CE-EventTime")); - mock2.expectedHeaderReceived("CE-CloudEventsVersion", "0.1"); - mock2.expectedHeaderReceived("CE-EventType", "org.apache.camel.event"); - mock2.expectedHeaderReceived("CE-EventID", "myEventID2"); - mock2.expectedHeaderReceived("CE-Source", "CE2"); - mock2.expectedBodiesReceived("test"); - - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setHeader("FilterVal", "CE1"); - e.getIn().setHeader("CE-CloudEventsVersion", "0.1"); - e.getIn().setHeader("CE-EventType", "org.apache.camel.event"); - e.getIn().setHeader("CE-EventID", "myEventID1"); - e.getIn().setHeader("CE-EventTime", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now())); - e.getIn().setHeader("CE-Source", "CE1"); - } - ); - context.createProducerTemplate().send( - "direct:source", - e -> { - e.getIn().setHeader("FilterVal", "CE2"); - e.getIn().setHeader("CE-CloudEventsVersion", "0.1"); - e.getIn().setHeader("CE-EventType", "org.apache.camel.event"); - e.getIn().setHeader("CE-EventID", "myEventID2"); - e.getIn().setHeader("CE-EventTime", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(ZonedDateTime.now())); - e.getIn().setHeader("CE-Source", "CE2"); - } - ); - - mock1.assertIsSatisfied(); - mock2.assertIsSatisfied(); - } -} diff --git a/runtime/camel-knative/src/test/resources/environment.json b/runtime/camel-knative/src/test/resources/environment.json deleted file mode 100644 index 4fbe864dd0..0000000000 --- a/runtime/camel-knative/src/test/resources/environment.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "services": [ - { - "type": "channel", - "protocol": "http", - "name": "c1", - "host": "localhost", - "port": "8001", - "metadata": { - "service.path": "", - "knative.event.type": "" - } - }, - { - "type": "endpoint", - "protocol": "http", - "name": "e1", - "host": "localhost", - "port": "9001", - "metadata": { - "service.path": "", - "knative.event.type": "" - } - } - ] -} \ No newline at end of file diff --git a/runtime/camel-knative/src/test/resources/log4j2-test.xml b/runtime/camel-knative/src/test/resources/log4j2-test.xml deleted file mode 100644 index b31e8b43ea..0000000000 --- a/runtime/camel-knative/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/runtime/pom.xml b/runtime/pom.xml deleted file mode 100644 index c460bf19c2..0000000000 --- a/runtime/pom.xml +++ /dev/null @@ -1,316 +0,0 @@ - - - - - - org.apache - apache - 21 - - - 4.0.0 - org.apache.camel.k - camel-k-runtime-parent - 0.3.0-SNAPSHOT - pom - - - UTF-8 - 1.8 - 1.8 - 2.23.1 - ${camel.version} - 4.12 - 5.4.0 - 0.9.10 - 2.6 - 3.8.1 - 4.3 - 3.11.1 - 2.11.1 - 1.7.25 - 2.5.6 - 1.3.21 - 1.23 - 1.2-groovy-2.5 - 2.9.8 - 2.1.0.RELEASE - 2.7.4 - 2.2.0 - 1.6.1 - 3.5.40 - 3.8.0 - 2.22.1 - 2.7 - 0.3.1 - - - - - The Apache Camel Team - dev@camel.apache.org - http://camel.apache.org - Apache Software Foundation - http://apache.org/ - - http://camel.apache.org/banner.data/apache-camel-7.png - - - - - - github - https://github.com/apache/camel-k/issues - - - - scm:git:http://gitbox.apache.org/repos/asf/camel-k.git - scm:git:https://gitbox.apache.org/repos/asf/camel-k.git - https://gitbox.apache.org/repos/asf?p=camel-k.git;a=summary - HEAD - - - - - - org.apache.camel - camel-bom - ${camel.version} - pom - import - - - - - - - - - io.fabric8 - fabric8-maven-plugin - ${fabric8-maven-plugin.version} - - - org.apache.maven.plugins - maven-compiler-plugin - ${maven-compiler-plugin.version} - - 1.8 - 1.8 - - -Xlint:deprecation - - - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - false - - - - - - - - camel-k-maven-plugin - camel-k-runtime-core - camel-k-runtime-jvm - camel-k-runtime-groovy - camel-k-runtime-kotlin - camel-k-runtime-yaml - camel-k-runtime-spring-boot-layout - camel-k-runtime-spring-boot - camel-knative-http - camel-knative - - - - - apache.snapshots - https://repository.apache.org/snapshots/ - Apache Snapshot Repo - - true - - - false - - - - - - - apache.snapshots - https://repository.apache.org/snapshots/ - - true - - - false - - - - - - - deps - - false - - - initialize versions:display-dependency-updates - - - org.commonjava.maven.plugins - directory-maven-plugin - ${directory-maven-plugin.version} - - - directories - - highest-basedir - - initialize - - camel-k.project.root - - - - - - org.codehaus.mojo - versions-maven-plugin - ${versions-maven-plugin.version} - - file:///${camel-k.project.root}/.maven-versions-rules.xml - - - - - - - catalog - - false - - - generate-resources - - - ${project.groupId} - camel-k-maven-plugin - ${project.version} - - - generate-catalog - - generate-catalog - - - - - - org.apache.camel - camel-catalog - ${catalog.version} - - - - - - - - release - - - release - - - - - - - true - org.apache.maven.plugins - maven-deploy-plugin - - true - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - attach-javadocs - - jar - - - - - ${javadoc.opts} - - - - - org.apache.maven.plugins - maven-gpg-plugin - - ${gpg.passphrase} - ${gpg.useagent} - - - - - sign - - - - - - - - - doclint-java8-disable - - [1.8,) - - - -Xdoclint:none - - - - From 4a694413aafb0a8407bf9dc916d94cc57adece3e Mon Sep 17 00:00:00 2001 From: Andrea Cosentino Date: Thu, 21 Feb 2019 10:56:53 +0100 Subject: [PATCH 2/2] chore(refactor): Fixes #470, moved camel-k-runtime into his own repo --- .gitmodules | 3 +++ runtime | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 runtime diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..1f98a990d7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "runtime"] + path = runtime + url = https://github.com/apache/camel-k-runtime.git diff --git a/runtime b/runtime new file mode 160000 index 0000000000..1bc48d9865 --- /dev/null +++ b/runtime @@ -0,0 +1 @@ +Subproject commit 1bc48d98659d69dd36cbd30736f165211b9c37e0