From d5fb66eaf3d7f0d12a0b5ff15da4493b22222d62 Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Thu, 23 May 2019 00:38:17 +0200 Subject: [PATCH 1/2] switch to camel 3, drop support for camel 2.x --- .travis.yml | 6 +- camel-k-adapter-camel-2/pom.xml | 71 ------ .../camel/k/adapter/DefaultAsyncProducer.java | 25 --- .../camel/k/adapter/DefaultComponent.java | 28 --- .../camel/k/adapter/DefaultEndpoint.java | 27 --- .../camel/k/adapter/DefaultRegistry.java | 82 ------- .../apache/camel/k/adapter/Exceptions.java | 29 --- .../org/apache/camel/k/adapter/Exchanges.java | 30 --- .../apache/camel/k/adapter/Introspection.java | 43 ---- .../java/org/apache/camel/k/adapter/Main.java | 65 ------ .../org/apache/camel/k/adapter/Objects.java | 27 --- .../apache/camel/k/adapter/Processors.java | 30 --- .../org/apache/camel/k/adapter/Registry.java | 38 ---- .../org/apache/camel/k/adapter/Resources.java | 43 ---- .../org/apache/camel/k/adapter/Routes.java | 26 --- .../camel/k/adapter/ServiceSupport.java | 20 -- .../org/apache/camel/k/adapter/Services.java | 47 ---- camel-k-adapter-camel-3/pom.xml | 71 ------ .../camel/k/adapter/DefaultAsyncProducer.java | 25 --- .../camel/k/adapter/DefaultComponent.java | 28 --- .../camel/k/adapter/DefaultEndpoint.java | 27 --- .../camel/k/adapter/DefaultRegistry.java | 20 -- .../apache/camel/k/adapter/Exceptions.java | 28 --- .../org/apache/camel/k/adapter/Exchanges.java | 30 --- .../apache/camel/k/adapter/Introspection.java | 47 ---- .../java/org/apache/camel/k/adapter/Main.java | 57 ----- .../org/apache/camel/k/adapter/Objects.java | 27 --- .../apache/camel/k/adapter/Processors.java | 30 --- .../org/apache/camel/k/adapter/Registry.java | 20 -- .../org/apache/camel/k/adapter/Resources.java | 43 ---- .../org/apache/camel/k/adapter/Routes.java | 26 --- .../camel/k/adapter/ServiceSupport.java | 20 -- .../org/apache/camel/k/adapter/Services.java | 48 ----- camel-k-maven-plugin/pom.xml | 2 +- .../processors/CatalogProcessor_2_x.java | 204 ------------------ ...mel.k.tooling.maven.model.CatalogProcessor | 18 +- .../processors/CataloProcessor2Test.java | 118 ---------- camel-k-runtime-bom/pom.xml | 4 + camel-k-runtime-core/pom.xml | 47 +--- .../org/apache/camel/k/ContextCustomizer.java | 3 +- .../org/apache/camel/k/InMemoryRegistry.java | 22 -- .../java/org/apache/camel/k/RoutesLoader.java | 5 +- .../main/java/org/apache/camel/k/Runtime.java | 23 +- .../StreamCachingContextCustomizer.java | 3 +- .../k/listener/AbstractPhaseListener.java | 4 + .../camel/k/listener/ContextConfigurer.java | 2 +- .../camel/k/listener/RoutesConfigurer.java | 8 +- .../camel/k/support/PropertiesSupport.java | 4 +- .../camel/k/support/RuntimeSupport.java | 5 +- .../apache/camel/k/support/URIResolver.java | 4 +- .../camel/k/support/NameCustomizer.java | 6 +- .../camel/k/support/RuntimeSupportTest.java | 53 ++--- .../StreamCachingContextCustomizerTest.java | 7 +- .../camel-k-runtime-example-health/pom.xml | 35 +-- .../camel-k-runtime-example-servlet/pom.xml | 35 +-- camel-k-runtime-examples/pom.xml | 2 +- camel-k-runtime-groovy/pom.xml | 57 ++--- .../camel/k/groovy/GroovyRoutesLoader.groovy | 8 +- .../groovy/dsl/ComponentConfiguration.groovy | 8 +- .../k/groovy/dsl/ContextConfiguration.groovy | 7 +- .../dsl/IntegrationConfiguration.groovy | 12 +- .../k/groovy/dsl/RegistryConfiguration.groovy | 7 +- .../apache/camel/k/groovy/LoaderTest.groovy | 7 +- .../dsl/extension/LogExtensionTest.groovy | 4 +- camel-k-runtime-health/pom.xml | 48 +---- .../k/health/HealthContextCustomizer.java | 5 +- .../camel/k/health/HealthCustomizerTest.java | 8 +- camel-k-runtime-jvm/pom.xml | 48 +---- .../camel/k/jvm/ApplicationRuntime.java | 28 +-- .../camel/k/jvm/loader/JavaClassLoader.java | 4 +- .../camel/k/jvm/loader/JavaScriptLoader.java | 5 +- .../camel/k/jvm/loader/JavaSourceLoader.java | 3 +- .../apache/camel/k/jvm/loader/XmlLoader.java | 10 +- .../apache/camel/k/jvm/PropertiesTest.java | 2 +- .../camel/k/jvm/RoutesLoadersCommonTest.java | 6 +- .../apache/camel/k/jvm/RoutesLoadersTest.java | 15 +- .../org/apache/camel/k/jvm/RuntimeTest.java | 4 - .../apache/camel/k/jvm/TestCustomizer.java | 3 +- camel-k-runtime-kotlin/pom.xml | 49 +---- .../camel/k/kotlin/KotlinRoutesLoader.kt | 6 +- .../k/kotlin/dsl/ContextConfiguration.kt | 2 +- .../k/kotlin/dsl/IntegrationConfiguration.kt | 2 +- .../k/kotlin/dsl/RegistryConfiguration.kt | 3 +- .../org/apache/camel/k/kotlin/LoaderTest.kt | 6 +- .../k/kotlin/extension/LogExtensionTest.kt | 4 +- camel-k-runtime-servlet/pom.xml | 48 +---- .../k/servlet/ServletContextCustomizer.java | 3 +- .../camel/k/servlet/ServletEndpoint.java | 2 +- .../k/servlet/ServletCustomizerTest.java | 6 +- camel-k-runtime-yaml/pom.xml | 49 +---- .../apache/camel/k/yaml/YamlFlowLoader.java | 4 +- .../apache/camel/k/yaml/RoutesLoaderTest.java | 6 +- camel-knative-http/pom.xml | 60 ++---- .../knative/http/KnativeHttpComponent.java | 11 +- camel-knative/pom.xml | 139 ++++-------- .../component/knative/KnativeComponent.java | 6 +- .../component/knative/KnativeEndpoint.java | 18 +- .../component/knative/KnativeEnvironment.java | 18 +- .../component/knative/KnativeProducer.java | 18 +- .../component/knative/KnativeSupport.java | 1 + distribution/pom.xml | 2 +- pom.xml | 61 +----- 102 files changed, 316 insertions(+), 2305 deletions(-) delete mode 100644 camel-k-adapter-camel-2/pom.xml delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultAsyncProducer.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultComponent.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultEndpoint.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultRegistry.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Exceptions.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Exchanges.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Introspection.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Main.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Objects.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Processors.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Registry.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Resources.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Routes.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/ServiceSupport.java delete mode 100644 camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Services.java delete mode 100644 camel-k-adapter-camel-3/pom.xml delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultAsyncProducer.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultComponent.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultEndpoint.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultRegistry.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Exceptions.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Exchanges.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Introspection.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Main.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Objects.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Processors.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Registry.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Resources.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Routes.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/ServiceSupport.java delete mode 100644 camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Services.java delete mode 100644 camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java delete mode 100644 camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CataloProcessor2Test.java delete mode 100644 camel-k-runtime-core/src/main/java/org/apache/camel/k/InMemoryRegistry.java diff --git a/.travis.yml b/.travis.yml index 8d42bcff1..def5998f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,8 +19,4 @@ language: java script: - - ./mvnw clean install -Dcamel2 - - ./mvnw clean install -Dcamel2 -Dcamel2.version=2.21.0 - - ./mvnw clean install -Dcamel2 -Dcamel2.version=2.22.0 - - ./mvnw clean install -Dcamel2 -Dcamel2.version=2.23.0 - - ./mvnw clean install -Dcamel3 + - ./mvnw clean install diff --git a/camel-k-adapter-camel-2/pom.xml b/camel-k-adapter-camel-2/pom.xml deleted file mode 100644 index 256a7e48b..000000000 --- a/camel-k-adapter-camel-2/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - org.apache.camel.k - camel-k-runtime-parent - 0.3.4-SNAPSHOT - - 4.0.0 - - camel-k-adapter-camel-2 - - - - - - - - - - - org.apache.camel - camel-core - ${camel2.version} - provided - - - - - - - - - - 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/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 deleted file mode 100644 index 4e3f500cf..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultAsyncProducer.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. - */ -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 deleted file mode 100644 index 01a0f6012..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultComponent.java +++ /dev/null @@ -1,28 +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.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 deleted file mode 100644 index bd998e0ff..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultEndpoint.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.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/DefaultRegistry.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultRegistry.java deleted file mode 100644 index a29ef4256..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/DefaultRegistry.java +++ /dev/null @@ -1,82 +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.adapter; - -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 class DefaultRegistry implements Registry { - private final ConcurrentMap registry; - - public DefaultRegistry() { - this.registry = new ConcurrentHashMap<>(); - } - - @Override - 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/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Exceptions.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Exceptions.java deleted file mode 100644 index b70aceed5..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Exceptions.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.k.adapter; - -import org.apache.camel.RuntimeCamelException; -import org.apache.camel.util.ObjectHelper; - -public final class Exceptions { - private Exceptions() { - } - - public static RuntimeCamelException wrapRuntimeCamelException(Throwable e) { - return ObjectHelper.wrapRuntimeCamelException(e); - } -} 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 deleted file mode 100644 index 8d6de5eb9..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Exchanges.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.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 deleted file mode 100644 index e08b1f61c..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Introspection.java +++ /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.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 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 properties, String optionPrefix, boolean includeNull) { - return IntrospectionSupport.getProperties(target, properties, optionPrefix, includeNull); - } -} diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Main.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Main.java deleted file mode 100644 index b40c68e17..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Main.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.adapter; - - -import java.util.Collections; -import java.util.Map; - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; - -public class Main extends org.apache.camel.main.MainSupport { - private CamelContext context; - - public Main(CamelContext context) { - this.context = context; - } - - @Override - protected ProducerTemplate findOrCreateCamelTemplate() { - return context.createProducerTemplate(); - } - - @Override - protected Map getCamelContextMap() { - return Collections.singletonMap(context.getName(), context); - } - - @Override - protected void doStart() throws Exception { - super.doStart(); - postProcessContext(); - - try { - context.start(); - } finally { - if (context.isVetoStarted()) { - completed(); - } - } - } - - @Override - protected void doStop() throws Exception { - super.doStop(); - - if (!getCamelContexts().isEmpty()) { - context.stop(); - } - } -} \ No newline at end of file diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Objects.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Objects.java deleted file mode 100644 index 00e0bc526..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Objects.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.adapter; - -import java.util.Iterator; - -import org.apache.camel.util.ObjectHelper; - -public final class Objects { - public static Iterator createIterator(Object value, String delimiter, boolean allowEmptyValues) { - return ObjectHelper.createIterator(value, delimiter, allowEmptyValues); - } -} diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Processors.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Processors.java deleted file mode 100644 index 24c580eb6..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Processors.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.adapter; - -import org.apache.camel.AsyncProcessor; -import org.apache.camel.Processor; -import org.apache.camel.util.AsyncProcessorConverterHelper; - -public final class Processors { - private Processors() { - } - - public static AsyncProcessor convertToAsync(Processor processor) { - return AsyncProcessorConverterHelper.convert(processor); - } -} diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Registry.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Registry.java deleted file mode 100644 index 0f2e20e88..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Registry.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.adapter; - -import java.util.Map; - -public interface Registry extends org.apache.camel.spi.Registry { - void bind(String name, Object bean); - - @SuppressWarnings("deprecation") - default public Object lookup(String name) { - return lookupByName(name); - } - - @SuppressWarnings("deprecation") - default public T lookup(String name, Class type) { - return lookupByNameAndType(name, type); - } - - @SuppressWarnings("deprecation") - default public Map lookupByType(Class type) { - return findByTypeWithName(type); - } -} \ No newline at end of file diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Resources.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Resources.java deleted file mode 100644 index 961223b55..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Resources.java +++ /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.adapter; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.camel.CamelContext; -import org.apache.camel.model.ModelHelper; -import org.apache.camel.model.RoutesDefinition; -import org.apache.camel.model.rest.RestsDefinition; -import org.apache.camel.util.ResourceHelper; - -public final class Resources { - private Resources() { - } - - public static InputStream resolveResourceAsInputStream(CamelContext camelContext, String uri) throws IOException { - return ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, uri); - } - - public static RoutesDefinition loadRoutesDefinition(CamelContext camelContext, InputStream is) throws Exception { - return camelContext.loadRoutesDefinition(is); - } - - public static RestsDefinition loadRestsDefinition(CamelContext camelContext, InputStream is) throws Exception { - return camelContext.loadRestsDefinition(is); - } -} diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Routes.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Routes.java deleted file mode 100644 index 7bc27f231..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Routes.java +++ /dev/null @@ -1,26 +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.adapter; - -import org.apache.camel.model.FromDefinition; -import org.apache.camel.model.RouteDefinition; - -public final class Routes { - public static FromDefinition getInput(RouteDefinition definition) { - return definition.getInputs().get(0); - } -} \ No newline at end of file diff --git a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/ServiceSupport.java b/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/ServiceSupport.java deleted file mode 100644 index c7ed213f4..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/ServiceSupport.java +++ /dev/null @@ -1,20 +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.adapter; - -public abstract class ServiceSupport extends org.apache.camel.support.ServiceSupport { -} 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 deleted file mode 100644 index 560021f19..000000000 --- a/camel-k-adapter-camel-2/src/main/java/org/apache/camel/k/adapter/Services.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.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-adapter-camel-3/pom.xml b/camel-k-adapter-camel-3/pom.xml deleted file mode 100644 index 4342c1525..000000000 --- a/camel-k-adapter-camel-3/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - org.apache.camel.k - camel-k-runtime-parent - 0.3.4-SNAPSHOT - - 4.0.0 - - camel-k-adapter-camel-3 - - - - - - - - - - - org.apache.camel - camel-core - ${camel3.version} - provided - - - - - - - - - - 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/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 deleted file mode 100644 index 5fe22b08f..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultAsyncProducer.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. - */ -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 deleted file mode 100644 index a9f746f20..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultComponent.java +++ /dev/null @@ -1,28 +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.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 deleted file mode 100644 index db3845493..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultEndpoint.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.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/DefaultRegistry.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultRegistry.java deleted file mode 100644 index cc1bdf578..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/DefaultRegistry.java +++ /dev/null @@ -1,20 +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.adapter; - -public class DefaultRegistry extends org.apache.camel.support.DefaultRegistry implements Registry { -} diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Exceptions.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Exceptions.java deleted file mode 100644 index dc4cb0119..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Exceptions.java +++ /dev/null @@ -1,28 +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.adapter; - -import org.apache.camel.RuntimeCamelException; - -public final class Exceptions { - private Exceptions() { - } - - public static RuntimeCamelException wrapRuntimeCamelException(Throwable e) { - return RuntimeCamelException.wrapRuntimeCamelException(e); - } -} 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 deleted file mode 100644 index 4e5696225..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Exchanges.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.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 deleted file mode 100644 index 2afca1355..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Introspection.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.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 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 getProperties(Object target, String optionPrefix, boolean includeNull) { - Map properties = new HashMap<>(); - IntrospectionSupport.getProperties(target, properties, optionPrefix, includeNull); - - return properties; - } -} diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Main.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Main.java deleted file mode 100644 index 95d10883e..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Main.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.adapter; - - -import org.apache.camel.CamelContext; -import org.apache.camel.ProducerTemplate; - -public class Main extends org.apache.camel.main.MainSupport { - public Main(CamelContext context) { - this.camelContext = context; - } - - @Override - protected void doStart() throws Exception { - super.doStart(); - postProcessCamelContext(camelContext); - - try { - // if we were veto started then mark as completed - this.camelContext.start(); - } finally { - if (this.camelContext.isVetoStarted()) { - completed(); - } - } - } - - protected void doStop() throws Exception { - super.doStop(); - this.camelContext.stop(); - } - - @Override - protected ProducerTemplate findOrCreateCamelTemplate() { - return this.camelContext.createProducerTemplate(); - } - - @Override - protected CamelContext createCamelContext() { - return this.camelContext; - } -} \ No newline at end of file diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Objects.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Objects.java deleted file mode 100644 index 1911e4ec1..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Objects.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.adapter; - -import java.util.Iterator; - -import org.apache.camel.support.ObjectHelper; - -public final class Objects { - public static Iterator createIterator(Object value, String delimiter, boolean allowEmptyValues) { - return ObjectHelper.createIterator(value, delimiter, allowEmptyValues); - } -} diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Processors.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Processors.java deleted file mode 100644 index 585dfa4a3..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Processors.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.adapter; - -import org.apache.camel.AsyncProcessor; -import org.apache.camel.Processor; -import org.apache.camel.support.AsyncProcessorConverterHelper; - -public final class Processors { - private Processors() { - } - - public static AsyncProcessor convertToAsync(Processor processor) { - return AsyncProcessorConverterHelper.convert(processor); - } -} diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Registry.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Registry.java deleted file mode 100644 index c007f2d2f..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Registry.java +++ /dev/null @@ -1,20 +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.adapter; - -public interface Registry extends org.apache.camel.spi.Registry { -} \ No newline at end of file diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Resources.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Resources.java deleted file mode 100644 index 072478fa1..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Resources.java +++ /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.adapter; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.camel.CamelContext; -import org.apache.camel.model.ModelHelper; -import org.apache.camel.model.RoutesDefinition; -import org.apache.camel.model.rest.RestsDefinition; -import org.apache.camel.support.ResourceHelper; - -public final class Resources { - private Resources() { - } - - public static InputStream resolveResourceAsInputStream(CamelContext camelContext, String uri) throws IOException { - return ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, uri); - } - - public static RoutesDefinition loadRoutesDefinition(CamelContext camelContext, InputStream is) throws Exception { - return ModelHelper.loadRoutesDefinition(camelContext, is); - } - - public static RestsDefinition loadRestsDefinition(CamelContext camelContext, InputStream is) throws Exception { - return ModelHelper.loadRestsDefinition(camelContext, is); - } -} diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Routes.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Routes.java deleted file mode 100644 index 3cb96f29a..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Routes.java +++ /dev/null @@ -1,26 +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.adapter; - -import org.apache.camel.model.FromDefinition; -import org.apache.camel.model.RouteDefinition; - -public final class Routes { - public static FromDefinition getInput(RouteDefinition definition) { - return definition.getInput(); - } -} \ No newline at end of file diff --git a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/ServiceSupport.java b/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/ServiceSupport.java deleted file mode 100644 index 26c8c7218..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/ServiceSupport.java +++ /dev/null @@ -1,20 +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.adapter; - -public abstract class ServiceSupport extends org.apache.camel.support.service.ServiceSupport { -} 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 deleted file mode 100644 index fbf07f53d..000000000 --- a/camel-k-adapter-camel-3/src/main/java/org/apache/camel/k/adapter/Services.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.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 58894b55c..30c071637 100644 --- a/camel-k-maven-plugin/pom.xml +++ b/camel-k-maven-plugin/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-parent - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 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 deleted file mode 100644 index 82102954f..000000000 --- a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_2_x.java +++ /dev/null @@ -1,204 +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.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) { - Semver semver = new Semver(catalog.getCatalogVersion(), Semver.SemverType.IVY); - return semver.isGreaterThanOrEqualTo("2.18.0") && semver.isLowerThan("3.0.0"); - } - - @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.addDependency("org.apache.camel", "camel-core"); - artifact.addDependency("org.apache.camel.k", "camel-k-adapter-camel-2"); - - 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.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"); - - 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"); - - artifacts.put(artifact.getArtifactId(), artifact); - } - - // ************************ - // - // camel-knative - // - // ************************ - - { - CamelArtifact artifact = new CamelArtifact(); - artifact.setGroupId("org.apache.camel.k"); - artifact.setArtifactId("camel-knative"); - artifact.createScheme("knative").setHttp(true); - artifact.addDependency("org.apache.camel", "camel-netty4-http"); - - artifacts.put(artifact.getArtifactId(), artifact); - } - - // ************************ - // - // camel-k-runtime-health - // - // ************************ - - { - CamelArtifact artifact = new CamelArtifact(); - artifact.setGroupId("org.apache.camel.k"); - artifact.setArtifactId("camel-k-runtime-health"); - artifact.addDependency("org.apache.camel", "camel-netty4-http"); - - artifacts.put(artifact.getArtifactId(), artifact); - } - - // ************************ - // - // camel-k-runtime-servlet - // - // ************************ - - { - CamelArtifact artifact = new CamelArtifact(); - artifact.setGroupId("org.apache.camel.k"); - artifact.setArtifactId("camel-k-runtime-servlet"); - artifact.addDependency("org.apache.camel", "camel-servlet"); - - 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/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 5a778d44f..aa4e3bc1e 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,2 +1,18 @@ -org.apache.camel.k.tooling.maven.processors.CatalogProcessor_2_x +# +# 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. +# + org.apache.camel.k.tooling.maven.processors.CatalogProcessor_3_x diff --git a/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CataloProcessor2Test.java b/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CataloProcessor2Test.java deleted file mode 100644 index b980ed452..000000000 --- a/camel-k-maven-plugin/src/test/java/org/apache/camel/k/tooling/maven/processors/CataloProcessor2Test.java +++ /dev/null @@ -1,118 +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.HashMap; -import java.util.Map; - -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; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CataloProcessor2Test extends AbstractCataloProcessorTest { - - @Test - public void testAcceptHyphen(){ - CatalogProcessor_2_x cp2 = new CatalogProcessor_2_x(); - - CamelCatalog catalog = versionCamelCatalog("2.21.0.acme-123456"); - - assertThat(cp2.accepts(catalog)).isTrue(); - } - - @Test - public void testAcceptEqualToLower(){ - CatalogProcessor_2_x cp2 = new CatalogProcessor_2_x(); - - CamelCatalog catalog = versionCamelCatalog("2.18.0"); - - assertThat(cp2.accepts(catalog)).isTrue(); - } - - @Test - public void testAcceptLessThanLower(){ - CatalogProcessor_2_x cp2 = new CatalogProcessor_2_x(); - - CamelCatalog catalog = versionCamelCatalog("2.17.0"); - - assertThat(cp2.accepts(catalog)).isFalse(); - } - - @Test - public void testAcceptEqualToHigher(){ - CatalogProcessor_2_x cp2 = new CatalogProcessor_2_x(); - - CamelCatalog catalog = versionCamelCatalog("3.0.0"); - - assertThat(cp2.accepts(catalog)).isFalse(); - } - - @Test - public void testAcceptMoreThanHigher(){ - CatalogProcessor_2_x cp2 = new CatalogProcessor_2_x(); - - CamelCatalog catalog = versionCamelCatalog("4.0.0"); - - assertThat(cp2.accepts(catalog)).isFalse(); - } - - @Test - public void testArtifactsEnrichment(){ - CatalogProcessor processor = new CatalogProcessor_2_x(); - CamelCatalog catalog = versionCamelCatalog("2.23.2"); - Map artifactMap = new HashMap<>(); - - assertThat(processor.accepts(catalog)).isTrue(); - processor.process(new MavenProject(), catalog, artifactMap); - - - assertThat(artifactMap.get("camel-k-runtime-jvm")).satisfies(a -> { - assertThat(a.getDependencies()).anyMatch( - d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-core") - ); - assertThat(a.getDependencies()).anyMatch( - d -> d.getGroupId().equals("org.apache.camel.k") && d.getArtifactId().equals("camel-k-adapter-camel-2") - ); - }); - assertThat(artifactMap.get("camel-k-runtime-groovy")).satisfies(a -> { - assertThat(a.getDependencies()).anyMatch( - d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-groovy") - ); - }); - assertThat(artifactMap.get("camel-k-runtime-health")).satisfies(a -> { - assertThat(a.getDependencies()).anyMatch( - d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-netty4-http") - ); - }); - assertThat(artifactMap.get("camel-k-runtime-servlet")).satisfies(a -> { - assertThat(a.getDependencies()).anyMatch( - d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-servlet") - ); - }); - - assertThat(artifactMap.get("camel-knative")).satisfies(a -> { - assertThat(a.getDependencies()).anyMatch( - d -> d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-netty4-http") - ); - }); - } -} diff --git a/camel-k-runtime-bom/pom.xml b/camel-k-runtime-bom/pom.xml index 85ac1097f..2de779589 100644 --- a/camel-k-runtime-bom/pom.xml +++ b/camel-k-runtime-bom/pom.xml @@ -28,7 +28,11 @@ 4.0.0 org.apache.camel.k camel-k-runtime-bom +<<<<<<< HEAD 0.3.4-SNAPSHOT +======= + 1.0.0-SNAPSHOT +>>>>>>> switch to camel 3, drop support for camel 2.x pom diff --git a/camel-k-runtime-core/pom.xml b/camel-k-runtime-core/pom.xml index a6e49e811..3bd6d1961 100644 --- a/camel-k-runtime-core/pom.xml +++ b/camel-k-runtime-core/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-parent - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 @@ -41,11 +41,21 @@ ${slf4j.version} + + org.apache.camel + camel-api + provided + org.apache.camel camel-core provided + + org.apache.camel + camel-properties + provided + org.apache.commons @@ -117,39 +127,4 @@ - - - camel3 - - - camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-3 - provided - - - - - camel2 - - - !camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-2 - provided - - - - - diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/ContextCustomizer.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/ContextCustomizer.java index d3fc841e5..2448a4695 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/ContextCustomizer.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/ContextCustomizer.java @@ -25,9 +25,8 @@ public interface ContextCustomizer extends Ordered, Comparable camelContext; } } diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/customizer/StreamCachingContextCustomizer.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/customizer/StreamCachingContextCustomizer.java index 99b2f7c52..e674eb2df 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/customizer/StreamCachingContextCustomizer.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/customizer/StreamCachingContextCustomizer.java @@ -18,7 +18,6 @@ import org.apache.camel.CamelContext; import org.apache.camel.k.ContextCustomizer; -import org.apache.camel.k.Runtime; import org.apache.camel.spi.StreamCachingStrategy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -109,7 +108,7 @@ public void setRemoveSpoolDirectoryWhenStopping(boolean removeSpoolDirectoryWhen } @Override - public void apply(CamelContext camelContext, Runtime.Registry runtimeRegistry) { + public void apply(CamelContext camelContext) { camelContext.setStreamCaching(isEnabled()); camelContext.getStreamCachingStrategy().setAnySpoolRules(isAnySpoolRules()); camelContext.getStreamCachingStrategy().setBufferSize(getBufferSize()); diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/AbstractPhaseListener.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/AbstractPhaseListener.java index 7678acc68..17574b1fd 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/AbstractPhaseListener.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/AbstractPhaseListener.java @@ -17,6 +17,10 @@ package org.apache.camel.k.listener; import org.apache.camel.k.Runtime; +import org.apache.camel.CamelContext; +import org.apache.camel.component.servlet.CamelHttpTransportServlet; +import org.apache.camel.k.ContextCustomizer; +import org.apache.camel.k.servlet.ServletRegistration; public abstract class AbstractPhaseListener implements Runtime.Listener { private final Runtime.Phase phase; diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextConfigurer.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextConfigurer.java index af806c7e7..bd92177c8 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextConfigurer.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextConfigurer.java @@ -47,6 +47,6 @@ protected void accept(Runtime runtime) { // This is useful to configure services such as the ClusterService, // RouteController, etc // - RuntimeSupport.configureContext(runtime.getContext(), runtime.getRegistry()); + RuntimeSupport.configureContext(runtime.getContext()); } } diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java index 3b2c89c44..22de71cde 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java @@ -16,12 +16,12 @@ */ package org.apache.camel.k.listener; +import org.apache.camel.RuntimeCamelException; 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.adapter.Exceptions; import org.apache.camel.k.support.RuntimeSupport; import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; @@ -63,9 +63,9 @@ protected void load(Runtime runtime, String[] routes) { try { source = Source.create(route); loader = RuntimeSupport.loaderFor(runtime.getContext(), source); - builder = loader.load(runtime.getRegistry(), source); + builder = loader.load(runtime.getContext(), source); } catch (Exception e) { - throw Exceptions.wrapRuntimeCamelException(e); + throw RuntimeCamelException.wrapRuntimeCamelException(e); } if (builder == null) { @@ -77,7 +77,7 @@ protected void load(Runtime runtime, String[] routes) { try { runtime.getContext().addRoutes(builder); } catch (Exception e) { - throw Exceptions.wrapRuntimeCamelException(e); + throw RuntimeCamelException.wrapRuntimeCamelException(e); } } } diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/PropertiesSupport.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/PropertiesSupport.java index 8c5ee2782..1b3c3635d 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/PropertiesSupport.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/support/PropertiesSupport.java @@ -34,7 +34,7 @@ import org.apache.camel.CamelContext; import org.apache.camel.component.properties.PropertiesComponent; import org.apache.camel.k.Constants; -import org.apache.camel.k.adapter.Introspection; +import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.util.ObjectHelper; import org.apache.commons.io.FilenameUtils; @@ -78,7 +78,7 @@ public static int bindProperties(Properties properties, Object target, String pr final Object val = entry.getValue(); try { - if (Introspection.setProperty(target, key, val)) { + if (IntrospectionSupport.setProperty(target, key, val)) { count.incrementAndGet(); } } catch (Exception ex) { 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 d74be380a..c6f4ec6ab 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 @@ -33,7 +33,6 @@ 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; @@ -48,7 +47,7 @@ public final class RuntimeSupport { private RuntimeSupport() { } - public static List configureContext(CamelContext context, Runtime.Registry registry) { + public static List configureContext(CamelContext context) { List appliedCustomizers = new ArrayList<>(); Map customizers = lookupCustomizers(context); @@ -58,7 +57,7 @@ public static List configureContext(CamelContext context, Run LOGGER.info("Apply ContextCustomizer with id={} and type={}", e.getKey(), e.getValue().getClass().getName()); PropertiesSupport.bindProperties(context, e.getValue(), "customizer." + e.getKey() + "."); - e.getValue().apply(context, registry); + e.getValue().apply(context); appliedCustomizers.add(e.getValue()); }); 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 335284011..7f92c6b13 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 org.apache.camel.CamelContext; import org.apache.camel.k.Constants; import org.apache.camel.k.Source; -import org.apache.camel.k.adapter.Resources; +import org.apache.camel.support.ResourceHelper; import org.apache.camel.util.StringHelper; @@ -46,7 +46,7 @@ public static InputStream resolve(CamelContext ctx, Source source) throws Except // Using platform encoding on purpose is = new ByteArrayInputStream(content.getBytes()); } else { - is = Resources.resolveResourceAsInputStream(ctx, source.getLocation()); + is = ResourceHelper.resolveResourceAsInputStream(ctx.getClassResolver(), source.getLocation()); } return source.isCompressed() ? new GZIPInputStream(Base64.getDecoder().wrap(is)) : is; diff --git a/camel-k-runtime-core/src/test/java/org/apache/camel/k/support/NameCustomizer.java b/camel-k-runtime-core/src/test/java/org/apache/camel/k/support/NameCustomizer.java index 0c19cba88..ef9bedeb6 100644 --- a/camel-k-runtime-core/src/test/java/org/apache/camel/k/support/NameCustomizer.java +++ b/camel-k-runtime-core/src/test/java/org/apache/camel/k/support/NameCustomizer.java @@ -20,7 +20,7 @@ import org.apache.camel.Ordered; import org.apache.camel.impl.ExplicitCamelContextNameStrategy; import org.apache.camel.k.ContextCustomizer; -import org.apache.camel.k.Runtime; +import org.apache.camel.model.ModelCamelContext; public final class NameCustomizer implements ContextCustomizer { private String name; @@ -39,7 +39,7 @@ public int getOrder() { } @Override - public void apply(CamelContext camelContext, Runtime.Registry registry) { - camelContext.setNameStrategy(new ExplicitCamelContextNameStrategy(name)); + public void apply(CamelContext camelContexty) { + camelContexty.adapt(ModelCamelContext.class).setNameStrategy(new ExplicitCamelContextNameStrategy(name)); } } diff --git a/camel-k-runtime-core/src/test/java/org/apache/camel/k/support/RuntimeSupportTest.java b/camel-k-runtime-core/src/test/java/org/apache/camel/k/support/RuntimeSupportTest.java index 0ce719bab..e4fde91df 100644 --- a/camel-k-runtime-core/src/test/java/org/apache/camel/k/support/RuntimeSupportTest.java +++ b/camel-k-runtime-core/src/test/java/org/apache/camel/k/support/RuntimeSupportTest.java @@ -26,8 +26,6 @@ import org.apache.camel.impl.ExplicitCamelContextNameStrategy; import org.apache.camel.k.Constants; import org.apache.camel.k.ContextCustomizer; -import org.apache.camel.k.InMemoryRegistry; -import org.apache.camel.k.Runtime; import org.apache.camel.spi.RestConfiguration; import org.junit.jupiter.api.Test; @@ -38,14 +36,13 @@ public class RuntimeSupportTest { @Test public void testLoadCustomizersWithPropertiesFlags() { PropertiesComponent pc = new PropertiesComponent(); - Runtime.Registry registry = new InMemoryRegistry(); - CamelContext context = new DefaultCamelContext(registry); + CamelContext context = new DefaultCamelContext(); context.addComponent("properties", pc); NameCustomizer customizer = new NameCustomizer("from-registry"); - registry.bind("name", customizer); + context.getRegistry().bind("name", customizer); - List customizers = RuntimeSupport.configureContext(context, registry); + List customizers = RuntimeSupport.configureContext(context); assertThat(context.getName()).isNotEqualTo("from-registry"); assertThat(context.getName()).isNotEqualTo("default"); assertThat(customizers).hasSize(0); @@ -54,7 +51,7 @@ public void testLoadCustomizersWithPropertiesFlags() { properties.setProperty("customizer.name.enabled", "true"); pc.setInitialProperties(properties); - customizers = RuntimeSupport.configureContext(context, registry); + customizers = RuntimeSupport.configureContext(context); assertThat(context.getName()).isEqualTo("from-registry"); assertThat(customizers).hasSize(1); } @@ -62,14 +59,13 @@ public void testLoadCustomizersWithPropertiesFlags() { @Test public void testLoadCustomizersWithList() { PropertiesComponent pc = new PropertiesComponent(); - Runtime.Registry registry = new InMemoryRegistry(); - CamelContext context = new DefaultCamelContext(registry); + CamelContext context = new DefaultCamelContext(); context.addComponent("properties", pc); NameCustomizer customizer = new NameCustomizer("from-registry"); - registry.bind("name", customizer); + context.getRegistry().bind("name", customizer); - List customizers = RuntimeSupport.configureContext(context, registry); + List customizers = RuntimeSupport.configureContext(context); assertThat(context.getName()).isNotEqualTo("from-registry"); assertThat(context.getName()).isNotEqualTo("default"); assertThat(customizers).hasSize(0); @@ -78,7 +74,7 @@ public void testLoadCustomizersWithList() { properties.setProperty(Constants.PROPERTY_CAMEL_K_CUSTOMIZER, "name"); pc.setInitialProperties(properties); - customizers = RuntimeSupport.configureContext(context, registry); + customizers = RuntimeSupport.configureContext(context); assertThat(context.getName()).isEqualTo("from-registry"); assertThat(customizers).hasSize(1); } @@ -86,13 +82,11 @@ public void testLoadCustomizersWithList() { @Test public void testLoadCustomizers() { PropertiesComponent pc = new PropertiesComponent(); - Runtime.Registry registry = new InMemoryRegistry(); - CamelContext context = new DefaultCamelContext(registry); + CamelContext context = new DefaultCamelContext(); context.addComponent("properties", pc); + context.getRegistry().bind("converters", (ContextCustomizer) (camelContext) -> camelContext.setLoadTypeConverters(false)); - registry.bind("converters", (ContextCustomizer) (camelContext, registry1) -> camelContext.setLoadTypeConverters(false)); - - List customizers = RuntimeSupport.configureContext(context, registry); + List customizers = RuntimeSupport.configureContext(context); assertThat(context.getName()).isNotEqualTo("from-registry"); assertThat(context.getName()).isNotEqualTo("default"); assertThat(context.isLoadTypeConverters()).isTrue(); @@ -102,14 +96,14 @@ public void testLoadCustomizers() { properties.setProperty("customizer.name.enabled", "true"); pc.setInitialProperties(properties); - customizers = RuntimeSupport.configureContext(context, registry); + customizers = RuntimeSupport.configureContext(context); assertThat(context.getName()).isEqualTo("default"); assertThat(customizers).hasSize(1); properties.setProperty("customizer.converters.enabled", "true"); pc.setInitialProperties(properties); - customizers = RuntimeSupport.configureContext(context, registry); + customizers = RuntimeSupport.configureContext(context); assertThat(context.getName()).isEqualTo("default"); assertThat(context.isLoadTypeConverters()).isFalse(); assertThat(customizers).hasSize(2); @@ -118,36 +112,34 @@ public void testLoadCustomizers() { @Test public void testLoadCustomizerOrder() { PropertiesComponent pc = new PropertiesComponent(); - Runtime.Registry registry = new InMemoryRegistry(); - DefaultCamelContext context = new DefaultCamelContext(registry); + DefaultCamelContext context = new DefaultCamelContext(); context.setName("camel"); context.addComponent("properties", pc); - - registry.bind("c1", new ContextCustomizer() { + context.getRegistry().bind("c1", new ContextCustomizer() { @Override public int getOrder() { return Ordered.LOWEST; } @Override - public void apply(CamelContext camelContext, Runtime.Registry registry) { + public void apply(CamelContext camelContext) { camelContext.setNameStrategy(new ExplicitCamelContextNameStrategy(camelContext.getName() + "-c1")); } }); - registry.bind("c2", new ContextCustomizer() { + context.getRegistry().bind("c2", new ContextCustomizer() { @Override public int getOrder() { return Ordered.HIGHEST; } @Override - public void apply(CamelContext camelContext, Runtime.Registry registry) { + public void apply(CamelContext camelContext) { camelContext.setNameStrategy(new ExplicitCamelContextNameStrategy(camelContext.getName() + "-c2")); } }); - registry.bind("c3", new ContextCustomizer() { + context.getRegistry().bind("c3", new ContextCustomizer() { @Override - public void apply(CamelContext camelContext, Runtime.Registry registry) { + public void apply(CamelContext camelContext) { camelContext.setNameStrategy(new ExplicitCamelContextNameStrategy(camelContext.getName() + "-c3")); } }); @@ -158,7 +150,7 @@ public void apply(CamelContext camelContext, Runtime.Registry registry) { properties.setProperty("customizer.c3.enabled", "true"); pc.setInitialProperties(properties); - List customizers = RuntimeSupport.configureContext(context, registry); + List customizers = RuntimeSupport.configureContext(context); assertThat(customizers).hasSize(3); assertThat(context.getName()).isEqualTo("camel-c2-c3-c1"); } @@ -174,8 +166,7 @@ public void testCustomizeRestConfiguration() { PropertiesComponent pc = new PropertiesComponent(); pc.setInitialProperties(properties); - Runtime.Registry registry = new InMemoryRegistry(); - CamelContext context = new DefaultCamelContext(registry); + CamelContext context = new DefaultCamelContext(); context.addComponent("properties", pc); diff --git a/camel-k-runtime-core/src/test/java/org/apache/camel/k/support/StreamCachingContextCustomizerTest.java b/camel-k-runtime-core/src/test/java/org/apache/camel/k/support/StreamCachingContextCustomizerTest.java index 9b9e88dea..b36f6dcf0 100644 --- a/camel-k-runtime-core/src/test/java/org/apache/camel/k/support/StreamCachingContextCustomizerTest.java +++ b/camel-k-runtime-core/src/test/java/org/apache/camel/k/support/StreamCachingContextCustomizerTest.java @@ -18,7 +18,6 @@ import org.apache.camel.CamelContext; import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.k.InMemoryRegistry; import org.apache.camel.k.customizer.StreamCachingContextCustomizer; import org.apache.camel.spi.StreamCachingStrategy; import org.junit.jupiter.api.Test; @@ -43,7 +42,7 @@ public void testClasspathHandler() { scccc.setSpoolUsedHeapMemoryThreshold(9); CamelContext context = new DefaultCamelContext(); - scccc.apply(context, new InMemoryRegistry()); + scccc.apply(context); assertThat(context.getStreamCachingStrategy().isAnySpoolRules()).isTrue(); assertThat(context.getStreamCachingStrategy().getBufferSize()).isEqualTo(9); @@ -57,7 +56,7 @@ public void testClasspathHandler() { scccc.setSpoolUsedHeapMemoryLimit("Max"); - scccc.apply(context, new InMemoryRegistry()); + scccc.apply(context); assertThat(context.getStreamCachingStrategy().getSpoolUsedHeapMemoryLimit()).isEqualTo(StreamCachingStrategy.SpoolUsedHeapMemoryLimit.Max); } @@ -69,7 +68,7 @@ public void testUnsupportedStreamCachingSpoolUsedHeapMemoryLimit() { CamelContext context = new DefaultCamelContext(); - IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> scccc.apply(context, new InMemoryRegistry())); + IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> scccc.apply(context)); assertThat(exception.getMessage()).isEqualTo("Invalid option Unsupported must either be Committed or Max"); } diff --git a/camel-k-runtime-examples/camel-k-runtime-example-health/pom.xml b/camel-k-runtime-examples/camel-k-runtime-example-health/pom.xml index 96a872dcb..f17cfc1db 100644 --- a/camel-k-runtime-examples/camel-k-runtime-example-health/pom.xml +++ b/camel-k-runtime-examples/camel-k-runtime-example-health/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-examples - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 @@ -102,37 +102,4 @@ - - - camel3 - - - camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-3 - - - - - camel2 - - - !camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-2 - - - - - diff --git a/camel-k-runtime-examples/camel-k-runtime-example-servlet/pom.xml b/camel-k-runtime-examples/camel-k-runtime-example-servlet/pom.xml index 629cf8705..65d6612b9 100644 --- a/camel-k-runtime-examples/camel-k-runtime-example-servlet/pom.xml +++ b/camel-k-runtime-examples/camel-k-runtime-example-servlet/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-examples - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 @@ -98,37 +98,4 @@ - - - camel3 - - - camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-3 - - - - - camel2 - - - !camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-2 - - - - - diff --git a/camel-k-runtime-examples/pom.xml b/camel-k-runtime-examples/pom.xml index c2ef46444..6f1eb86b5 100644 --- a/camel-k-runtime-examples/pom.xml +++ b/camel-k-runtime-examples/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-parent - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 diff --git a/camel-k-runtime-groovy/pom.xml b/camel-k-runtime-groovy/pom.xml index d234925d3..8542d70cd 100644 --- a/camel-k-runtime-groovy/pom.xml +++ b/camel-k-runtime-groovy/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-parent - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 @@ -33,11 +33,20 @@ camel-k-runtime-jvm + + org.apache.camel + camel-api + provided + org.apache.camel camel-core provided + + org.apache.camel.k + camel-k-runtime-core + org.apache.camel @@ -64,6 +73,11 @@ + + org.apache.camel + camel-properties + test + org.codehaus.groovy groovy-test @@ -119,45 +133,4 @@ - - - camel3 - - - camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-3 - provided - - - - org.apache.camel - camel-properties - test - - - - - camel2 - - - !camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-2 - provided - - - - - diff --git a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy index bf373274b..3e341dd1d 100644 --- a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy +++ b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/GroovyRoutesLoader.groovy @@ -16,15 +16,15 @@ */ package org.apache.camel.k.groovy +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.groovy.dsl.IntegrationConfiguration import org.apache.camel.k.support.URIResolver import org.codehaus.groovy.control.CompilerConfiguration + class GroovyRoutesLoader implements RoutesLoader { @Override List getSupportedLanguages() { @@ -32,7 +32,7 @@ class GroovyRoutesLoader implements RoutesLoader { } @Override - RouteBuilder load(Runtime.Registry registry, Source source) throws Exception { + RouteBuilder load(CamelContext camelContext, Source source) throws Exception { return new RouteBuilder() { @Override void configure() throws Exception { @@ -48,7 +48,7 @@ class GroovyRoutesLoader implements RoutesLoader { def script = (DelegatingScript) sh.parse(reader) // set the delegate target - script.setDelegate(new IntegrationConfiguration(registry, this)) + script.setDelegate(new IntegrationConfiguration(this)) script.run() } } 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 bfc080d5b..b60f61b30 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.k.adapter.Introspection +import org.apache.camel.support.IntrospectionSupport class ComponentConfiguration { private final org.apache.camel.Component component @@ -47,19 +47,19 @@ class ComponentConfiguration { } } - if (!Introspection.setProperty(component, name, value, true)) { + if (!IntrospectionSupport.setProperty(component, name, value, true)) { throw new MissingMethodException(name, this.component.class, args as Object[]) } } def propertyMissing(String name, value) { - if (!Introspection.setProperty(component, name, value, true)) { + if (!IntrospectionSupport.setProperty(component, name, value, true)) { throw new MissingMethodException(name, this.component.class, value) } } def propertyMissing(String name) { - def properties = Introspection.getProperties(component, properties, null, false) + def properties = IntrospectionSupport.getProperties(component, properties, null, false) return properties[name] } diff --git a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy index ea63d0a13..a42520a41 100644 --- a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy +++ b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/ContextConfiguration.groovy @@ -17,20 +17,17 @@ 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) { + ContextConfiguration(CamelContext context) { this.context = context - this.registry = registry } def registry(Closure callable) { callable.resolveStrategy = Closure.DELEGATE_FIRST - callable.delegate = new RegistryConfiguration(registry) + callable.delegate = new RegistryConfiguration(this.context.registry) callable.call() } diff --git a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy index b71d7df7a..132ab7634 100644 --- a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy +++ b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/IntegrationConfiguration.groovy @@ -21,28 +21,26 @@ 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 +import org.apache.camel.spi.Registry class IntegrationConfiguration { - private final Runtime.Registry registry - final CamelContext context + final Registry registry final Components components final RouteBuilder builder - IntegrationConfiguration(Runtime.Registry registry, RouteBuilder builder) { - this.registry = registry + IntegrationConfiguration(RouteBuilder builder) { this.context = builder.getContext() + this.registry = this.context.registry 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.delegate = new ContextConfiguration(context) callable.call() } diff --git a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy index 14545ef66..48dc5c511 100644 --- a/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy +++ b/camel-k-runtime-groovy/src/main/groovy/org/apache/camel/k/groovy/dsl/RegistryConfiguration.groovy @@ -16,12 +16,13 @@ */ package org.apache.camel.k.groovy.dsl -import org.apache.camel.k.Runtime +import org.apache.camel.spi.Registry + class RegistryConfiguration { - private final Runtime.Registry registry + private final Registry registry - RegistryConfiguration(Runtime.Registry registry) { + RegistryConfiguration(Registry registry) { this.registry = registry } 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 a31e9eae1..210454597 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 @@ -17,9 +17,7 @@ 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.adapter.Routes import org.apache.camel.k.support.RuntimeSupport import org.apache.camel.model.ToDefinition import spock.lang.Specification @@ -33,7 +31,7 @@ class LoaderTest extends Specification { when: def loader = RuntimeSupport.loaderFor(context, source) - def builder = loader.load(new InMemoryRegistry(), source) + def builder = loader.load(context, source) then: loader instanceof GroovyRoutesLoader @@ -46,7 +44,6 @@ class LoaderTest extends Specification { routes.size() == 1 routes[0].outputs[0] instanceof ToDefinition - - Routes.getInput(routes[0]).endpointUri == 'timer:tick' + routes[0].input.endpointUri == 'timer:tick' } } 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 8dd39e080..7b1db771c 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.k.adapter.Exchanges +import org.apache.camel.support.DefaultExchange import spock.lang.Specification class LogExtensionTest extends Specification { @@ -33,7 +33,7 @@ class LogExtensionTest extends Specification { "body: $it.in.body" } - def ex = Exchanges.newDefaultExchange(ctx) + def ex = new DefaultExchange(ctx) ex.in.body = 'hello' def result = log.exchangeFormatter.format(ex) diff --git a/camel-k-runtime-health/pom.xml b/camel-k-runtime-health/pom.xml index 0467a9f23..63de757d5 100644 --- a/camel-k-runtime-health/pom.xml +++ b/camel-k-runtime-health/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-parent - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 @@ -60,6 +60,11 @@ camel-test test + + org.apache.camel + camel-properties + test + org.apache.camel.k camel-k-runtime-jvm @@ -99,45 +104,4 @@ - - - camel3 - - - camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-3 - provided - - - - org.apache.camel - camel-properties - test - - - - - camel2 - - - !camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-2 - provided - - - - - diff --git a/camel-k-runtime-health/src/main/java/org/apache/camel/k/health/HealthContextCustomizer.java b/camel-k-runtime-health/src/main/java/org/apache/camel/k/health/HealthContextCustomizer.java index 3217f5aae..47797e04f 100644 --- a/camel-k-runtime-health/src/main/java/org/apache/camel/k/health/HealthContextCustomizer.java +++ b/camel-k-runtime-health/src/main/java/org/apache/camel/k/health/HealthContextCustomizer.java @@ -18,7 +18,6 @@ import org.apache.camel.CamelContext; import org.apache.camel.k.ContextCustomizer; -import org.apache.camel.k.Runtime; import org.apache.camel.k.servlet.ServletRegistration; public class HealthContextCustomizer implements ContextCustomizer { @@ -39,8 +38,8 @@ public void setPath(String path) { } @Override - public void apply(CamelContext camelContext, Runtime.Registry registry) { - registry.bind( + public void apply(CamelContext camelContext) { + camelContext.getRegistry().bind( "health-servlet", new ServletRegistration( "HealthServlet", diff --git a/camel-k-runtime-health/src/test/java/org/apache/camel/k/health/HealthCustomizerTest.java b/camel-k-runtime-health/src/test/java/org/apache/camel/k/health/HealthCustomizerTest.java index 0713b444d..887983fc3 100644 --- a/camel-k-runtime-health/src/test/java/org/apache/camel/k/health/HealthCustomizerTest.java +++ b/camel-k-runtime-health/src/test/java/org/apache/camel/k/health/HealthCustomizerTest.java @@ -21,7 +21,6 @@ import io.undertow.servlet.core.ManagedServlet; import io.undertow.servlet.core.ManagedServlets; import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.k.InMemoryRegistry; import org.apache.camel.k.Runtime; import org.apache.camel.k.servlet.ServletContextCustomizer; import org.apache.camel.test.AvailablePortFinder; @@ -33,15 +32,14 @@ public class HealthCustomizerTest { @Test public void testServletConfigurer() { - Runtime.Registry registry = new InMemoryRegistry(); - Runtime runtime = Runtime.of(new DefaultCamelContext(registry), registry); + Runtime runtime = Runtime.of(new DefaultCamelContext()); HealthContextCustomizer healthCustomizer = new HealthContextCustomizer(); - healthCustomizer.apply(runtime.getContext(), runtime.getRegistry()); + healthCustomizer.apply(runtime.getContext()); ServletContextCustomizer servletCustomizer = new ServletContextCustomizer(); servletCustomizer.setBindPort(AvailablePortFinder.getNextAvailable()); - servletCustomizer.apply(runtime.getContext(), runtime.getRegistry()); + servletCustomizer.apply(runtime.getContext()); DeploymentManager manager = Servlets.defaultContainer().getDeploymentByPath("/"); ManagedServlets managedServlets = manager.getDeployment().getServlets(); diff --git a/camel-k-runtime-jvm/pom.xml b/camel-k-runtime-jvm/pom.xml index 0d28ed9d9..5fde97d20 100644 --- a/camel-k-runtime-jvm/pom.xml +++ b/camel-k-runtime-jvm/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-parent - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 @@ -78,6 +78,11 @@ camel-undertow test + + org.apache.camel + camel-properties + test + org.junit.jupiter @@ -127,45 +132,4 @@ - - - camel3 - - - camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-3 - provided - - - - org.apache.camel - camel-properties - test - - - - - camel2 - - - !camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-2 - provided - - - - - diff --git a/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationRuntime.java b/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationRuntime.java index 785266583..feea77c30 100644 --- a/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationRuntime.java +++ b/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationRuntime.java @@ -21,12 +21,12 @@ import java.util.Set; import org.apache.camel.CamelContext; +import org.apache.camel.ProducerTemplate; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.k.InMemoryRegistry; import org.apache.camel.k.Runtime; -import org.apache.camel.k.adapter.Exceptions; -import org.apache.camel.k.adapter.Main; import org.apache.camel.k.support.PropertiesSupport; +import org.apache.camel.main.Main; import org.apache.camel.main.MainSupport; import org.apache.camel.spi.HasId; import org.apache.camel.util.function.ThrowingConsumer; @@ -38,18 +38,25 @@ public final class ApplicationRuntime implements Runtime { private final Main main; private final DefaultCamelContext context; - private final Runtime.Registry registry; private final Set listeners; public ApplicationRuntime() { - this.registry = new InMemoryRegistry(); this.listeners = new LinkedHashSet<>(); this.context = new DefaultCamelContext(); this.context.setName("camel-k"); - this.context.setRegistry(this.registry); - this.main = new Main(context); + this.main = new Main() { + @Override + protected ProducerTemplate findOrCreateCamelTemplate() { + return context.createProducerTemplate(); + } + @Override + protected CamelContext createCamelContext() { + return context; + } + }; + this.main.addMainListener(new MainListenerAdapter()); } @@ -58,11 +65,6 @@ public CamelContext getContext() { return context; } - @Override - public Runtime.Registry getRegistry() { - return registry; - } - public void run() throws Exception { this.main.run(); } @@ -97,7 +99,7 @@ public void addListener(Phase phase, ThrowingConsumer consum consumer.accept(runtime); return true; } catch (Exception e) { - throw Exceptions.wrapRuntimeCamelException(e); + throw RuntimeCamelException.wrapRuntimeCamelException(e); } } diff --git a/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaClassLoader.java b/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaClassLoader.java index eb400ba18..f1f6ea7c4 100644 --- a/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaClassLoader.java +++ b/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaClassLoader.java @@ -19,9 +19,9 @@ import java.util.Collections; import java.util.List; +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.commons.lang3.StringUtils; @@ -32,7 +32,7 @@ public List getSupportedLanguages() { } @Override - public RouteBuilder load(Runtime.Registry registry, Source source) throws Exception { + public RouteBuilder load(CamelContext camelContext, Source source) throws Exception { String name = source.getName(); name = StringUtils.removeEnd(name, ".class"); diff --git a/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaScriptLoader.java b/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaScriptLoader.java index 5362b4672..8ed4b4acd 100644 --- a/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaScriptLoader.java +++ b/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/JavaScriptLoader.java @@ -30,7 +30,6 @@ 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; @@ -45,7 +44,7 @@ public List getSupportedLanguages() { } @Override - public RouteBuilder load(Runtime.Registry registry, Source source) throws Exception { + public RouteBuilder load(CamelContext camelContext, Source source) throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { @@ -59,7 +58,7 @@ public void configure() throws Exception { bindings.put("builder", this); bindings.put("context", context); bindings.put("components", new Components(context)); - bindings.put("registry", registry); + bindings.put("registry", camelContext.getRegistry()); bindings.put("from", (Function) uri -> from(uri)); bindings.put("rest", (Supplier) () -> rest()); bindings.put("restConfiguration", (Supplier) () -> restConfiguration()); 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 6e201bfaf..e85cbf02d 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 @@ -28,7 +28,6 @@ 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; @@ -44,7 +43,7 @@ public List getSupportedLanguages() { } @Override - public RouteBuilder load(Runtime.Registry registry, Source source) throws Exception { + public RouteBuilder load(CamelContext camelContext, Source source) throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { diff --git a/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/XmlLoader.java b/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/XmlLoader.java index 37a8dc79f..82918714d 100644 --- a/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/XmlLoader.java +++ b/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/loader/XmlLoader.java @@ -21,12 +21,12 @@ import java.util.List; import javax.xml.bind.UnmarshalException; +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.adapter.Resources; import org.apache.camel.k.support.URIResolver; +import org.apache.camel.model.ModelHelper; import org.apache.camel.model.RoutesDefinition; import org.apache.camel.model.rest.RestsDefinition; import org.slf4j.Logger; @@ -41,13 +41,13 @@ public List getSupportedLanguages() { } @Override - public RouteBuilder load(Runtime.Registry registry, Source source) throws Exception { + public RouteBuilder load(CamelContext camelContext, Source source) throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { try (InputStream is = URIResolver.resolve(getContext(), source)) { try { - RoutesDefinition definition = Resources.loadRoutesDefinition(getContext(), is); + RoutesDefinition definition = ModelHelper.loadRoutesDefinition(getContext(), is); LOGGER.debug("Loaded {} routes from {}", definition.getRoutes().size(), source); setRouteCollection(definition); @@ -60,7 +60,7 @@ public void configure() throws Exception { try (InputStream is = URIResolver.resolve(getContext(), source)) { try { - RestsDefinition definition = Resources.loadRestsDefinition(getContext(), is); + RestsDefinition definition = ModelHelper.loadRestsDefinition(getContext(), is); LOGGER.debug("Loaded {} rests from {}", definition.getRests().size(), source); setRestCollection(definition); diff --git a/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java b/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java index 0374a2c4f..d41b5b4c8 100644 --- a/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java +++ b/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java @@ -156,7 +156,7 @@ public void testContextCustomizerFromRegistry() throws Exception { runtime.setProperties(properties); runtime.addListener(new ContextConfigurer()); runtime.addListener(new ContextLifecycleConfigurer()); - runtime.getRegistry().bind("c1", (ContextCustomizer) (camelContext, registry) -> { + runtime.getRegistry().bind("c1", (ContextCustomizer) camelContext -> { camelContext.setMessageHistory(false); camelContext.setLoadTypeConverters(false); }); 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 1bfe01769..2a31d8423 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 @@ -21,10 +21,8 @@ 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.adapter.Routes; import org.apache.camel.k.jvm.loader.JavaClassLoader; import org.apache.camel.k.jvm.loader.JavaScriptLoader; import org.apache.camel.k.jvm.loader.JavaSourceLoader; @@ -44,7 +42,7 @@ public class RoutesLoadersCommonTest { 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); + RouteBuilder builder = loader.load(new DefaultCamelContext(), source); assertThat(loader).isInstanceOf(type); assertThat(builder).isNotNull(); @@ -54,7 +52,7 @@ void testLoaders(String location, Class type) throws Exc List routes = builder.getRouteCollection().getRoutes(); assertThat(routes).hasSize(1); - assertThat(Routes.getInput(routes.get(0)).getEndpointUri()).isEqualTo("timer:tick"); + assertThat(routes.get(0).getInput().getEndpointUri()).isEqualTo("timer:tick"); assertThat(routes.get(0).getOutputs().get(0)).isInstanceOf(ToDefinition.class); } 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 02150ce60..58151f228 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 @@ -21,11 +21,8 @@ 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.adapter.Routes; import org.apache.camel.k.jvm.loader.JavaClassLoader; import org.apache.camel.k.jvm.loader.JavaSourceLoader; import org.apache.camel.k.support.RuntimeSupport; @@ -43,11 +40,11 @@ public class RoutesLoadersTest { @Test public void testLoaderFromRegistry() throws Exception { RoutesLoader myLoader = new JavaClassLoader(); - Runtime.Registry registry = new InMemoryRegistry(); - registry.bind("my-loader", myLoader); + CamelContext camelContext = new DefaultCamelContext(); + camelContext.getRegistry().bind("my-loader", myLoader); Source source = Source.create("classpath:" + MyRoutes.class.getName() + ".class"); - RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(registry), source); + RoutesLoader loader = RuntimeSupport.loaderFor(camelContext, source); assertThat(loader).isInstanceOf(JavaClassLoader.class); assertThat(loader).isSameAs(myLoader); @@ -59,7 +56,7 @@ 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); + RouteBuilder builder = loader.load(context, source); assertThat(loader).isInstanceOf(JavaSourceLoader.class); assertThat(builder).isNotNull(); @@ -69,7 +66,7 @@ public void testLoadJavaWithNestedClass() throws Exception { List routes = builder.getRouteCollection().getRoutes(); assertThat(routes).hasSize(1); - assertThat(Routes.getInput(routes.get(0)).getEndpointUri()).isEqualTo("timer:tick"); + assertThat(routes.get(0).getInput().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); @@ -81,7 +78,7 @@ public void testLoadJavaWithRestConfiguration() throws Exception { Source source = Source.create("classpath:MyRoutesWithRestConfiguration.java"); RoutesLoader loader = RuntimeSupport.loaderFor(new DefaultCamelContext(), source); - RouteBuilder builder = loader.load(new InMemoryRegistry(), source); + RouteBuilder builder = loader.load(context, source); assertThat(loader).isInstanceOf(JavaSourceLoader.class); assertThat(builder).isNotNull(); 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 805fcd516..f3e118b89 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 @@ -16,20 +16,16 @@ */ 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.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.model.ModelCamelContext; import org.apache.camel.util.ObjectHelper; -import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Java6Assertions.assertThat; diff --git a/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/TestCustomizer.java b/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/TestCustomizer.java index 7cd61abdf..c20019d0f 100644 --- a/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/TestCustomizer.java +++ b/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/TestCustomizer.java @@ -18,7 +18,6 @@ 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; @@ -32,7 +31,7 @@ public void setMessageHistory(boolean messageHistory) { } @Override - public void apply(CamelContext camelContext, Runtime.Registry registry) { + public void apply(CamelContext camelContext) { camelContext.setMessageHistory(messageHistory); camelContext.setLoadTypeConverters(false); } diff --git a/camel-k-runtime-kotlin/pom.xml b/camel-k-runtime-kotlin/pom.xml index 9d404059e..7e1cfcb5c 100644 --- a/camel-k-runtime-kotlin/pom.xml +++ b/camel-k-runtime-kotlin/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-parent - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 @@ -66,6 +66,12 @@ + + org.apache.camel + camel-properties + test + + org.junit.jupiter junit-jupiter-api @@ -126,45 +132,4 @@ - - - camel3 - - - camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-3 - provided - - - - org.apache.camel - camel-properties - test - - - - - camel2 - - - !camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-2 - provided - - - - - diff --git a/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt b/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt index 38be3d287..d357e2fc0 100644 --- a/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt +++ b/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/KotlinRoutesLoader.kt @@ -16,9 +16,9 @@ */ package org.apache.camel.k.kotlin +import org.apache.camel.CamelContext 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 @@ -43,7 +43,7 @@ class KotlinRoutesLoader : RoutesLoader { } @Throws(Exception::class) - override fun load(registry: Registry, source: Source): RouteBuilder? { + override fun load(camelContext: CamelContext, source: Source): RouteBuilder? { return object : RouteBuilder() { @Throws(Exception::class) override fun configure() { @@ -69,7 +69,7 @@ class KotlinRoutesLoader : RoutesLoader { // // Arguments used to initialize the script base class // - constructorArgs(registry, builder) + constructorArgs(camelContext.registry, builder) } ) diff --git a/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt b/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt index ce3e8c10d..a95568f9a 100644 --- a/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt +++ b/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/ContextConfiguration.kt @@ -17,7 +17,7 @@ package org.apache.camel.k.kotlin.dsl import org.apache.camel.CamelContext -import org.apache.camel.k.Runtime.Registry +import org.apache.camel.spi.Registry class ContextConfiguration (val registry: Registry, val context: CamelContext) { diff --git a/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt b/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt index 576e8d4e2..aa3856a5e 100644 --- a/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt +++ b/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/IntegrationConfiguration.kt @@ -20,8 +20,8 @@ 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 +import org.apache.camel.spi.Registry abstract class IntegrationConfiguration( private val registry : Registry, diff --git a/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt b/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt index 1e1b09194..9fcb32042 100644 --- a/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt +++ b/camel-k-runtime-kotlin/src/main/kotlin/org/apache/camel/k/kotlin/dsl/RegistryConfiguration.kt @@ -16,7 +16,8 @@ */ package org.apache.camel.k.kotlin.dsl -import org.apache.camel.k.Runtime.Registry +import org.apache.camel.spi.Registry + class RegistryConfiguration(val registry: Registry) { fun bind(name: String, value: Any) { 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 a3831d4d0..d75a328a0 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 @@ -17,9 +17,7 @@ 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.adapter.Routes import org.apache.camel.k.support.RuntimeSupport import org.apache.camel.model.ProcessDefinition import org.apache.camel.model.ToDefinition @@ -33,7 +31,7 @@ class LoaderTest { var context = DefaultCamelContext() var source = Source.create("classpath:routes.kts") val loader = RuntimeSupport.loaderFor(context, source) - val builder = loader.load(InMemoryRegistry(), source) + val builder = loader.load(context, source) assertThat(loader).isInstanceOf(KotlinRoutesLoader::class.java) assertThat(builder).isNotNull @@ -43,7 +41,7 @@ class LoaderTest { val routes = builder.routeCollection.routes assertThat(routes).hasSize(1) - assertThat(Routes.getInput(routes[0]).endpointUri).isEqualTo("timer:tick") + assertThat(routes[0].getInput().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/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 0d5a28104..291a8495b 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.k.adapter.Exchanges +import org.apache.camel.support.DefaultExchange 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 = Exchanges.newDefaultExchange(ctx) + var ex = DefaultExchange(ctx) ex.getIn().body = "hello" assertThat(log.exchangeFormatter.format(ex)).isEqualTo("body: hello") diff --git a/camel-k-runtime-servlet/pom.xml b/camel-k-runtime-servlet/pom.xml index 4f3ad1bb8..6a41f158f 100644 --- a/camel-k-runtime-servlet/pom.xml +++ b/camel-k-runtime-servlet/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-parent - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 @@ -81,6 +81,11 @@ camel-test test + + org.apache.camel + camel-properties + test + org.junit.jupiter @@ -115,45 +120,4 @@ - - - camel3 - - - camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-3 - provided - - - - org.apache.camel - camel-properties - test - - - - - camel2 - - - !camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-2 - provided - - - - - diff --git a/camel-k-runtime-servlet/src/main/java/org/apache/camel/k/servlet/ServletContextCustomizer.java b/camel-k-runtime-servlet/src/main/java/org/apache/camel/k/servlet/ServletContextCustomizer.java index 5666298ab..818f6bfe1 100644 --- a/camel-k-runtime-servlet/src/main/java/org/apache/camel/k/servlet/ServletContextCustomizer.java +++ b/camel-k-runtime-servlet/src/main/java/org/apache/camel/k/servlet/ServletContextCustomizer.java @@ -19,7 +19,6 @@ import org.apache.camel.CamelContext; import org.apache.camel.Ordered; import org.apache.camel.k.ContextCustomizer; -import org.apache.camel.k.Runtime; public class ServletContextCustomizer implements ContextCustomizer { public static final String DEFAULT_BIND_HOST = "0.0.0.0"; @@ -62,7 +61,7 @@ public void setPath(String path) { } @Override - public void apply(CamelContext camelContext, Runtime.Registry registry) { + public void apply(CamelContext camelContext) { endpoint = new ServletEndpoint(camelContext, bindHost, bindPort, path); try { diff --git a/camel-k-runtime-servlet/src/main/java/org/apache/camel/k/servlet/ServletEndpoint.java b/camel-k-runtime-servlet/src/main/java/org/apache/camel/k/servlet/ServletEndpoint.java index 26a096818..075b11224 100644 --- a/camel-k-runtime-servlet/src/main/java/org/apache/camel/k/servlet/ServletEndpoint.java +++ b/camel-k-runtime-servlet/src/main/java/org/apache/camel/k/servlet/ServletEndpoint.java @@ -26,7 +26,7 @@ import io.undertow.servlet.api.DeploymentManager; import io.undertow.servlet.util.ImmediateInstanceHandle; import org.apache.camel.CamelContext; -import org.apache.camel.k.adapter.ServiceSupport; +import org.apache.camel.support.service.ServiceSupport; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/camel-k-runtime-servlet/src/test/java/org/apache/camel/k/servlet/ServletCustomizerTest.java b/camel-k-runtime-servlet/src/test/java/org/apache/camel/k/servlet/ServletCustomizerTest.java index 627970b81..01f9dcf7c 100644 --- a/camel-k-runtime-servlet/src/test/java/org/apache/camel/k/servlet/ServletCustomizerTest.java +++ b/camel-k-runtime-servlet/src/test/java/org/apache/camel/k/servlet/ServletCustomizerTest.java @@ -22,7 +22,6 @@ import io.undertow.servlet.core.ManagedServlets; import org.apache.camel.component.servlet.CamelHttpTransportServlet; import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.k.InMemoryRegistry; import org.apache.camel.k.Runtime; import org.apache.camel.test.AvailablePortFinder; import org.junit.jupiter.api.Test; @@ -33,15 +32,14 @@ public class ServletCustomizerTest { @Test public void testServletConfigurer() { - Runtime.Registry registry = new InMemoryRegistry(); - Runtime runtime = Runtime.of(new DefaultCamelContext(registry), registry); + Runtime runtime = Runtime.of(new DefaultCamelContext()); ServletRegistrationContextCustomizer servletRegistrationCustomizer = new ServletRegistrationContextCustomizer("/webhook/*", "webhook-servlet"); servletRegistrationCustomizer.apply(runtime.getContext(), runtime.getRegistry()); ServletContextCustomizer servletCustomizer = new ServletContextCustomizer(); servletCustomizer.setBindPort(AvailablePortFinder.getNextAvailable()); - servletCustomizer.apply(runtime.getContext(), runtime.getRegistry()); + servletCustomizer.apply(runtime.getContext()); DeploymentManager manager = Servlets.defaultContainer().getDeploymentByPath("/"); ManagedServlets managedServlets = manager.getDeployment().getServlets(); diff --git a/camel-k-runtime-yaml/pom.xml b/camel-k-runtime-yaml/pom.xml index d6958ac7a..839460402 100644 --- a/camel-k-runtime-yaml/pom.xml +++ b/camel-k-runtime-yaml/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-parent - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 @@ -62,6 +62,12 @@ + + org.apache.camel + camel-properties + test + + org.junit.jupiter junit-jupiter-api @@ -95,45 +101,4 @@ - - - camel3 - - - camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-3 - provided - - - - org.apache.camel - camel-properties - test - - - - - camel2 - - - !camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-2 - provided - - - - - diff --git a/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/YamlFlowLoader.java b/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/YamlFlowLoader.java index 98ecd5a20..bba8a14dd 100644 --- a/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/YamlFlowLoader.java +++ b/camel-k-runtime-yaml/src/main/java/org/apache/camel/k/yaml/YamlFlowLoader.java @@ -26,9 +26,9 @@ 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.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.support.URIResolver; import org.apache.camel.k.yaml.model.Endpoint; @@ -61,7 +61,7 @@ public List getSupportedLanguages() { @SuppressWarnings("uncheked") @Override - public RouteBuilder load(Runtime.Registry registry, Source source) throws Exception { + public RouteBuilder load(CamelContext camelContext, Source source) throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { 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 97bb16439..556ec80e3 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 @@ -21,10 +21,8 @@ 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.Source; -import org.apache.camel.k.adapter.Routes; import org.apache.camel.k.support.RuntimeSupport; import org.apache.camel.model.RouteDefinition; import org.apache.camel.model.ToDefinition; @@ -39,7 +37,7 @@ public void testLoadYamlFlow() throws Exception { CamelContext context = new DefaultCamelContext(); Source source = Source.create("classpath:routes.flow"); RoutesLoader loader = RuntimeSupport.loaderFor(context, source); - RouteBuilder builder = loader.load(new InMemoryRegistry(), source); + RouteBuilder builder = loader.load(context, source); assertThat(loader).isInstanceOf(YamlFlowLoader.class); assertThat(builder).isNotNull(); @@ -49,7 +47,7 @@ public void testLoadYamlFlow() throws Exception { List routes = builder.getRouteCollection().getRoutes(); assertThat(routes).hasSize(1); - assertThat(Routes.getInput(routes.get(0)).getEndpointUri()).isEqualTo("timer:tick"); + assertThat(routes.get(0).getInput().getEndpointUri()).isEqualTo("timer:tick"); assertThat(routes.get(0).getOutputs().get(0)).isInstanceOf(ToDefinition.class); } } diff --git a/camel-knative-http/pom.xml b/camel-knative-http/pom.xml index dbd43558a..0f7e97b5d 100644 --- a/camel-knative-http/pom.xml +++ b/camel-knative-http/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-parent - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 @@ -52,6 +52,12 @@ provided + + org.apache.camel + spi-annotations + provided + + @@ -70,6 +76,12 @@ test + + org.apache.camel + camel-properties + test + + org.junit.jupiter junit-jupiter-api @@ -104,50 +116,4 @@ - - - camel3 - - - camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-3 - provided - - - org.apache.camel - spi-annotations - provided - - - - org.apache.camel - camel-properties - test - - - - - camel2 - - - !camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-2 - provided - - - - - 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 92b61f8b3..f1e10554d 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 @@ -44,6 +44,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.RuntimeCamelException; import org.apache.camel.TypeConverter; import org.apache.camel.component.netty4.NettyConverter; import org.apache.camel.component.netty4.http.DefaultNettyHttpBinding; @@ -54,11 +55,9 @@ import org.apache.camel.component.netty4.http.NettyHttpConsumer; import org.apache.camel.component.netty4.http.NettyHttpHelper; import org.apache.camel.component.netty4.http.handlers.HttpServerChannelHandler; -import org.apache.camel.k.adapter.Exceptions; -import org.apache.camel.k.adapter.Objects; -import org.apache.camel.k.adapter.Services; import org.apache.camel.spi.HeaderFilterStrategy; import org.apache.camel.support.RestConsumerContextPathMatcher; +import org.apache.camel.support.service.ServiceHelper; import org.apache.camel.util.ObjectHelper; import org.apache.camel.util.URISupport; import org.apache.camel.util.UnsafeUriCharactersEncoder; @@ -86,7 +85,7 @@ public synchronized HttpServerConsumerChannelFactory getMultiplexChannelHandler( protected void doStop() throws Exception { super.doStop(); - Services.start(handlers.values()); + ServiceHelper.startService(handlers.values()); handlers.clear(); } @@ -237,7 +236,7 @@ private HttpServerChannelHandler getHandler(HttpRequest request, String method) break; } } catch (Exception e) { - throw Exceptions.wrapRuntimeCamelException(e); + throw RuntimeCamelException.wrapRuntimeCamelException(e); } } } @@ -351,7 +350,7 @@ public HttpRequest toNettyRequest(Message message, String uri, NettyHttpConfigur } // use an iterator as there can be multiple values. (must not use a delimiter) - final Iterator it = Objects.createIterator(value, null, true); + final Iterator it = org.apache.camel.support.ObjectHelper.createIterator(value, null, true); while (it.hasNext()) { String headerValue = tc.convertTo(String.class, it.next()); diff --git a/camel-knative/pom.xml b/camel-knative/pom.xml index 4f6f14f34..a6d0a1526 100644 --- a/camel-knative/pom.xml +++ b/camel-knative/pom.xml @@ -21,7 +21,7 @@ org.apache.camel.k camel-k-runtime-parent - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 @@ -57,6 +57,17 @@ provided + + org.apache.camel + spi-annotations + provided + + + org.apache.camel + apt + provided + + com.fasterxml.jackson.core jackson-databind @@ -102,6 +113,12 @@ test + + org.apache.camel + camel-properties + test + + org.junit.jupiter junit-jupiter-api @@ -136,104 +153,26 @@ - - - camel3 - - - camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-3 - provided - - - org.apache.camel - spi-annotations - provided - - - - org.apache.camel - camel-properties - test - - - - org.apache.camel - apt - provided - - - - - - org.apache.camel - camel-package-maven-plugin - ${camel3.version} - - false - - - - generate - - prepare-components - - process-classes - - - - - - - - camel2 - - - !camel3 - - - - - - org.apache.camel.k - camel-k-adapter-camel-2 - provided - - - - org.apache.camel - apt - provided - - - - - - org.apache.camel - camel-package-maven-plugin - ${camel2.version} - - false - - - - generate - - prepare-components - - process-classes - - - - - - - + + + + org.apache.camel + camel-package-maven-plugin + ${camel.version} + + false + + + + generate + + prepare-components + + process-classes + + + + + 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 19f9dff1d..8c1e2bf03 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 org.apache.camel.CamelContext; import org.apache.camel.Endpoint; -import org.apache.camel.k.adapter.DefaultComponent; -import org.apache.camel.k.adapter.Introspection; +import org.apache.camel.support.DefaultComponent; +import org.apache.camel.support.IntrospectionSupport; import org.apache.camel.util.StringHelper; public class KnativeComponent extends DefaultComponent { @@ -101,7 +101,7 @@ protected Endpoint createEndpoint(String uri, String remaining, Map Map mergeMaps(Map map, Map... maps) { return answer; } + @SuppressWarnings("unchecked") public static Map mapOf(K key, V value, Object... keyVals) { Map map = new HashMap<>(); map.put(key, value); diff --git a/distribution/pom.xml b/distribution/pom.xml index c610c074e..05b8f3773 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -21,7 +21,7 @@ camel-k-runtime-parent org.apache.camel.k - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 pom diff --git a/pom.xml b/pom.xml index 4e8cb02c7..99ec17521 100644 --- a/pom.xml +++ b/pom.xml @@ -28,16 +28,14 @@ 4.0.0 org.apache.camel.k camel-k-runtime-parent - 0.3.4-SNAPSHOT + 1.0.0-SNAPSHOT pom UTF-8 1.8 1.8 - 2.24.0 - 3.0.0-M2 - ${camel2.version} + 3.0.0-M2 ${camel.version} 4.12 5.4.2 @@ -140,8 +138,6 @@ - camel-k-adapter-camel-2 - camel-k-adapter-camel-3 camel-k-maven-plugin camel-k-runtime-core camel-k-runtime-jvm @@ -187,15 +183,13 @@ - org.apache.camel.k - camel-k-adapter-camel-3 - ${project.version} - - - org.apache.camel.k - camel-k-adapter-camel-2 - ${project.version} + org.apache.camel + camel-bom + ${camel.version} + pom + import + org.apache.camel.k camel-k-runtime-core @@ -245,45 +239,6 @@ - - camel3 - - - camel3 - - - - - - org.apache.camel - camel-bom - ${camel3.version} - pom - import - - - - - - camel2 - - - !camel3 - - - - - - org.apache.camel - camel-bom - ${camel2.version} - pom - import - - - - - deps From b53529e1a1aae5cfa906ee02fd0e112c66d431c0 Mon Sep 17 00:00:00 2001 From: lburgazzoli Date: Mon, 3 Jun 2019 11:00:52 +0200 Subject: [PATCH 2/2] camel-3: polish --- .../processors/CatalogProcessor_3_x.java | 1 - .../processors/CataloProcessor3Test.java | 3 --- camel-k-runtime-bom/pom.xml | 4 ---- .../main/java/org/apache/camel/k/Runtime.java | 22 ++++++++++------- .../k/listener/AbstractPhaseListener.java | 2 -- .../camel/k/listener/ContextConfigurer.java | 6 ++--- .../listener/ContextLifecycleConfigurer.java | 4 ++-- .../camel/k/listener/RoutesConfigurer.java | 6 ++--- .../apache/camel/k/listener/RoutesDumper.java | 2 +- .../camel/k/groovy/dsl/IntegrationTest.groovy | 24 +++++++++---------- .../camel/k/health/HealthCustomizerTest.java | 4 ++-- .../camel/k/jvm/ApplicationRuntime.java | 4 ++-- .../apache/camel/k/jvm/PropertiesTest.java | 12 +++++----- .../org/apache/camel/k/jvm/RuntimeTest.java | 4 ++-- .../camel/k/kotlin/dsl/IntegrationTest.kt | 22 ++++++++--------- .../ServletRegistrationContextCustomizer.java | 9 ++++--- .../k/servlet/ServletCustomizerTest.java | 5 ++-- .../ServletRegistrationCustomizerTest.java | 9 +++---- 18 files changed, 67 insertions(+), 76 deletions(-) diff --git a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_3_x.java b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_3_x.java index 8ebec01d8..82301ebf3 100644 --- a/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_3_x.java +++ b/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/processors/CatalogProcessor_3_x.java @@ -94,7 +94,6 @@ public void process(MavenProject project, CamelCatalog catalog, Map d.getGroupId().equals("org.apache.camel") && d.getArtifactId().equals("camel-core") ); - assertThat(a.getDependencies()).anyMatch( - d -> d.getGroupId().equals("org.apache.camel.k") && d.getArtifactId().equals("camel-k-adapter-camel-3") - ); }); assertThat(artifactMap.get("camel-k-runtime-groovy")).satisfies(a -> { assertThat(a.getDependencies()).anyMatch( diff --git a/camel-k-runtime-bom/pom.xml b/camel-k-runtime-bom/pom.xml index 2de779589..28e5a61ce 100644 --- a/camel-k-runtime-bom/pom.xml +++ b/camel-k-runtime-bom/pom.xml @@ -28,11 +28,7 @@ 4.0.0 org.apache.camel.k camel-k-runtime-bom -<<<<<<< HEAD - 0.3.4-SNAPSHOT -======= 1.0.0-SNAPSHOT ->>>>>>> switch to camel 3, drop support for camel 2.x pom 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 68e8598f6..eedb7ea6b 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,19 +21,15 @@ import org.apache.camel.CamelContext; import org.apache.camel.Ordered; import org.apache.camel.component.properties.PropertiesComponent; +import org.apache.camel.spi.HasCamelContext; import org.apache.camel.spi.Registry; -public interface Runtime { - /** - * Returns the context associated to this runtime. - */ - CamelContext getContext(); - +public interface Runtime extends HasCamelContext { /** * Returns the registry associated to this runtime. */ default Registry getRegistry() { - return getContext().getRegistry(); + return getCamelContext().getRegistry(); } default void setProperties(Properties properties) { @@ -63,7 +59,7 @@ default int getOrder() { } /** - * Helper to create a simple runtime from a given Camel Context and Runtime Registry. + * Helper to create a simple runtime from a given Camel Context. * * @param camelContext the camel context * @return the runtime @@ -71,4 +67,14 @@ default int getOrder() { static Runtime of(CamelContext camelContext) { return () -> camelContext; } + + /** + * Helper to create a simple runtime from a given Camel Context provider. + * + * @param provider the camel context provider + * @return the runtime + */ + static Runtime of(HasCamelContext provider) { + return () -> provider.getCamelContext(); + } } diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/AbstractPhaseListener.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/AbstractPhaseListener.java index 17574b1fd..bf8adfe1e 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/AbstractPhaseListener.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/AbstractPhaseListener.java @@ -18,9 +18,7 @@ import org.apache.camel.k.Runtime; import org.apache.camel.CamelContext; -import org.apache.camel.component.servlet.CamelHttpTransportServlet; import org.apache.camel.k.ContextCustomizer; -import org.apache.camel.k.servlet.ServletRegistration; public abstract class AbstractPhaseListener implements Runtime.Listener { private final Runtime.Phase phase; diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextConfigurer.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextConfigurer.java index bd92177c8..867d67325 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextConfigurer.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextConfigurer.java @@ -32,14 +32,14 @@ protected void accept(Runtime runtime) { // // camel.context.${name} = ${value} // - PropertiesSupport.bindProperties(runtime.getContext(), runtime.getContext(), "camel.context."); + PropertiesSupport.bindProperties(runtime.getCamelContext(), runtime.getCamelContext(), "camel.context."); // // Configure the camel rest definition using properties in the form: // // camel.rest.${name} = ${value} // - RuntimeSupport.configureRest(runtime.getContext()); + RuntimeSupport.configureRest(runtime.getCamelContext()); // // Programmatically configure the camel context. @@ -47,6 +47,6 @@ protected void accept(Runtime runtime) { // This is useful to configure services such as the ClusterService, // RouteController, etc // - RuntimeSupport.configureContext(runtime.getContext()); + RuntimeSupport.configureContext(runtime.getCamelContext()); } } diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextLifecycleConfigurer.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextLifecycleConfigurer.java index a01b8864f..789d467d7 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextLifecycleConfigurer.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/ContextLifecycleConfigurer.java @@ -31,7 +31,7 @@ protected void accept(Runtime runtime) { // // Configure components upon creation // - runtime.getContext().addLifecycleStrategy(new LifecycleStrategySupport() { + runtime.getCamelContext().addLifecycleStrategy(new LifecycleStrategySupport() { @SuppressWarnings("unchecked") @Override public void onComponentAdd(String name, Component component) { @@ -41,7 +41,7 @@ public void onComponentAdd(String name, Component component) { // // camel.component.${scheme}.${name} = ${value} // - PropertiesSupport.bindProperties(runtime.getContext(), component, "camel.component." + name + "."); + PropertiesSupport.bindProperties(runtime.getCamelContext(), component, "camel.component." + name + "."); } }); } diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java index 22de71cde..520489665 100644 --- a/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java +++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/listener/RoutesConfigurer.java @@ -62,8 +62,8 @@ protected void load(Runtime runtime, String[] routes) { try { source = Source.create(route); - loader = RuntimeSupport.loaderFor(runtime.getContext(), source); - builder = loader.load(runtime.getContext(), source); + loader = RuntimeSupport.loaderFor(runtime.getCamelContext(), source); + builder = loader.load(runtime.getCamelContext(), source); } catch (Exception e) { throw RuntimeCamelException.wrapRuntimeCamelException(e); } @@ -75,7 +75,7 @@ protected void load(Runtime runtime, String[] routes) { LOGGER.info("Loading routes from: {}", route); try { - runtime.getContext().addRoutes(builder); + runtime.getCamelContext().addRoutes(builder); } catch (Exception e) { throw RuntimeCamelException.wrapRuntimeCamelException(e); } 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 7f0eec6e4..d5cbd2a66 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 @@ -36,7 +36,7 @@ public RoutesDumper() { @Override protected void accept(Runtime runtime) { - CamelContext context = runtime.getContext(); + CamelContext context = runtime.getCamelContext(); RoutesDefinition routes = new RoutesDefinition(); routes.setRoutes(context.adapt(ModelCamelContext.class).getRouteDefinitions()); diff --git a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy b/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy index 5fbde31b6..53a50023b 100644 --- a/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy +++ b/camel-k-runtime-groovy/src/test/groovy/org/apache/camel/k/groovy/dsl/IntegrationTest.groovy @@ -36,12 +36,12 @@ class IntegrationTest extends Specification { 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' + runtime.camelContext.restConfiguration.host == 'my-host' + runtime.camelContext.restConfiguration.port == 9192 + runtime.camelContext.getRestConfiguration('undertow', false).host == 'my-undertow-host' + runtime.camelContext.getRestConfiguration('undertow', false).port == 9193 + runtime.camelContext.restDefinitions.size() == 1 + runtime.camelContext.restDefinitions[0].path == '/my/path' } def "load integration with bindings"() { @@ -52,9 +52,9 @@ class IntegrationTest extends Specification { runtime.run() then: - runtime.context.registry.lookupByName('myEntry1') == 'myRegistryEntry1' - runtime.context.registry.lookupByName('myEntry2') == 'myRegistryEntry2' - runtime.context.registry.lookupByName('myEntry3') instanceof Processor + runtime.camelContext.registry.lookupByName('myEntry1') == 'myRegistryEntry1' + runtime.camelContext.registry.lookupByName('myEntry2') == 'myRegistryEntry2' + runtime.camelContext.registry.lookupByName('myEntry3') instanceof Processor } def "load integration with component configuration"() { @@ -69,9 +69,9 @@ class IntegrationTest extends Specification { 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) + def seda = it.camelContext.getComponent('seda', SedaComponent) + def mySeda = it.camelContext.getComponent('mySeda', SedaComponent) + def log = it.camelContext.getComponent('log', LogComponent) assert seda != null assert mySeda != null diff --git a/camel-k-runtime-health/src/test/java/org/apache/camel/k/health/HealthCustomizerTest.java b/camel-k-runtime-health/src/test/java/org/apache/camel/k/health/HealthCustomizerTest.java index 887983fc3..a57a0e312 100644 --- a/camel-k-runtime-health/src/test/java/org/apache/camel/k/health/HealthCustomizerTest.java +++ b/camel-k-runtime-health/src/test/java/org/apache/camel/k/health/HealthCustomizerTest.java @@ -35,11 +35,11 @@ public void testServletConfigurer() { Runtime runtime = Runtime.of(new DefaultCamelContext()); HealthContextCustomizer healthCustomizer = new HealthContextCustomizer(); - healthCustomizer.apply(runtime.getContext()); + healthCustomizer.apply(runtime.getCamelContext()); ServletContextCustomizer servletCustomizer = new ServletContextCustomizer(); servletCustomizer.setBindPort(AvailablePortFinder.getNextAvailable()); - servletCustomizer.apply(runtime.getContext()); + servletCustomizer.apply(runtime.getCamelContext()); DeploymentManager manager = Servlets.defaultContainer().getDeploymentByPath("/"); ManagedServlets managedServlets = manager.getDeployment().getServlets(); diff --git a/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationRuntime.java b/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationRuntime.java index feea77c30..d94d671c4 100644 --- a/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationRuntime.java +++ b/camel-k-runtime-jvm/src/main/java/org/apache/camel/k/jvm/ApplicationRuntime.java @@ -61,7 +61,7 @@ protected CamelContext createCamelContext() { } @Override - public CamelContext getContext() { + public CamelContext getCamelContext() { return context; } @@ -84,7 +84,7 @@ public void addListener(Runtime.Listener listener) { id = id + "."; } - PropertiesSupport.bindProperties(getContext(), listener, id); + PropertiesSupport.bindProperties(getCamelContext(), listener, id); } LOGGER.info("Add listener: {}", listener); diff --git a/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java b/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java index d41b5b4c8..8cb416c1e 100644 --- a/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java +++ b/camel-k-runtime-jvm/src/test/java/org/apache/camel/k/jvm/PropertiesTest.java @@ -41,7 +41,7 @@ public void testLoadProperties() throws Exception { runtime.addListener(new ContextConfigurer()); runtime.addListener(new ContextLifecycleConfigurer()); runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); + CamelContext context = r.getCamelContext(); assertThat(context.resolvePropertyPlaceholders("{{root.key}}")).isEqualTo("root.value"); assertThat(context.resolvePropertyPlaceholders("{{001.key}}")).isEqualTo("001.value"); assertThat(context.resolvePropertyPlaceholders("{{002.key}}")).isEqualTo("002.value"); @@ -62,7 +62,7 @@ public void testSystemProperties() throws Exception { runtime.addListener(new ContextConfigurer()); runtime.addListener(new ContextLifecycleConfigurer()); runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); + CamelContext context = r.getCamelContext(); String value = context.resolvePropertyPlaceholders("{{my.property}}"); assertThat(value).isEqualTo("my.value"); @@ -90,7 +90,7 @@ public void testComponentConfiguration() throws Exception { runtime.addListener(new ContextConfigurer()); runtime.addListener(new ContextLifecycleConfigurer()); runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); + CamelContext context = r.getCamelContext(); assertThat(context.getComponent("seda", true)).hasFieldOrPropertyWithValue("queueSize", queueSize1); assertThat(context.getComponent("my-seda", true)).hasFieldOrPropertyWithValue("queueSize", queueSize2); runtime.stop(); @@ -114,7 +114,7 @@ public void testContextConfiguration() throws Exception { runtime.addListener(new ContextConfigurer()); runtime.addListener(new ContextLifecycleConfigurer()); runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); + CamelContext context = r.getCamelContext(); assertThat(context.isMessageHistory()).isFalse(); assertThat(context.isLoadTypeConverters()).isFalse(); runtime.stop(); @@ -138,7 +138,7 @@ public void testContextCustomizerFromProperty() throws Exception { runtime.addListener(new ContextConfigurer()); runtime.addListener(new ContextLifecycleConfigurer()); runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); + CamelContext context = r.getCamelContext(); assertThat(context.isMessageHistory()).isFalse(); assertThat(context.isLoadTypeConverters()).isFalse(); runtime.stop(); @@ -161,7 +161,7 @@ public void testContextCustomizerFromRegistry() throws Exception { camelContext.setLoadTypeConverters(false); }); runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); + CamelContext context = r.getCamelContext(); assertThat(context.isMessageHistory()).isFalse(); assertThat(context.isLoadTypeConverters()).isFalse(); runtime.stop(); 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 f3e118b89..09c4a0a1d 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 @@ -41,7 +41,7 @@ void testLoadMultipleRoutes() throws Exception { 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(); + CamelContext context = r.getCamelContext(); List routes = context.getRoutes(); assertThat(routes).hasSize(2); @@ -66,7 +66,7 @@ void testLoadRouteAndRest() throws Exception { runtime.addListener(new ContextLifecycleConfigurer()); runtime.addListener(RoutesConfigurer.forRoutes("classpath:routes.xml", "classpath:rests.xml")); runtime.addListener(Runtime.Phase.Started, r -> { - CamelContext context = r.getContext(); + CamelContext context = r.getCamelContext(); assertThat(context.adapt(ModelCamelContext.class).getRouteDefinitions()).isNotEmpty(); assertThat(context.adapt(ModelCamelContext.class).getRestDefinitions()).isNotEmpty(); 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 9022b3c6c..9037cf1e2 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 @@ -37,12 +37,12 @@ class IntegrationTest { 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.adapt(ModelCamelContext::class.java).restDefinitions.size).isEqualTo(1) - assertThat(runtime.context.adapt(ModelCamelContext::class.java).restDefinitions[0].path).isEqualTo("/my/path") + assertThat(runtime.camelContext.restConfiguration.host).isEqualTo("my-host") + assertThat(runtime.camelContext.restConfiguration.port).isEqualTo(9192) + assertThat(runtime.camelContext.getRestConfiguration("undertow", false).host).isEqualTo("my-undertow-host") + assertThat(runtime.camelContext.getRestConfiguration("undertow", false).port).isEqualTo(9193) + assertThat(runtime.camelContext.adapt(ModelCamelContext::class.java).restDefinitions.size).isEqualTo(1) + assertThat(runtime.camelContext.adapt(ModelCamelContext::class.java).restDefinitions[0].path).isEqualTo("/my/path") } @Test @@ -52,8 +52,8 @@ class IntegrationTest { 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) + assertThat(runtime.camelContext.registry.lookupByName("my-entry")).isEqualTo("myRegistryEntry1") + assertThat(runtime.camelContext.registry.lookupByName("my-proc")).isInstanceOf(Processor::class.java) } @Test @@ -67,9 +67,9 @@ class IntegrationTest { 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) + val seda = runtime.camelContext.getComponent("seda", SedaComponent::class.java) + val mySeda = runtime.camelContext.getComponent("mySeda", SedaComponent::class.java) + val log = runtime.camelContext.getComponent("log", LogComponent::class.java) sedaSize.set(seda!!.queueSize) sedaConsumers.set(seda.concurrentConsumers) diff --git a/camel-k-runtime-servlet/src/main/java/org/apache/camel/k/servlet/ServletRegistrationContextCustomizer.java b/camel-k-runtime-servlet/src/main/java/org/apache/camel/k/servlet/ServletRegistrationContextCustomizer.java index 232643d12..7c394614d 100644 --- a/camel-k-runtime-servlet/src/main/java/org/apache/camel/k/servlet/ServletRegistrationContextCustomizer.java +++ b/camel-k-runtime-servlet/src/main/java/org/apache/camel/k/servlet/ServletRegistrationContextCustomizer.java @@ -4,7 +4,6 @@ import org.apache.camel.Ordered; import org.apache.camel.component.servlet.CamelHttpTransportServlet; import org.apache.camel.k.ContextCustomizer; -import org.apache.camel.k.Runtime; public class ServletRegistrationContextCustomizer implements ContextCustomizer { public static final String DEFAULT_PATH = "/camel/*"; @@ -23,10 +22,10 @@ public ServletRegistrationContextCustomizer(String path, String camelServletName } @Override - public void apply(CamelContext camelContext, Runtime.Registry registry) { - registry.bind( - camelServletName, - new ServletRegistration(camelServletName, new CamelHttpTransportServlet(), path) + public void apply(CamelContext camelContext) { + camelContext.getRegistry().bind( + camelServletName, + new ServletRegistration(camelServletName, new CamelHttpTransportServlet(), path) ); } diff --git a/camel-k-runtime-servlet/src/test/java/org/apache/camel/k/servlet/ServletCustomizerTest.java b/camel-k-runtime-servlet/src/test/java/org/apache/camel/k/servlet/ServletCustomizerTest.java index 01f9dcf7c..4732bba4a 100644 --- a/camel-k-runtime-servlet/src/test/java/org/apache/camel/k/servlet/ServletCustomizerTest.java +++ b/camel-k-runtime-servlet/src/test/java/org/apache/camel/k/servlet/ServletCustomizerTest.java @@ -20,7 +20,6 @@ import io.undertow.servlet.api.DeploymentManager; import io.undertow.servlet.core.ManagedServlet; import io.undertow.servlet.core.ManagedServlets; -import org.apache.camel.component.servlet.CamelHttpTransportServlet; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.k.Runtime; import org.apache.camel.test.AvailablePortFinder; @@ -35,11 +34,11 @@ public void testServletConfigurer() { Runtime runtime = Runtime.of(new DefaultCamelContext()); ServletRegistrationContextCustomizer servletRegistrationCustomizer = new ServletRegistrationContextCustomizer("/webhook/*", "webhook-servlet"); - servletRegistrationCustomizer.apply(runtime.getContext(), runtime.getRegistry()); + servletRegistrationCustomizer.apply(runtime.getCamelContext()); ServletContextCustomizer servletCustomizer = new ServletContextCustomizer(); servletCustomizer.setBindPort(AvailablePortFinder.getNextAvailable()); - servletCustomizer.apply(runtime.getContext()); + servletCustomizer.apply(runtime.getCamelContext()); DeploymentManager manager = Servlets.defaultContainer().getDeploymentByPath("/"); ManagedServlets managedServlets = manager.getDeployment().getServlets(); diff --git a/camel-k-runtime-servlet/src/test/java/org/apache/camel/k/servlet/ServletRegistrationCustomizerTest.java b/camel-k-runtime-servlet/src/test/java/org/apache/camel/k/servlet/ServletRegistrationCustomizerTest.java index d39d3e478..93877075b 100644 --- a/camel-k-runtime-servlet/src/test/java/org/apache/camel/k/servlet/ServletRegistrationCustomizerTest.java +++ b/camel-k-runtime-servlet/src/test/java/org/apache/camel/k/servlet/ServletRegistrationCustomizerTest.java @@ -20,9 +20,7 @@ import io.undertow.servlet.api.DeploymentManager; import io.undertow.servlet.core.ManagedServlet; import io.undertow.servlet.core.ManagedServlets; -import org.apache.camel.component.servlet.CamelHttpTransportServlet; import org.apache.camel.impl.DefaultCamelContext; -import org.apache.camel.k.InMemoryRegistry; import org.apache.camel.k.Runtime; import org.apache.camel.test.AvailablePortFinder; import org.junit.jupiter.api.Test; @@ -33,15 +31,14 @@ public class ServletRegistrationCustomizerTest { @Test public void testServletRegistrationConfigurer() { - Runtime.Registry registry = new InMemoryRegistry(); - Runtime runtime = Runtime.of(new DefaultCamelContext(registry), registry); + Runtime runtime = Runtime.of(new DefaultCamelContext()); ServletRegistrationContextCustomizer servletRegistrationCustomizer = new ServletRegistrationContextCustomizer(); - servletRegistrationCustomizer.apply(runtime.getContext(), runtime.getRegistry()); + servletRegistrationCustomizer.apply(runtime.getCamelContext()); ServletContextCustomizer servletCustomizer = new ServletContextCustomizer(); servletCustomizer.setBindPort(AvailablePortFinder.getNextAvailable()); - servletCustomizer.apply(runtime.getContext(), runtime.getRegistry()); + servletCustomizer.apply(runtime.getCamelContext()); DeploymentManager manager = Servlets.defaultContainer().getDeploymentByPath("/"); ManagedServlets managedServlets = manager.getDeployment().getServlets();