This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
The following commit(s) were added to refs/heads/master by this push: new d3fc05a Support for camel 3.x #11 new 023d3c8 Merge pull request #16 from lburgazzoli/github-11-camel-3 d3fc05a is described below commit d3fc05aa508a109fb859eb6412bcdae2527d4543 Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Mon Feb 25 01:18:07 2019 +0100 Support for camel 3.x #11 --- .travis.yml | 4 +- Jenkinsfile | 10 +- .../pom.xml | 19 +- .../camel/k/adapter/DefaultAsyncProducer.java | 25 ++ .../apache/camel/k/adapter/DefaultComponent.java | 28 +++ .../apache/camel/k/adapter/DefaultEndpoint.java | 27 +++ .../java/org/apache/camel/k/adapter/Exchanges.java | 30 +++ .../org/apache/camel/k/adapter/Introspection.java | 43 ++++ .../org/apache/camel/k/adapter/Processors.java | 33 +-- .../java/org/apache/camel/k/adapter/Resources.java | 33 +-- .../java/org/apache/camel/k/adapter/Services.java | 47 ++++ .../pom.xml | 19 +- .../camel/k/adapter/DefaultAsyncProducer.java | 25 ++ .../apache/camel/k/adapter/DefaultComponent.java | 28 +++ .../apache/camel/k/adapter/DefaultEndpoint.java | 27 +++ .../java/org/apache/camel/k/adapter/Exchanges.java | 30 +++ .../org/apache/camel/k/adapter/Introspection.java | 47 ++++ .../org/apache/camel/k/adapter/Processors.java | 33 +-- .../java/org/apache/camel/k/adapter/Resources.java | 33 +-- .../java/org/apache/camel/k/adapter/Services.java | 48 ++++ camel-k-maven-plugin/pom.xml | 1 + .../camel/k/tooling/maven/GenerateCatalogMojo.java | 2 +- .../maven/processors/CatalogProcessor_2_x.java | 1 + ...rocessor_2_x.java => CatalogProcessor_3_x.java} | 24 +- ...he.camel.k.tooling.maven.model.CatalogProcessor | 1 + camel-k-runtime-core/pom.xml | 48 +++- .../src/main/java/org/apache/camel/k/Runtime.java | 5 - .../org/apache/camel/k/listener/RoutesDumper.java | 5 +- .../org/apache/camel/k/support/RuntimeSupport.java | 4 +- .../org/apache/camel/k/support/URIResolver.java | 4 +- camel-k-runtime-groovy/pom.xml | 48 +++- .../k/groovy/dsl/ComponentConfiguration.groovy | 10 +- .../org/apache/camel/k/groovy/LoaderTest.groovy | 4 +- .../k/groovy/dsl/extension/LogExtensionTest.groovy | 4 +- camel-k-runtime-jvm/pom.xml | 51 +++- .../camel/k/jvm/loader/JavaSourceLoader.java | 13 +- .../camel/k/jvm/RoutesLoadersCommonTest.java | 1 + .../org/apache/camel/k/jvm/RoutesLoadersTest.java | 4 + .../java/org/apache/camel/k/jvm/RuntimeTest.java | 11 +- camel-k-runtime-kotlin/pom.xml | 53 ++++- .../kotlin/org/apache/camel/k/kotlin/LoaderTest.kt | 4 +- .../apache/camel/k/kotlin/dsl/IntegrationTest.kt | 21 +- .../camel/k/kotlin/extension/LogExtensionTest.kt | 4 +- camel-k-runtime-spring-boot/pom.xml | 42 +++- camel-k-runtime-yaml/pom.xml | 54 ++++- .../org/apache/camel/k/yaml/RoutesLoaderTest.java | 5 +- camel-knative-http/pom.xml | 47 +++- .../knative/http/KnativeHttpComponent.java | 4 +- camel-knative/pom.xml | 57 ++++- .../apache/camel/component/knative/Knative.java | 1 - .../camel/component/knative/KnativeComponent.java | 6 +- .../component/knative/KnativeConfiguration.java | 2 - .../camel/component/knative/KnativeEndpoint.java | 10 +- .../component/knative/KnativeEnvironment.java | 4 +- .../camel/component/knative/KnativeProducer.java | 18 +- pom.xml | 263 ++++++++++++++------- 56 files changed, 1098 insertions(+), 327 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1f77f5a..6d79b9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,4 +18,6 @@ # language: java -script: ./mvnw test +script: + - ./mvnw test -Dcamel2 + - ./mvnw test -Dcamel3 diff --git a/Jenkinsfile b/Jenkinsfile index 81ce795..1c57e46 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -42,9 +42,15 @@ pipeline { stages { - stage('Test & Install') { + stage('Test Vs Camel 2.x & Install') { steps { - sh "./mvnw $MAVEN_PARAMS clean install -f pom.xml" + sh "./mvnw $MAVEN_PARAMS clean install -Dcamel2 -f pom.xml" + } + } + + stage('Test Vs Camel 3.x & Install') { + steps { + sh "./mvnw $MAVEN_PARAMS clean install -Dcamel3 -f pom.xml" } } diff --git a/camel-k-runtime-core/pom.xml b/camel-k-adapter-camel-2/pom.xml similarity index 81% copy from camel-k-runtime-core/pom.xml copy to camel-k-adapter-camel-2/pom.xml index 6f704df..eb91332 100644 --- a/camel-k-runtime-core/pom.xml +++ b/camel-k-adapter-camel-2/pom.xml @@ -25,7 +25,7 @@ </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>camel-k-runtime-core</artifactId> + <artifactId>camel-k-adapter-camel-2</artifactId> <dependencies> @@ -38,23 +38,9 @@ <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-core</artifactId> + <version>${camel2.version}</version> <scope>provided</scope> </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>${slf4j.version}</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - <version>${commons-lang.version}</version> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>${commons-io.version}</version> - </dependency> <!-- ****************************** --> <!-- --> @@ -74,7 +60,6 @@ <version>${junit-jupiter.version}</version> <scope>test</scope> </dependency> - <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultAsyncProducer.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultAsyncProducer.java new file mode 100644 index 0000000..4e3f500 --- /dev/null +++ b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultAsyncProducer.java @@ -0,0 +1,25 @@ +/** + * 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.adapter; + +import org.apache.camel.Endpoint; + +public abstract class DefaultAsyncProducer extends org.apache.camel.impl.DefaultAsyncProducer { + public DefaultAsyncProducer(Endpoint endpoint) { + super(endpoint); + } +} diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultComponent.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultComponent.java new file mode 100644 index 0000000..01a0f60 --- /dev/null +++ b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultComponent.java @@ -0,0 +1,28 @@ +/** + * 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.adapter; + +import org.apache.camel.CamelContext; + +public abstract class DefaultComponent extends org.apache.camel.impl.DefaultComponent { + public DefaultComponent() { + } + + public DefaultComponent(CamelContext context) { + super(context); + } +} diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultEndpoint.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultEndpoint.java new file mode 100644 index 0000000..bd998e0 --- /dev/null +++ b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultEndpoint.java @@ -0,0 +1,27 @@ +/** + * 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.adapter; + +import org.apache.camel.Component; + +public abstract class DefaultEndpoint extends org.apache.camel.impl.DefaultEndpoint { + public DefaultEndpoint() { + } + public DefaultEndpoint(String endpointUri, Component component) { + super(endpointUri, component); + } +} diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Exchanges.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Exchanges.java new file mode 100644 index 0000000..8d6de5e --- /dev/null +++ b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Exchanges.java @@ -0,0 +1,30 @@ +/** + * 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.adapter; + +import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.impl.DefaultExchange; + +public final class Exchanges { + protected Exchanges() { + } + + public final static Exchange newDefaultExchange(CamelContext context) { + return new DefaultExchange(context); + } +} diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Introspection.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Introspection.java new file mode 100644 index 0000000..e08b1f6 --- /dev/null +++ b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Introspection.java @@ -0,0 +1,43 @@ +/** + * 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.adapter; + +import java.util.Map; + +import org.apache.camel.TypeConverter; +import org.apache.camel.util.IntrospectionSupport; + +public final class Introspection { + private Introspection() { + } + + public static boolean setProperties(TypeConverter typeConverter, Object target, Map<String, Object> properties) throws Exception { + return IntrospectionSupport.setProperties(typeConverter, target, properties); + } + + public static boolean setProperty(Object target, String name, Object value) throws Exception { + return IntrospectionSupport.setProperty(target, name, value, false); + } + + public static boolean setProperty(Object target, String name, Object value, boolean builderPattern) throws Exception { + return IntrospectionSupport.setProperty(target, name, value, builderPattern); + } + + public static boolean getProperties(Object target, Map<String, Object> properties, String optionPrefix, boolean includeNull) { + return IntrospectionSupport.getProperties(target, properties, optionPrefix, includeNull); + } +} diff --git a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Processors.java similarity index 50% copy from camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy copy to camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Processors.java index fee6475..24c580e 100644 --- a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy +++ b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Processors.java @@ -3,7 +3,7 @@ * 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 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 @@ -14,30 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.groovy.dsl.extension +package org.apache.camel.k.adapter; -import org.apache.camel.component.log.LogComponent -import org.apache.camel.impl.DefaultCamelContext -import org.apache.camel.impl.DefaultExchange -import spock.lang.Specification +import org.apache.camel.AsyncProcessor; +import org.apache.camel.Processor; +import org.apache.camel.util.AsyncProcessorConverterHelper; -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) +public final class Processors { + private Processors() { + } - then: - result == 'body: hello' + public static AsyncProcessor convertToAsync(Processor processor) { + return AsyncProcessorConverterHelper.convert(processor); } } diff --git a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Resources.java similarity index 50% copy from camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy copy to camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Resources.java index fee6475..ba034d4 100644 --- a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy +++ b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Resources.java @@ -3,7 +3,7 @@ * 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 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 @@ -14,30 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.groovy.dsl.extension +package org.apache.camel.k.adapter; -import org.apache.camel.component.log.LogComponent -import org.apache.camel.impl.DefaultCamelContext -import org.apache.camel.impl.DefaultExchange -import spock.lang.Specification +import java.io.IOException; +import java.io.InputStream; -class LogExtensionTest extends Specification { +import org.apache.camel.CamelContext; +import org.apache.camel.util.ResourceHelper; - 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) +public final class Resources { + private Resources() { + } - then: - result == 'body: hello' + public static InputStream resolveResourceAsInputStream(CamelContext camelContext, String uri) throws IOException { + return ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, uri); } } diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Services.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Services.java new file mode 100644 index 0000000..560021f --- /dev/null +++ b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Services.java @@ -0,0 +1,47 @@ +/** + * 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.adapter; + +import java.util.Arrays; + +import org.apache.camel.util.ServiceHelper; + +public final class Services { + private Services() { + + } + + public static void start(Object... services) throws Exception { + ServiceHelper.startServices(services); + } + + public static void stop(Object... services) throws Exception { + ServiceHelper.stopServices(services); + } + + public static void suspend(Object... services) throws Exception { + ServiceHelper.suspendServices(Arrays.asList(services)); + } + + public static void resume(Object... services) throws Exception { + ServiceHelper.resumeService(Arrays.asList(services)); + } + + public static void shutdown(Object... services) throws Exception { + ServiceHelper.stopAndShutdownServices(Arrays.asList(services)); + } +} diff --git a/camel-k-runtime-core/pom.xml b/camel-k-adapter-camel-3/pom.xml similarity index 81% copy from camel-k-runtime-core/pom.xml copy to camel-k-adapter-camel-3/pom.xml index 6f704df..0477802 100644 --- a/camel-k-runtime-core/pom.xml +++ b/camel-k-adapter-camel-3/pom.xml @@ -25,7 +25,7 @@ </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>camel-k-runtime-core</artifactId> + <artifactId>camel-k-adapter-camel-3</artifactId> <dependencies> @@ -38,23 +38,9 @@ <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-core</artifactId> + <version>${camel3.version}</version> <scope>provided</scope> </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>${slf4j.version}</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - <version>${commons-lang.version}</version> - </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>${commons-io.version}</version> - </dependency> <!-- ****************************** --> <!-- --> @@ -74,7 +60,6 @@ <version>${junit-jupiter.version}</version> <scope>test</scope> </dependency> - <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultAsyncProducer.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultAsyncProducer.java new file mode 100644 index 0000000..5fe22b0 --- /dev/null +++ b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultAsyncProducer.java @@ -0,0 +1,25 @@ +/** + * 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.adapter; + +import org.apache.camel.Endpoint; + +public abstract class DefaultAsyncProducer extends org.apache.camel.support.DefaultAsyncProducer { + public DefaultAsyncProducer(Endpoint endpoint) { + super(endpoint); + } +} diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultComponent.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultComponent.java new file mode 100644 index 0000000..a9f746f --- /dev/null +++ b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultComponent.java @@ -0,0 +1,28 @@ +/** + * 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.adapter; + +import org.apache.camel.CamelContext; + +public abstract class DefaultComponent extends org.apache.camel.support.DefaultComponent { + public DefaultComponent() { + } + + public DefaultComponent(CamelContext context) { + super(context); + } +} diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultEndpoint.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultEndpoint.java new file mode 100644 index 0000000..db38454 --- /dev/null +++ b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultEndpoint.java @@ -0,0 +1,27 @@ +/** + * 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.adapter; + +import org.apache.camel.Component; + +public abstract class DefaultEndpoint extends org.apache.camel.support.DefaultEndpoint { + public DefaultEndpoint() { + } + public DefaultEndpoint(String endpointUri, Component component) { + super(endpointUri, component); + } +} diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Exchanges.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Exchanges.java new file mode 100644 index 0000000..4e56962 --- /dev/null +++ b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Exchanges.java @@ -0,0 +1,30 @@ +/** + * 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.adapter; + +import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.support.DefaultExchange; + +public final class Exchanges { + protected Exchanges() { + } + + public final static Exchange newDefaultExchange(CamelContext context) { + return new DefaultExchange(context); + } +} diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Introspection.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Introspection.java new file mode 100644 index 0000000..2afca13 --- /dev/null +++ b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Introspection.java @@ -0,0 +1,47 @@ +/** + * 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.adapter; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.camel.TypeConverter; +import org.apache.camel.support.IntrospectionSupport; + +public final class Introspection { + private Introspection() { + } + + public static boolean setProperties(TypeConverter typeConverter, Object target, Map<String, Object> properties) throws Exception { + return IntrospectionSupport.setProperties(typeConverter, target, properties); + } + + public static boolean setProperty(Object target, String name, Object value) throws Exception { + return IntrospectionSupport.setProperty(target, name, value, false); + } + + public static boolean setProperty(Object target, String name, Object value, boolean builderPattern) throws Exception { + return IntrospectionSupport.setProperty(target, name, value, builderPattern); + } + + public static Map<String, Object> getProperties(Object target, String optionPrefix, boolean includeNull) { + Map<String, Object> properties = new HashMap<>(); + IntrospectionSupport.getProperties(target, properties, optionPrefix, includeNull); + + return properties; + } +} diff --git a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Processors.java similarity index 50% copy from camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy copy to camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Processors.java index fee6475..585dfa4 100644 --- a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy +++ b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Processors.java @@ -3,7 +3,7 @@ * 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 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 @@ -14,30 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.groovy.dsl.extension +package org.apache.camel.k.adapter; -import org.apache.camel.component.log.LogComponent -import org.apache.camel.impl.DefaultCamelContext -import org.apache.camel.impl.DefaultExchange -import spock.lang.Specification +import org.apache.camel.AsyncProcessor; +import org.apache.camel.Processor; +import org.apache.camel.support.AsyncProcessorConverterHelper; -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) +public final class Processors { + private Processors() { + } - then: - result == 'body: hello' + public static AsyncProcessor convertToAsync(Processor processor) { + return AsyncProcessorConverterHelper.convert(processor); } } diff --git a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Resources.java similarity index 50% copy from camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy copy to camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Resources.java index fee6475..eb74616 100644 --- a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy +++ b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Resources.java @@ -3,7 +3,7 @@ * 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 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 @@ -14,30 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.k.groovy.dsl.extension +package org.apache.camel.k.adapter; -import org.apache.camel.component.log.LogComponent -import org.apache.camel.impl.DefaultCamelContext -import org.apache.camel.impl.DefaultExchange -import spock.lang.Specification +import java.io.IOException; +import java.io.InputStream; -class LogExtensionTest extends Specification { +import org.apache.camel.CamelContext; +import org.apache.camel.support.ResourceHelper; - 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) +public final class Resources { + private Resources() { + } - then: - result == 'body: hello' + public static InputStream resolveResourceAsInputStream(CamelContext camelContext, String uri) throws IOException { + return ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, uri); } } diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Services.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Services.java new file mode 100644 index 0000000..fbf07f5 --- /dev/null +++ b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Services.java @@ -0,0 +1,48 @@ +/** + * 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.adapter; + + +import java.util.Arrays; + +import org.apache.camel.support.service.ServiceHelper; + +public final class Services { + private Services() { + + } + + public static void start(Object... services) throws Exception { + ServiceHelper.startService(services); + } + + public static void stop(Object... services) throws Exception { + ServiceHelper.stopService(services); + } + + public static void suspend(Object... services) throws Exception { + ServiceHelper.suspendServices(Arrays.asList(services)); + } + + public static void resume(Object... services) throws Exception { + ServiceHelper.resumeService(Arrays.asList(services)); + } + + public static void shutdown(Object... services) throws Exception { + ServiceHelper.stopAndShutdownServices(Arrays.asList(services)); + } +} diff --git a/camel-k-maven-plugin/pom.xml b/camel-k-maven-plugin/pom.xml index a6ad36e..61a8fc8 100644 --- a/camel-k-maven-plugin/pom.xml +++ b/camel-k-maven-plugin/pom.xml @@ -87,6 +87,7 @@ <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-catalog</artifactId> + <version>${camel.version}</version> <scope>provided</scope> </dependency> <dependency> diff --git a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java index d6abd9c..1b5a2ba 100644 --- a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java +++ b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java @@ -128,7 +128,7 @@ public class GenerateCatalogMojo extends AbstractMojo { try (Writer writer = Files.newBufferedWriter(output, StandardCharsets.UTF_8)) { CamelCatalog cr = new CamelCatalog.Builder() .metadata(new ObjectMeta.Builder() - .name("camel-catalog-" + catalog.getCatalogVersion()) + .name("camel-catalog-" + catalog.getCatalogVersion().toLowerCase()) .putLabels("app", "camel-k") .putLabels("camel.apache.org/catalog.version", catalog.getCatalogVersion()) .putLabels("camel.apache.org/catalog.loader.version", catalog.getLoadedVersion()) diff --git a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java index 12a82ae..a48f819 100644 --- a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java +++ b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java @@ -93,6 +93,7 @@ public class CatalogProcessor_2_x implements CatalogProcessor { artifact.setGroupId("org.apache.camel.k"); artifact.setArtifactId("camel-k-runtime-jvm"); artifact.addDependency("org.apache.camel", "camel-core"); + artifact.addDependency("org.apache.camel.k", "camel-k-adapter-camel-2"); artifacts.put(artifact.getArtifactId(), artifact); } diff --git a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_3_x.java similarity index 90% copy from camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java copy to camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_3_x.java index 12a82ae..94fd552 100644 --- a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java +++ b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_3_x.java @@ -21,13 +21,12 @@ import java.util.List; import java.util.Map; import com.vdurmont.semver4j.Semver; - 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 { +public class CatalogProcessor_3_x implements CatalogProcessor { private static final List<String> KNOWN_HTTP_URIS = Arrays.asList( "ahc", "ahc-ws", @@ -76,7 +75,7 @@ public class CatalogProcessor_2_x implements CatalogProcessor { @Override public boolean accepts(CamelCatalog catalog) { - return new Semver(catalog.getCatalogVersion(), Semver.SemverType.IVY).satisfies("[2.18,3]"); + return new Semver(catalog.getCatalogVersion(), Semver.SemverType.IVY).withClearedSuffixAndBuild().satisfies("[3,4]"); } @Override @@ -92,7 +91,9 @@ public class CatalogProcessor_2_x implements CatalogProcessor { 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"); + artifact.addDependency("org.apache.camel.k", "camel-k-adapter-camel-3"); artifacts.put(artifact.getArtifactId(), artifact); } @@ -107,6 +108,7 @@ public class CatalogProcessor_2_x implements CatalogProcessor { 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); @@ -122,20 +124,7 @@ public class CatalogProcessor_2_x implements CatalogProcessor { CamelArtifact artifact = new CamelArtifact(); artifact.setGroupId("org.apache.camel.k"); artifact.setArtifactId("camel-k-runtime-kotlin"); - - artifacts.put(artifact.getArtifactId(), artifact); - } - - // ************************ - // - // camel-k-runtime-yaml - // - // ************************ - - { - CamelArtifact artifact = new CamelArtifact(); - artifact.setGroupId("org.apache.camel.k"); - artifact.setArtifactId("camel-k-runtime-yaml"); + artifact.setVersion(project.getVersion()); artifacts.put(artifact.getArtifactId(), artifact); } @@ -150,6 +139,7 @@ public class CatalogProcessor_2_x implements CatalogProcessor { 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"); diff --git a/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.model.CatalogProcessor b/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.model.CatalogProcessor index 1531453..5a778d4 100644 --- a/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.model.CatalogProcessor +++ b/camel-k-maven-plugin/src/main/resources/META-INF/services/org.apache.camel.k.tooling.maven.model.CatalogProcessor @@ -1 +1,2 @@ org.apache.camel.k.tooling.maven.processors.CatalogProcessor_2_x +org.apache.camel.k.tooling.maven.processors.CatalogProcessor_3_x diff --git a/camel-k-runtime-core/pom.xml b/camel-k-runtime-core/pom.xml index 6f704df..3eb913b 100644 --- a/camel-k-runtime-core/pom.xml +++ b/camel-k-runtime-core/pom.xml @@ -36,15 +36,17 @@ <!-- ****************************** --> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-core</artifactId> - <scope>provided</scope> - </dependency> - <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> + + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core</artifactId> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> @@ -74,7 +76,6 @@ <version>${junit-jupiter.version}</version> <scope>test</scope> </dependency> - <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> @@ -83,4 +84,39 @@ </dependency> </dependencies> + <profiles> + <profile> + <id>camel3</id> + <activation> + <property> + <name>camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-3</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> + </profile> + <profile> + <id>camel2</id> + <activation> + <property> + <name>!camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-2</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> + </profile> + </profiles> + </project> diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/Runtime.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/Runtime.java index 31fbbe5..d21e829 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/Runtime.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/Runtime.java @@ -21,8 +21,6 @@ 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 { /** @@ -58,19 +56,16 @@ public interface Runtime { void bind(String name, Object bean); @SuppressWarnings("deprecation") - @Override default public Object lookup(String name) { return lookupByName(name); } @SuppressWarnings("deprecation") - @Override default public <T> T lookup(String name, Class<T> type) { return lookupByNameAndType(name, type); } @SuppressWarnings("deprecation") - @Override default public <T> Map<String, T> lookupByType(Class<T> type) { return findByTypeWithName(type); } diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesDumper.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesDumper.java index 379fc7f..7f0eec6 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesDumper.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesDumper.java @@ -20,6 +20,7 @@ import javax.xml.bind.JAXBException; import org.apache.camel.CamelContext; import org.apache.camel.k.Runtime; +import org.apache.camel.model.ModelCamelContext; import org.apache.camel.model.ModelHelper; import org.apache.camel.model.RoutesDefinition; import org.apache.camel.model.rest.RestsDefinition; @@ -38,10 +39,10 @@ public class RoutesDumper extends AbstractPhaseListener { CamelContext context = runtime.getContext(); RoutesDefinition routes = new RoutesDefinition(); - routes.setRoutes(context.getRouteDefinitions()); + routes.setRoutes(context.adapt(ModelCamelContext.class).getRouteDefinitions()); RestsDefinition rests = new RestsDefinition(); - rests.setRests(context.getRestDefinitions()); + rests.setRests(context.adapt(ModelCamelContext.class).getRestDefinitions()); try { if (LOGGER.isDebugEnabled() && !routes.getRoutes().isEmpty()) { diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/RuntimeSupport.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/RuntimeSupport.java index ce41289..170d115 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/RuntimeSupport.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/RuntimeSupport.java @@ -37,9 +37,9 @@ 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.k.adapter.Introspection; 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; @@ -118,7 +118,7 @@ public final class RuntimeSupport { final Object val = entry.getValue(); try { - if (IntrospectionSupport.setProperty(target, key, val, false)) { + if (Introspection.setProperty(target, key, val)) { count.incrementAndGet(); } } catch (Exception ex) { diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/URIResolver.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/URIResolver.java index 3b20602..3352840 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/URIResolver.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/URIResolver.java @@ -26,7 +26,7 @@ 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.k.adapter.Resources; import org.apache.camel.util.StringHelper; @@ -46,7 +46,7 @@ public class URIResolver { // Using platform encoding on purpose is = new ByteArrayInputStream(content.getBytes()); } else { - is = ResourceHelper.resolveMandatoryResourceAsInputStream(ctx, source.getLocation()); + is = Resources.resolveResourceAsInputStream(ctx, source.getLocation()); } return source.isCompressed() ? new GZIPInputStream(Base64.getDecoder().wrap(is)) : is; diff --git a/camel-k-runtime-groovy/pom.xml b/camel-k-runtime-groovy/pom.xml index 389d7b1..24f9485 100644 --- a/camel-k-runtime-groovy/pom.xml +++ b/camel-k-runtime-groovy/pom.xml @@ -31,13 +31,14 @@ <dependency> <groupId>org.apache.camel.k</groupId> <artifactId>camel-k-runtime-jvm</artifactId> - <version>${project.version}</version> </dependency> + <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-core</artifactId> <scope>provided</scope> </dependency> + <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-groovy</artifactId> @@ -49,6 +50,7 @@ </exclusions> <scope>provided</scope> </dependency> + <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy</artifactId> @@ -62,14 +64,12 @@ <!-- --> <!-- ****************************** --> - <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-test</artifactId> <version>${groovy.version}</version> <scope>test</scope> </dependency> - <dependency> <groupId>org.spockframework</groupId> <artifactId>spock-core</artifactId> @@ -82,7 +82,6 @@ </exclusion> </exclusions> </dependency> - <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> @@ -114,4 +113,45 @@ </plugins> </build> + <profiles> + <profile> + <id>camel3</id> + <activation> + <property> + <name>camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-3</artifactId> + <scope>provided</scope> + </dependency> + <!-- test --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-properties</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + </profile> + <profile> + <id>camel2</id> + <activation> + <property> + <name>!camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-2</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> + </profile> + </profiles> + </project> diff --git a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentConfiguration.groovy b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentConfiguration.groovy index 2454e72..bfc080d 100644 --- a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentConfiguration.groovy +++ b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ComponentConfiguration.groovy @@ -16,7 +16,7 @@ */ package org.apache.camel.k.groovy.dsl -import org.apache.camel.util.IntrospectionSupport +import org.apache.camel.k.adapter.Introspection class ComponentConfiguration { private final org.apache.camel.Component component @@ -47,21 +47,19 @@ class ComponentConfiguration { } } - if (!IntrospectionSupport.setProperty(component, name, value, true)) { + if (!Introspection.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)) { + if (!Introspection.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) + def properties = Introspection.getProperties(component, properties, null, false) return properties[name] } diff --git a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy b/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy index 72fe2db..13b5f24 100644 --- a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy +++ b/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/LoaderTest.groovy @@ -27,16 +27,18 @@ class LoaderTest extends Specification { def "load route from classpath"() { given: + def context = new DefaultCamelContext() def source = Source.create("classpath:routes.groovy") when: - def loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source) + def loader = RuntimeSupport.loaderFor(context, source) def builder = loader.load(new InMemoryRegistry(), source) then: loader instanceof GroovyRoutesLoader builder != null + builder.setContext(context) builder.configure() def routes = builder.routeCollection.routes diff --git a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy b/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy index fee6475..8dd39e0 100644 --- a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy +++ b/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/extension/LogExtensionTest.groovy @@ -18,7 +18,7 @@ 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 org.apache.camel.k.adapter.Exchanges import spock.lang.Specification class LogExtensionTest extends Specification { @@ -33,7 +33,7 @@ class LogExtensionTest extends Specification { "body: $it.in.body" } - def ex = new DefaultExchange(ctx) + def ex = Exchanges.newDefaultExchange(ctx) ex.in.body = 'hello' def result = log.exchangeFormatter.format(ex) diff --git a/camel-k-runtime-jvm/pom.xml b/camel-k-runtime-jvm/pom.xml index 4cbaedf..5dfd3dc 100644 --- a/camel-k-runtime-jvm/pom.xml +++ b/camel-k-runtime-jvm/pom.xml @@ -36,15 +36,16 @@ <!-- ****************************** --> <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-core</artifactId> + </dependency> + + <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-core</artifactId> <scope>provided</scope> </dependency> - <dependency> - <groupId>org.apache.camel.k</groupId> - <artifactId>camel-k-runtime-core</artifactId> - <version>${project.version}</version> - </dependency> + <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> @@ -126,4 +127,44 @@ </plugins> </build> + <profiles> + <profile> + <id>camel3</id> + <activation> + <property> + <name>camel3</name> + </property> + </activation> + <dependencies> + <!-- test --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-3</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-properties</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + </profile> + <profile> + <id>camel2</id> + <activation> + <property> + <name>!camel3</name> + </property> + </activation> + <dependencies> + <!-- test --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-2</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + </profile> + </profiles> + </project> diff --git a/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaSourceLoader.java b/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaSourceLoader.java index 6d67166..6e201bf 100644 --- a/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaSourceLoader.java +++ b/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaSourceLoader.java @@ -59,11 +59,13 @@ public class JavaSourceLoader implements RoutesLoader { // create the builder RoutesBuilder builder = compiled.create().get(); - // Wrap routes builder - includeRoutes(builder); - if (builder instanceof RouteBuilder) { - Map<String, RestConfigurationDefinition> configurations = ((RouteBuilder) builder).getRestConfigurations(); + RouteBuilder rb = ((RouteBuilder) builder); + + rb.setContext(context); + rb.configure(); + + Map<String, RestConfigurationDefinition> configurations = rb.getRestConfigurations(); // // TODO: RouteBuilder.getRestConfigurations() should not @@ -83,6 +85,9 @@ public class JavaSourceLoader implements RoutesLoader { context.addRestConfiguration(conf); } } + + setRouteCollection(rb.getRouteCollection()); + setRestCollection(rb.getRestCollection()); } } } diff --git a/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersCommonTest.java b/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersCommonTest.java index f4c4f4a..fb2a8a0 100644 --- a/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersCommonTest.java +++ b/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersCommonTest.java @@ -48,6 +48,7 @@ public class RoutesLoadersCommonTest { assertThat(loader).isInstanceOf(type); assertThat(builder).isNotNull(); + builder.setContext(new DefaultCamelContext()); builder.configure(); List<RouteDefinition> routes = builder.getRouteCollection().getRoutes(); diff --git a/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java b/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java index e5a0b22..bc44345 100644 --- a/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java +++ b/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RoutesLoadersTest.java @@ -54,6 +54,8 @@ public class RoutesLoadersTest { @Test public void testLoadJavaWithNestedClass() throws Exception { + CamelContext context = new DefaultCamelContext(); + Source source = Source.create("classpath:MyRoutesWithNestedClass.java"); RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source); RouteBuilder builder = loader.load(new InMemoryRegistry(), source); @@ -61,6 +63,7 @@ public class RoutesLoadersTest { assertThat(loader).isInstanceOf(JavaSourceLoader.class); assertThat(builder).isNotNull(); + builder.setContext(context); builder.configure(); List<RouteDefinition> routes = builder.getRouteCollection().getRoutes(); @@ -74,6 +77,7 @@ public class RoutesLoadersTest { @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); diff --git a/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTest.java b/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTest.java index b86bbb9..0070e98 100644 --- a/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTest.java +++ b/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/RuntimeTest.java @@ -23,12 +23,13 @@ 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.adapter.Resources; 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.model.ModelCamelContext; import org.apache.camel.util.ObjectHelper; -import org.apache.camel.util.ResourceHelper; import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.Test; @@ -72,8 +73,8 @@ public class RuntimeTest { runtime.addListener(Runtime.Phase.Started, r -> { CamelContext context = r.getContext(); - assertThat(context.getRouteDefinitions()).isNotEmpty(); - assertThat(context.getRestDefinitions()).isNotEmpty(); + assertThat(context.adapt(ModelCamelContext.class).getRouteDefinitions()).isNotEmpty(); + assertThat(context.adapt(ModelCamelContext.class).getRestDefinitions()).isNotEmpty(); runtime.stop(); }); @@ -91,13 +92,13 @@ public class RuntimeTest { CamelContext context = new ApplicationRuntime().getContext(); - try (InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, "platform:my-resource.txt")) { + try (InputStream is = Resources.resolveResourceAsInputStream(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")) { + try (InputStream is = Resources.resolveResourceAsInputStream(context, "platform:my-other-resource.txt")) { String content = IOUtils.toString(is, Charset.defaultCharset()); assertThat(content).isEqualTo("value from env"); diff --git a/camel-k-runtime-kotlin/pom.xml b/camel-k-runtime-kotlin/pom.xml index 6d4bfc8..fcab33e 100644 --- a/camel-k-runtime-kotlin/pom.xml +++ b/camel-k-runtime-kotlin/pom.xml @@ -29,15 +29,16 @@ <dependencies> <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-jvm</artifactId> + </dependency> + + <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-core</artifactId> <scope>provided</scope> </dependency> - <dependency> - <groupId>org.apache.camel.k</groupId> - <artifactId>camel-k-runtime-jvm</artifactId> - <version>${project.version}</version> - </dependency> + <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib-jdk8</artifactId> @@ -77,7 +78,6 @@ <version>${junit-jupiter.version}</version> <scope>test</scope> </dependency> - <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> @@ -120,4 +120,45 @@ </plugins> </build> + <profiles> + <profile> + <id>camel3</id> + <activation> + <property> + <name>camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-3</artifactId> + <scope>provided</scope> + </dependency> + <!-- test --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-properties</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + </profile> + <profile> + <id>camel2</id> + <activation> + <property> + <name>!camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-2</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> + </profile> + </profiles> + </project> diff --git a/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt b/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt index 8b09000..c31af21 100644 --- a/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt +++ b/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/LoaderTest.kt @@ -29,13 +29,15 @@ class LoaderTest { @Test fun `load route from classpath`() { + var context = DefaultCamelContext() var source = Source.create("classpath:routes.kts") - val loader = RuntimeSupport.loaderFor(DefaultCamelContext(), source) + val loader = RuntimeSupport.loaderFor(context, source) val builder = loader.load(InMemoryRegistry(), source) assertThat(loader).isInstanceOf(KotlinRoutesLoader::class.java) assertThat(builder).isNotNull + builder.context = context builder.configure() val routes = builder.routeCollection.routes diff --git a/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationTest.kt b/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationTest.kt index ca1f73c..9022b3c 100644 --- a/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationTest.kt +++ b/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationTest.kt @@ -1,3 +1,19 @@ +/** + * 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.Processor @@ -6,6 +22,7 @@ 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.model.ModelCamelContext import org.apache.camel.spi.ExchangeFormatter import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -24,8 +41,8 @@ class IntegrationTest { 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") + assertThat(runtime.context.adapt(ModelCamelContext::class.java).restDefinitions.size).isEqualTo(1) + assertThat(runtime.context.adapt(ModelCamelContext::class.java).restDefinitions[0].path).isEqualTo("/my/path") } @Test diff --git a/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/extension/LogExtensionTest.kt b/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/extension/LogExtensionTest.kt index 9d9a328..0d5a281 100644 --- a/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/extension/LogExtensionTest.kt +++ b/camel-k-runtime-kotlin/src/test/kotlin/org/apache/camel/k/kotlin/extension/LogExtensionTest.kt @@ -2,7 +2,7 @@ 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.apache.camel.k.adapter.Exchanges import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -16,7 +16,7 @@ class LogExtensionTest { e -> "body: " + e.getIn().body } - var ex = DefaultExchange(ctx) + var ex = Exchanges.newDefaultExchange(ctx) ex.getIn().body = "hello" assertThat(log.exchangeFormatter.format(ex)).isEqualTo("body: hello") diff --git a/camel-k-runtime-spring-boot/pom.xml b/camel-k-runtime-spring-boot/pom.xml index 70bb80b..1435109 100644 --- a/camel-k-runtime-spring-boot/pom.xml +++ b/camel-k-runtime-spring-boot/pom.xml @@ -42,7 +42,6 @@ <dependency> <groupId>org.apache.camel.k</groupId> <artifactId>camel-k-runtime-jvm</artifactId> - <version>${project.version}</version> <exclusions> <exclusion> <groupId>org.apache.logging.log4j</groupId> @@ -134,4 +133,45 @@ </plugin> </plugins> </build> + + <profiles> + <profile> + <id>camel3</id> + <activation> + <property> + <name>camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-3</artifactId> + <scope>provided</scope> + </dependency> + <!-- test --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-properties</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + </profile> + <profile> + <id>camel2</id> + <activation> + <property> + <name>!camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-2</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> + </profile> + </profiles> </project> diff --git a/camel-k-runtime-yaml/pom.xml b/camel-k-runtime-yaml/pom.xml index dac0cef..d528f0a 100644 --- a/camel-k-runtime-yaml/pom.xml +++ b/camel-k-runtime-yaml/pom.xml @@ -36,15 +36,15 @@ <!-- ****************************** --> <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-core</artifactId> - <scope>provided</scope> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-core</artifactId> </dependency> + <dependency> - <groupId>org.apache.camel.k</groupId> - <artifactId>camel-k-runtime-jvm</artifactId> - <version>${project.version}</version> + <groupId>org.apache.camel</groupId> + <artifactId>camel-core</artifactId> </dependency> + <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> @@ -74,7 +74,6 @@ <version>${junit-jupiter.version}</version> <scope>test</scope> </dependency> - <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> @@ -83,4 +82,45 @@ </dependency> </dependencies> + <profiles> + <profile> + <id>camel3</id> + <activation> + <property> + <name>camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-3</artifactId> + <scope>provided</scope> + </dependency> + <!-- test --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-properties</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + </profile> + <profile> + <id>camel2</id> + <activation> + <property> + <name>!camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-2</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> + </profile> + </profiles> + </project> diff --git a/camel-k-runtime-yaml/src/test/java/org/apache/camel/k/yaml/RoutesLoaderTest.java b/camel-k-runtime-yaml/src/test/java/org/apache/camel/k/yaml/RoutesLoaderTest.java index 1035306..2c77ad9 100644 --- a/camel-k-runtime-yaml/src/test/java/org/apache/camel/k/yaml/RoutesLoaderTest.java +++ b/camel-k-runtime-yaml/src/test/java/org/apache/camel/k/yaml/RoutesLoaderTest.java @@ -18,6 +18,7 @@ package org.apache.camel.k.yaml; 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.RoutesLoader; @@ -34,13 +35,15 @@ public class RoutesLoaderTest { @Test public void testLoadYamlFlow() throws Exception { + CamelContext context = new DefaultCamelContext(); Source source = Source.create("classpath:routes.flow"); - RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source); + RoutesLoader loader = RuntimeSupport.loaderFor(context, source); RouteBuilder builder = loader.load(new InMemoryRegistry(), source); assertThat(loader).isInstanceOf(YamlFlowLoader.class); assertThat(builder).isNotNull(); + builder.setContext(context); builder.configure(); List<RouteDefinition> routes = builder.getRouteCollection().getRoutes(); diff --git a/camel-knative-http/pom.xml b/camel-knative-http/pom.xml index b0a955e..9188acc 100644 --- a/camel-knative-http/pom.xml +++ b/camel-knative-http/pom.xml @@ -82,7 +82,6 @@ <version>${junit-jupiter.version}</version> <scope>test</scope> </dependency> - <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> @@ -105,4 +104,50 @@ </dependencies> + <profiles> + <profile> + <id>camel3</id> + <activation> + <property> + <name>camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-3</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>spi-annotations</artifactId> + <scope>provided</scope> + </dependency> + <!-- test --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-properties</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + </profile> + <profile> + <id>camel2</id> + <activation> + <property> + <name>!camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-2</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> + </profile> + </profiles> + </project> diff --git a/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpComponent.java b/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpComponent.java index 7287122..f639e68 100644 --- a/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpComponent.java +++ b/camel-knative-http/src/main/java/org/apache/camel/component/knative/http/KnativeHttpComponent.java @@ -39,9 +39,9 @@ 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.k.adapter.Services; 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; @@ -63,7 +63,7 @@ public class KnativeHttpComponent extends NettyHttpComponent { protected void doStop() throws Exception { super.doStop(); - ServiceHelper.stopService(handlers.values()); + Services.start(handlers.values()); handlers.clear(); } diff --git a/camel-knative/pom.xml b/camel-knative/pom.xml index f845ac6..7e51b29 100644 --- a/camel-knative/pom.xml +++ b/camel-knative/pom.xml @@ -42,6 +42,11 @@ </dependency> <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-knative-http</artifactId> + </dependency> + + <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-core</artifactId> <scope>provided</scope> @@ -51,11 +56,6 @@ <artifactId>camel-netty4-http</artifactId> <scope>provided</scope> </dependency> - <dependency> - <groupId>org.apache.camel.k</groupId> - <artifactId>camel-knative-http</artifactId> - <version>${project.version}</version> - </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> @@ -114,7 +114,6 @@ <version>${junit-jupiter.version}</version> <scope>test</scope> </dependency> - <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> @@ -137,4 +136,50 @@ </dependencies> + <profiles> + <profile> + <id>camel3</id> + <activation> + <property> + <name>camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-3</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>spi-annotations</artifactId> + <scope>provided</scope> + </dependency> + <!-- test --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-properties</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + </profile> + <profile> + <id>camel2</id> + <activation> + <property> + <name>!camel3</name> + </property> + </activation> + <dependencies> + <!-- runtime --> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-2</artifactId> + <scope>provided</scope> + </dependency> + </dependencies> + </profile> + </profiles> + </project> diff --git a/camel-knative/src/main/java/org/apache/camel/component/knative/Knative.java b/camel-knative/src/main/java/org/apache/camel/component/knative/Knative.java index ce701ef..4ea19d4 100644 --- a/camel-knative/src/main/java/org/apache/camel/component/knative/Knative.java +++ b/camel-knative/src/main/java/org/apache/camel/component/knative/Knative.java @@ -22,7 +22,6 @@ 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"; diff --git a/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java b/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java index 60b7835..19f9dff 100644 --- a/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java +++ b/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeComponent.java @@ -20,8 +20,8 @@ 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.k.adapter.DefaultComponent; +import org.apache.camel.k.adapter.Introspection; import org.apache.camel.util.StringHelper; public class KnativeComponent extends DefaultComponent { @@ -101,7 +101,7 @@ public class KnativeComponent extends DefaultComponent { final KnativeConfiguration conf = getKnativeConfiguration(); // set properties from the endpoint uri - IntrospectionSupport.setProperties(getCamelContext().getTypeConverter(), conf, parameters); + Introspection.setProperties(getCamelContext().getTypeConverter(), conf, parameters); return new KnativeEndpoint(uri, this, Knative.Type.valueOf(type), target, conf); } diff --git a/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java b/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java index 967f7dd..9d8a022 100644 --- a/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java +++ b/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeConfiguration.java @@ -17,12 +17,10 @@ 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") diff --git a/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java b/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java index cceb218..32752d9 100644 --- a/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java +++ b/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEndpoint.java @@ -27,14 +27,14 @@ 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.k.adapter.DefaultEndpoint; +import org.apache.camel.k.adapter.Services; 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; @@ -47,11 +47,9 @@ import org.apache.camel.util.URISupport; 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 @@ -83,12 +81,12 @@ public class KnativeEndpoint extends DefaultEndpoint implements DelegateEndpoint @Override protected void doStart() throws Exception { super.doStart(); - ServiceHelper.startService(endpoint); + Services.start(endpoint); } @Override protected void doStop() throws Exception { - ServiceHelper.stopService(endpoint); + Services.stop(endpoint); super.doStop(); } diff --git a/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEnvironment.java b/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEnvironment.java index efef0ca..52ca039 100644 --- a/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEnvironment.java +++ b/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeEnvironment.java @@ -34,8 +34,8 @@ 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.k.adapter.Resources; import org.apache.camel.util.CollectionHelper; -import org.apache.camel.util.ResourceHelper; import org.apache.camel.util.StringHelper; /* @@ -133,7 +133,7 @@ public class KnativeEnvironment { } public static KnativeEnvironment mandatoryLoadFromResource(CamelContext context, String path) throws Exception { - try (InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(context, path)) { + try (InputStream is = Resources.resolveResourceAsInputStream(context, path)) { // // read the knative environment from a file formatted as json, i.e. : diff --git a/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeProducer.java b/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeProducer.java index 740455f..3e3aee4 100644 --- a/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeProducer.java +++ b/camel-knative/src/main/java/org/apache/camel/component/knative/KnativeProducer.java @@ -24,10 +24,10 @@ 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.k.adapter.DefaultAsyncProducer; +import org.apache.camel.k.adapter.Processors; +import org.apache.camel.k.adapter.Services; 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 { @@ -43,7 +43,7 @@ public class KnativeProducer extends DefaultAsyncProducer { Processor pipeline = Pipeline.newInstance(endpoint.getCamelContext(), elements); - this.processor = AsyncProcessorConverterHelper.convert(pipeline); + this.processor = Processors.convertToAsync(pipeline); } @Override @@ -53,27 +53,27 @@ public class KnativeProducer extends DefaultAsyncProducer { @Override protected void doStart() throws Exception { - ServiceHelper.startServices(processor); + Services.start(processor); } @Override protected void doStop() throws Exception { - ServiceHelper.stopServices(processor); + Services.start(processor); } @Override protected void doSuspend() throws Exception { - ServiceHelper.suspendService(processor); + Services.suspend(processor); } @Override protected void doResume() throws Exception { - ServiceHelper.resumeService(processor); + Services.resume(processor); } @Override protected void doShutdown() throws Exception { - ServiceHelper.stopAndShutdownServices(processor); + Services.shutdown(processor); } } diff --git a/pom.xml b/pom.xml index f8d7405..b0038a5 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,9 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> - <camel.version>2.23.1</camel.version> + <camel2.version>2.23.1</camel2.version> + <camel3.version>3.0.0-M1</camel3.version> + <camel.version>${camel2.version}</camel.version> <catalog.version>${camel.version}</catalog.version> <junit.version>4.12</junit.version> <junit-jupiter.version>5.4.0</junit-jupiter.version> @@ -87,18 +89,6 @@ <tag>HEAD</tag> </scm> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.apache.camel</groupId> - <artifactId>camel-bom</artifactId> - <version>${camel.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - <build> <pluginManagement> <plugins> @@ -132,6 +122,8 @@ </build> <modules> + <module>camel-k-adapter-camel-3</module> + <module>camel-k-adapter-camel-2</module> <module>camel-k-maven-plugin</module> <module>camel-k-runtime-core</module> <module>camel-k-runtime-jvm</module> @@ -172,8 +164,107 @@ </pluginRepository> </pluginRepositories> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-3</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-adapter-camel-2</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-core</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-jvm</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-groovy</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-kotlin</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-yaml</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-spring-boot</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-k-runtime-spring-boot-layout</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-knative</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.k</groupId> + <artifactId>camel-knative-http</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + </dependencyManagement> + <profiles> <profile> + <id>camel3</id> + <activation> + <property> + <name>camel3</name> + </property> + </activation> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-bom</artifactId> + <version>${camel3.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + </profile> + <profile> + <id>camel2</id> + <activation> + <property> + <name>!camel3</name> + </property> + </activation> + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-bom</artifactId> + <version>${camel2.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + </profile> + + <profile> <id>deps</id> <activation> <activeByDefault>false</activeByDefault> @@ -240,78 +331,78 @@ </plugins> </build> </profile> -<profile> - <id>release</id> - <activation> - <property> - <name>release</name> - </property> - </activation> - <build> - <plugins> - <!-- We want to deploy the artifact to a staging location for perusal --> - <plugin> - <inherited>true</inherited> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-deploy-plugin</artifactId> - <configuration> - <updateReleaseInfo>true</updateReleaseInfo> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <executions> - <execution> - <id>attach-javadocs</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - <configuration> - <additionalOptions>${javadoc.opts}</additionalOptions> - </configuration> - </plugin> - <!-- We want to sign the artifact, the POM, and all attached artifacts --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-gpg-plugin</artifactId> - <configuration> - <passphrase>${gpg.passphrase}</passphrase> - <useAgent>${gpg.useagent}</useAgent> - </configuration> - <executions> - <execution> - <goals> - <goal>sign</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>doclint-java8-disable</id> - <activation> - <jdk>[1.8,)</jdk> - </activation> - <properties> - <javadoc.opts>-Xdoclint:none</javadoc.opts> - </properties> - </profile> + <profile> + <id>release</id> + <activation> + <property> + <name>release</name> + </property> + </activation> + <build> + <plugins> + <!-- We want to deploy the artifact to a staging location for perusal --> + <plugin> + <inherited>true</inherited> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <updateReleaseInfo>true</updateReleaseInfo> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <executions> + <execution> + <id>attach-javadocs</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + <configuration> + <additionalOptions>${javadoc.opts}</additionalOptions> + </configuration> + </plugin> + <!-- We want to sign the artifact, the POM, and all attached artifacts --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-gpg-plugin</artifactId> + <configuration> + <passphrase>${gpg.passphrase}</passphrase> + <useAgent>${gpg.useagent}</useAgent> + </configuration> + <executions> + <execution> + <goals> + <goal>sign</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>doclint-java8-disable</id> + <activation> + <jdk>[1.8,)</jdk> + </activation> + <properties> + <javadoc.opts>-Xdoclint:none</javadoc.opts> + </properties> + </profile> </profiles> </project>