You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2020/05/20 11:52:38 UTC
[camel-k-runtime] branch master updated (6ff4451 -> 5eb22f3)
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git.
from 6ff4451 Bump Log4j2 version to 2.13.3
new b7417bf [quarkus] support stopping the application #224
new 0176251 cron: use ManagementStrategy to shutdown the context to make cron available to all the runtimes
new 5eb22f3 cron: create a quarkus extension
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/workflows/pr-build.yml | 1 +
.../quarkus/deployment/DeploymentProcessor.java | 19 ++++---
.../it/src/main/resources/application.properties | 1 +
.../it/src/test/resources/application.properties | 21 --------
.../k/core/quarkus/RuntimeListenerAdapter.java | 18 ++++++-
.../deployment/pom.xml | 8 +--
.../camel/k/quarkus/cron}/deployment/Feature.java | 4 +-
.../it/pom.xml | 13 +++--
.../k/quarkus/cron}/deployment/Application.java | 35 ++++++-------
.../it/src/main/resources/application.properties | 3 +-
.../k/quarkus/cron}/deployment/ExtensionIT.java | 2 +-
.../k/quarkus/cron/deployment/ExtensionTest.java | 27 +++++++---
.../pom.xml | 2 +-
.../runtime/pom.xml | 6 +--
.../it/src/main/resources/application.properties | 1 +
.../it/src/test/resources/application.properties | 21 --------
.../it/src/main/resources/application.properties | 1 +
.../it/src/test/resources/application.properties | 21 --------
.../it/src/main/resources/application.properties | 1 +
.../it/src/test/resources/application.properties | 21 --------
camel-k-quarkus/pom.xml | 1 +
camel-k-runtime-bom/pom.xml | 10 ++++
.../main/java/org/apache/camel/k/RuntimeAware.java | 7 +--
.../apache/camel/k/listener/RoutesConfigurer.java | 5 ++
.../camel/k/cron/CronSourceLoaderInterceptor.java | 58 +++++++++++++++++++++-
.../java/org/apache/camel/k/cron/CronTest.java | 2 -
pom.xml | 26 ++++++++++
.../src/it/generate-catalog-main/verify.groovy | 2 +
.../src/it/generate-catalog-quarkus/verify.groovy | 2 +
.../camel/k/tooling/maven/GenerateCatalogMojo.java | 2 +-
30 files changed, 200 insertions(+), 141 deletions(-)
delete mode 100644 camel-k-quarkus/camel-k-quarkus-core/it/src/test/resources/application.properties
copy camel-k-quarkus/{camel-k-quarkus-loader-js => camel-k-quarkus-cron}/deployment/pom.xml (93%)
copy camel-k-quarkus/{camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus => camel-k-quarkus-cron/deployment/src/main/java/org/apache/camel/k/quarkus/cron}/deployment/Feature.java (89%)
copy camel-k-quarkus/{camel-k-quarkus-core => camel-k-quarkus-cron}/it/pom.xml (92%)
copy camel-k-quarkus/{camel-k-quarkus-core/it/src/main/java/org/apache/camel/k/core/quarkus => camel-k-quarkus-cron/it/src/main/java/org/apache/camel/k/quarkus/cron}/deployment/Application.java (62%)
copy camel-k-quarkus/{camel-k-quarkus-loader-js => camel-k-quarkus-cron}/it/src/main/resources/application.properties (94%)
copy camel-k-quarkus/{camel-k-quarkus-core/it/src/test/java/org/apache/camel/k/core/quarkus => camel-k-quarkus-cron/it/src/test/java/org/apache/camel/k/quarkus/cron}/deployment/ExtensionIT.java (94%)
copy tooling/camel-k-maven-plugin/src/it/generate-rest-dsl-from-v2/verify.groovy => camel-k-quarkus/camel-k-quarkus-cron/it/src/test/java/org/apache/camel/k/quarkus/cron/deployment/ExtensionTest.java (59%)
copy camel-k-quarkus/{camel-k-quarkus-core => camel-k-quarkus-cron}/pom.xml (96%)
copy camel-k-quarkus/{camel-k-quarkus-loader-xml => camel-k-quarkus-cron}/runtime/pom.xml (94%)
delete mode 100644 camel-k-quarkus/camel-k-quarkus-loader-js/it/src/test/resources/application.properties
delete mode 100644 camel-k-quarkus/camel-k-quarkus-loader-xml/it/src/test/resources/application.properties
delete mode 100644 camel-k-quarkus/camel-k-quarkus-loader-yaml/it/src/test/resources/application.properties
copy camel-k-runtime-webhook/src/main/java/org/apache/camel/k/webhook/WebhookAction.java => camel-k-runtime-core/src/main/java/org/apache/camel/k/RuntimeAware.java (86%)
[camel-k-runtime] 03/03: cron: create a quarkus extension
Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
commit 5eb22f321f1e4bb1a6af017f6b921014925a6693
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Wed May 20 12:23:56 2020 +0200
cron: create a quarkus extension
---
.github/workflows/pr-build.yml | 1 +
.../quarkus/deployment/DeploymentProcessor.java | 19 ++-
.../it/src/main/resources/application.properties | 1 +
.../it/src/test/resources/application.properties | 21 ---
.../{ => camel-k-quarkus-cron/deployment}/pom.xml | 46 +++---
.../camel/k/quarkus/cron/deployment/Feature.java | 29 ++++
camel-k-quarkus/camel-k-quarkus-cron/it/pom.xml | 159 +++++++++++++++++++++
.../k/quarkus/cron/deployment/Application.java | 46 ++++++
.../it/src/main/resources/application.properties | 3 +-
.../k/quarkus/cron/deployment/ExtensionIT.java | 23 +++
.../k/quarkus/cron/deployment/ExtensionTest.java | 38 +++++
camel-k-quarkus/{ => camel-k-quarkus-cron}/pom.xml | 30 +---
.../camel-k-quarkus-cron/runtime/pom.xml | 86 +++++++++++
.../it/src/main/resources/application.properties | 1 +
.../it/src/test/resources/application.properties | 21 ---
.../it/src/main/resources/application.properties | 1 +
.../it/src/test/resources/application.properties | 21 ---
.../it/src/main/resources/application.properties | 1 +
.../it/src/test/resources/application.properties | 21 ---
camel-k-quarkus/pom.xml | 1 +
camel-k-runtime-bom/pom.xml | 10 ++
.../camel/k/cron/CronSourceLoaderInterceptor.java | 4 +-
pom.xml | 26 ++++
.../src/it/generate-catalog-main/verify.groovy | 2 +
.../src/it/generate-catalog-quarkus/verify.groovy | 2 +
.../camel/k/tooling/maven/GenerateCatalogMojo.java | 2 +-
26 files changed, 480 insertions(+), 135 deletions(-)
diff --git a/.github/workflows/pr-build.yml b/.github/workflows/pr-build.yml
index 5e3b8ff..31262d8 100644
--- a/.github/workflows/pr-build.yml
+++ b/.github/workflows/pr-build.yml
@@ -61,6 +61,7 @@ jobs:
matrix:
native-image-project:
- :camel-k-quarkus-core-it
+ - :camel-k-quarkus-cron-it
- :camel-k-quarkus-loader-xml-it
- :camel-k-quarkus-loader-yaml-it
- :camel-k-runtime-example-quarkus-xml
diff --git a/camel-k-quarkus/camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus/deployment/DeploymentProcessor.java b/camel-k-quarkus/camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus/deployment/DeploymentProcessor.java
index c097c66..167daca 100644
--- a/camel-k-quarkus/camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus/deployment/DeploymentProcessor.java
+++ b/camel-k-quarkus/camel-k-quarkus-core/deployment/src/main/java/org/apache/camel/k/core/quarkus/deployment/DeploymentProcessor.java
@@ -40,12 +40,19 @@ import static org.apache.camel.k.core.quarkus.deployment.DeploymentSupport.getAl
public class DeploymentProcessor {
@BuildStep
- CamelServicePatternBuildItem servicePatterns() {
- return new CamelServicePatternBuildItem(
- CamelServicePatternBuildItem.CamelServiceDestination.REGISTRY,
- true,
- Constants.SOURCE_LOADER_RESOURCE_PATH + "/*",
- Constants.CONTEXT_CUSTOMIZER_RESOURCE_PATH + "/*");
+ List<CamelServicePatternBuildItem> servicePatterns() {
+ return List.of(
+ new CamelServicePatternBuildItem(
+ CamelServicePatternBuildItem.CamelServiceDestination.REGISTRY,
+ true,
+ Constants.SOURCE_LOADER_RESOURCE_PATH + "/*",
+ Constants.CONTEXT_CUSTOMIZER_RESOURCE_PATH + "/*"),
+ new CamelServicePatternBuildItem(
+ CamelServicePatternBuildItem.CamelServiceDestination.DISCOVERY,
+ true,
+ Constants.SOURCE_LOADER_INTERCEPTOR_RESOURCE_PATH + "/*")
+ );
+
}
@BuildStep
diff --git a/camel-k-quarkus/camel-k-quarkus-core/it/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-core/it/src/main/resources/application.properties
index 876ce6b..d43bc0b 100644
--- a/camel-k-quarkus/camel-k-quarkus-core/it/src/main/resources/application.properties
+++ b/camel-k-quarkus/camel-k-quarkus-core/it/src/main/resources/application.properties
@@ -19,6 +19,7 @@
#
quarkus.log.file.enable = false
quarkus.log.console.enable = false
+quarkus.banner.enabled = false
#
# Camel
diff --git a/camel-k-quarkus/camel-k-quarkus-core/it/src/test/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-core/it/src/test/resources/application.properties
deleted file mode 100644
index a35368c..0000000
--- a/camel-k-quarkus/camel-k-quarkus-core/it/src/test/resources/application.properties
+++ /dev/null
@@ -1,21 +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.
-## ---------------------------------------------------------------------------
-#
-# Quarkus
-#
-quarkus.log.file.enable = false
-quarkus.log.console.enable = false
\ No newline at end of file
diff --git a/camel-k-quarkus/pom.xml b/camel-k-quarkus/camel-k-quarkus-cron/deployment/pom.xml
similarity index 56%
copy from camel-k-quarkus/pom.xml
copy to camel-k-quarkus/camel-k-quarkus-cron/deployment/pom.xml
index 5643159..f8d594f 100644
--- a/camel-k-quarkus/pom.xml
+++ b/camel-k-quarkus/camel-k-quarkus-cron/deployment/pom.xml
@@ -20,19 +20,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-runtime-parent</artifactId>
+ <artifactId>camel-k-quarkus-cron-parent</artifactId>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <packaging>pom</packaging>
- <artifactId>camel-k-quarkus</artifactId>
+ <artifactId>camel-k-quarkus-cron-deployment</artifactId>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-bom</artifactId>
+ <artifactId>camel-quarkus-bom-deployment</artifactId>
<version>${camel-quarkus.version}</version>
<type>pom</type>
<scope>import</scope>
@@ -40,18 +39,33 @@
</dependencies>
</dependencyManagement>
- <modules>
- <module>camel-k-quarkus-loader-xml</module>
- <module>camel-k-quarkus-loader-js</module>
- <module>camel-k-quarkus-loader-yaml</module>
- <module>camel-k-quarkus-loader-java</module>
- <module>camel-k-quarkus-loader-groovy</module>
- <module>camel-k-quarkus-loader-kotlin</module>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-core-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-cron</artifactId>
+ </dependency>
+ </dependencies>
- <module>camel-k-quarkus-core</module>
- <module>camel-k-quarkus-knative</module>
-
- <module>camel-k-runtime-quarkus</module>
- </modules>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/camel-k-quarkus/camel-k-quarkus-cron/deployment/src/main/java/org/apache/camel/k/quarkus/cron/deployment/Feature.java b/camel-k-quarkus/camel-k-quarkus-cron/deployment/src/main/java/org/apache/camel/k/quarkus/cron/deployment/Feature.java
new file mode 100644
index 0000000..b8c60d3
--- /dev/null
+++ b/camel-k-quarkus/camel-k-quarkus-cron/deployment/src/main/java/org/apache/camel/k/quarkus/cron/deployment/Feature.java
@@ -0,0 +1,29 @@
+/*
+ * 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.quarkus.cron.deployment;
+
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+
+public class Feature {
+ private static final String FEATURE = "camel-k-runtime-cron";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+}
diff --git a/camel-k-quarkus/camel-k-quarkus-cron/it/pom.xml b/camel-k-quarkus/camel-k-quarkus-cron/it/pom.xml
new file mode 100644
index 0000000..7724032
--- /dev/null
+++ b/camel-k-quarkus/camel-k-quarkus-cron/it/pom.xml
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-cron-parent</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-k-quarkus-cron-it</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-cron</artifactId>
+ </dependency>
+
+ <!-- quarkus dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-jsonb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-resteasy-jsonb</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>io.rest-assured</groupId>
+ <artifactId>rest-assured</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>${build-helper-maven-plugin.version}</version>
+ <executions>
+ <execution>
+ <id>reserve-network-port</id>
+ <goals>
+ <goal>reserve-network-port</goal>
+ </goals>
+ <phase>process-resources</phase>
+ <configuration>
+ <portNames>
+ <portName>test.http.port.jvm</portName>
+ <portName>test.http.port.native</portName>
+ </portNames>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-maven-plugin</artifactId>
+ <version>${quarkus.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemProperties>
+ <quarkus.http.test-port>${test.http.port.jvm}</quarkus.http.test-port>
+ <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
+ </systemProperties>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ <quarkus.native.additional-build-args>--language:js</quarkus.native.additional-build-args>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ <configuration>
+ <systemProperties>
+ <quarkus.http.test-port>${test.http.port.native}</quarkus.http.test-port>
+ <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
+ </systemProperties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+
+</project>
diff --git a/camel-k-quarkus/camel-k-quarkus-cron/it/src/main/java/org/apache/camel/k/quarkus/cron/deployment/Application.java b/camel-k-quarkus/camel-k-quarkus-cron/it/src/main/java/org/apache/camel/k/quarkus/cron/deployment/Application.java
new file mode 100644
index 0000000..3d8cb21
--- /dev/null
+++ b/camel-k-quarkus/camel-k-quarkus-cron/it/src/main/java/org/apache/camel/k/quarkus/cron/deployment/Application.java
@@ -0,0 +1,46 @@
+/*
+ * 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.quarkus.cron.deployment;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ExtendedCamelContext;
+import org.apache.camel.k.Constants;
+
+@Path("/test")
+@ApplicationScoped
+public class Application {
+ @Inject
+ CamelContext context;
+
+ @GET
+ @Path("/find-cron-interceptor")
+ @Produces(MediaType.TEXT_PLAIN)
+ public String findCronInterceptor() {
+ return context.adapt(ExtendedCamelContext.class)
+ .getFactoryFinder(Constants.SOURCE_LOADER_INTERCEPTOR_RESOURCE_PATH)
+ .findClass("cron")
+ .map(Class::getName)
+ .orElse("");
+ }
+}
diff --git a/camel-k-quarkus/camel-k-quarkus-loader-js/it/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-cron/it/src/main/resources/application.properties
similarity index 94%
copy from camel-k-quarkus/camel-k-quarkus-loader-js/it/src/main/resources/application.properties
copy to camel-k-quarkus/camel-k-quarkus-cron/it/src/main/resources/application.properties
index 3dff777..2958915 100644
--- a/camel-k-quarkus/camel-k-quarkus-loader-js/it/src/main/resources/application.properties
+++ b/camel-k-quarkus/camel-k-quarkus-cron/it/src/main/resources/application.properties
@@ -18,7 +18,8 @@
# Quarkus
#
quarkus.log.file.enable = false
-quarkus.log.console.enable = false
+quarkus.log.console.enable = true
+quarkus.banner.enabled = false
#
# Quarkus :: Camel
diff --git a/camel-k-quarkus/camel-k-quarkus-cron/it/src/test/java/org/apache/camel/k/quarkus/cron/deployment/ExtensionIT.java b/camel-k-quarkus/camel-k-quarkus-cron/it/src/test/java/org/apache/camel/k/quarkus/cron/deployment/ExtensionIT.java
new file mode 100644
index 0000000..9039b12
--- /dev/null
+++ b/camel-k-quarkus/camel-k-quarkus-cron/it/src/test/java/org/apache/camel/k/quarkus/cron/deployment/ExtensionIT.java
@@ -0,0 +1,23 @@
+/*
+ * 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.quarkus.cron.deployment;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+public class ExtensionIT extends ExtensionTest {
+}
\ No newline at end of file
diff --git a/camel-k-quarkus/camel-k-quarkus-cron/it/src/test/java/org/apache/camel/k/quarkus/cron/deployment/ExtensionTest.java b/camel-k-quarkus/camel-k-quarkus-cron/it/src/test/java/org/apache/camel/k/quarkus/cron/deployment/ExtensionTest.java
new file mode 100644
index 0000000..8d0def1
--- /dev/null
+++ b/camel-k-quarkus/camel-k-quarkus-cron/it/src/test/java/org/apache/camel/k/quarkus/cron/deployment/ExtensionTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.quarkus.cron.deployment;
+
+import java.io.IOException;
+
+import io.quarkus.test.junit.QuarkusTest;
+import org.apache.camel.k.cron.CronSourceLoaderInterceptor;
+import org.junit.jupiter.api.Test;
+
+import static io.restassured.RestAssured.when;
+import static org.hamcrest.Matchers.is;
+
+@QuarkusTest
+public class ExtensionTest {
+ @Test
+ public void cronInterceptorIsRegistered() throws IOException {
+ when()
+ .get("/test/find-cron-interceptor")
+ .then()
+ .statusCode(200)
+ .body(is(CronSourceLoaderInterceptor.class.getName()));
+ }
+}
diff --git a/camel-k-quarkus/pom.xml b/camel-k-quarkus/camel-k-quarkus-cron/pom.xml
similarity index 57%
copy from camel-k-quarkus/pom.xml
copy to camel-k-quarkus/camel-k-quarkus-cron/pom.xml
index 5643159..9ae1a12 100644
--- a/camel-k-quarkus/pom.xml
+++ b/camel-k-quarkus/camel-k-quarkus-cron/pom.xml
@@ -20,38 +20,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.camel.k</groupId>
- <artifactId>camel-k-runtime-parent</artifactId>
+ <artifactId>camel-k-quarkus</artifactId>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
- <artifactId>camel-k-quarkus</artifactId>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-bom</artifactId>
- <version>${camel-quarkus.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
+ <artifactId>camel-k-quarkus-cron-parent</artifactId>
<modules>
- <module>camel-k-quarkus-loader-xml</module>
- <module>camel-k-quarkus-loader-js</module>
- <module>camel-k-quarkus-loader-yaml</module>
- <module>camel-k-quarkus-loader-java</module>
- <module>camel-k-quarkus-loader-groovy</module>
- <module>camel-k-quarkus-loader-kotlin</module>
-
- <module>camel-k-quarkus-core</module>
- <module>camel-k-quarkus-knative</module>
-
- <module>camel-k-runtime-quarkus</module>
+ <module>runtime</module>
+ <module>deployment</module>
+ <module>it</module>
</modules>
</project>
diff --git a/camel-k-quarkus/camel-k-quarkus-cron/runtime/pom.xml b/camel-k-quarkus/camel-k-quarkus-cron/runtime/pom.xml
new file mode 100644
index 0000000..73a889b
--- /dev/null
+++ b/camel-k-quarkus/camel-k-quarkus-cron/runtime/pom.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-cron-parent</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-k-quarkus-cron</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-runtime-cron</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-bootstrap-maven-plugin</artifactId>
+ <version>${quarkus.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>extension-descriptor</goal>
+ </goals>
+ <configuration>
+ <deployment>${project.groupId}:${project.artifactId}-deployment:${project.version}</deployment>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.jboss.jandex</groupId>
+ <artifactId>jandex-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>make-index</id>
+ <goals>
+ <goal>jandex</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/camel-k-quarkus/camel-k-quarkus-loader-js/it/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-loader-js/it/src/main/resources/application.properties
index 3dff777..b4cc6d4 100644
--- a/camel-k-quarkus/camel-k-quarkus-loader-js/it/src/main/resources/application.properties
+++ b/camel-k-quarkus/camel-k-quarkus-loader-js/it/src/main/resources/application.properties
@@ -19,6 +19,7 @@
#
quarkus.log.file.enable = false
quarkus.log.console.enable = false
+quarkus.banner.enabled = false
#
# Quarkus :: Camel
diff --git a/camel-k-quarkus/camel-k-quarkus-loader-js/it/src/test/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-loader-js/it/src/test/resources/application.properties
deleted file mode 100644
index a35368c..0000000
--- a/camel-k-quarkus/camel-k-quarkus-loader-js/it/src/test/resources/application.properties
+++ /dev/null
@@ -1,21 +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.
-## ---------------------------------------------------------------------------
-#
-# Quarkus
-#
-quarkus.log.file.enable = false
-quarkus.log.console.enable = false
\ No newline at end of file
diff --git a/camel-k-quarkus/camel-k-quarkus-loader-xml/it/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-loader-xml/it/src/main/resources/application.properties
index d277fd6..73b0e70 100644
--- a/camel-k-quarkus/camel-k-quarkus-loader-xml/it/src/main/resources/application.properties
+++ b/camel-k-quarkus/camel-k-quarkus-loader-xml/it/src/main/resources/application.properties
@@ -19,6 +19,7 @@
#
quarkus.log.file.enable = false
quarkus.log.console.enable = false
+quarkus.banner.enabled = false
#
# Quarkus :: Camel
diff --git a/camel-k-quarkus/camel-k-quarkus-loader-xml/it/src/test/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-loader-xml/it/src/test/resources/application.properties
deleted file mode 100644
index a35368c..0000000
--- a/camel-k-quarkus/camel-k-quarkus-loader-xml/it/src/test/resources/application.properties
+++ /dev/null
@@ -1,21 +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.
-## ---------------------------------------------------------------------------
-#
-# Quarkus
-#
-quarkus.log.file.enable = false
-quarkus.log.console.enable = false
\ No newline at end of file
diff --git a/camel-k-quarkus/camel-k-quarkus-loader-yaml/it/src/main/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-loader-yaml/it/src/main/resources/application.properties
index 3dff777..b4cc6d4 100644
--- a/camel-k-quarkus/camel-k-quarkus-loader-yaml/it/src/main/resources/application.properties
+++ b/camel-k-quarkus/camel-k-quarkus-loader-yaml/it/src/main/resources/application.properties
@@ -19,6 +19,7 @@
#
quarkus.log.file.enable = false
quarkus.log.console.enable = false
+quarkus.banner.enabled = false
#
# Quarkus :: Camel
diff --git a/camel-k-quarkus/camel-k-quarkus-loader-yaml/it/src/test/resources/application.properties b/camel-k-quarkus/camel-k-quarkus-loader-yaml/it/src/test/resources/application.properties
deleted file mode 100644
index a35368c..0000000
--- a/camel-k-quarkus/camel-k-quarkus-loader-yaml/it/src/test/resources/application.properties
+++ /dev/null
@@ -1,21 +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.
-## ---------------------------------------------------------------------------
-#
-# Quarkus
-#
-quarkus.log.file.enable = false
-quarkus.log.console.enable = false
\ No newline at end of file
diff --git a/camel-k-quarkus/pom.xml b/camel-k-quarkus/pom.xml
index 5643159..539bbbf 100644
--- a/camel-k-quarkus/pom.xml
+++ b/camel-k-quarkus/pom.xml
@@ -50,6 +50,7 @@
<module>camel-k-quarkus-core</module>
<module>camel-k-quarkus-knative</module>
+ <module>camel-k-quarkus-cron</module>
<module>camel-k-runtime-quarkus</module>
</modules>
diff --git a/camel-k-runtime-bom/pom.xml b/camel-k-runtime-bom/pom.xml
index fdf21cb..8051ed4 100644
--- a/camel-k-runtime-bom/pom.xml
+++ b/camel-k-runtime-bom/pom.xml
@@ -255,6 +255,16 @@
<artifactId>camel-k-quarkus-knative-deployment</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-cron</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-cron-deployment</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- loaders -->
diff --git a/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java b/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java
index 04585e9..e97eaee 100644
--- a/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java
+++ b/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java
@@ -85,8 +85,8 @@ public class CronSourceLoaderInterceptor implements SourceLoader.Interceptor, Ru
return;
}
- CamelContext context = runtime.getCamelContext();
- String[] components = overridableComponents.split(",", -1);
+ final CamelContext context = runtime.getCamelContext();
+ final String[] components = overridableComponents.split(",", -1);
for (RouteDefinition def : builder.getRouteCollection().getRoutes()) {
String uri = def.getInput() != null ? def.getInput().getUri() : null;
diff --git a/pom.xml b/pom.xml
index 7edbcd9..10ff851 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,6 +66,7 @@
<jandex.version>2.1.3.Final</jandex.version>
<javapoet.version>1.11.1</javapoet.version>
<rest-assured.version>4.3.0</rest-assured.version>
+ <hamcrest.version>2.2</hamcrest.version>
<gmavenplus-plugin.version>1.9.0</gmavenplus-plugin.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
@@ -362,6 +363,16 @@
<artifactId>camel-k-runtime-knative</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-runtime-cron</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-runtime-master</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- runtime - quarkus -->
<dependency>
@@ -454,6 +465,16 @@
<artifactId>camel-k-quarkus-knative-deployment</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-cron</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.k</groupId>
+ <artifactId>camel-k-quarkus-knative-cron</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<!-- loaders -->
<dependency>
@@ -564,6 +585,11 @@
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ <version>${hamcrest.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
diff --git a/tooling/camel-k-maven-plugin/src/it/generate-catalog-main/verify.groovy b/tooling/camel-k-maven-plugin/src/it/generate-catalog-main/verify.groovy
index 21d246b..b08a066 100644
--- a/tooling/camel-k-maven-plugin/src/it/generate-catalog-main/verify.groovy
+++ b/tooling/camel-k-maven-plugin/src/it/generate-catalog-main/verify.groovy
@@ -24,6 +24,8 @@ new File(basedir, "catalog.yaml").withReader {
assert catalog.spec.runtime.metadata['quarkus.version'] == quarkusVersion
assert catalog.spec.runtime.metadata['camel-quarkus.version'] == camelQuarkusVersion
+ assert catalog.spec.runtime.capabilities['cron'].dependencies[0].groupId == 'org.apache.camel.k'
+ assert catalog.spec.runtime.capabilities['cron'].dependencies[0].artifactId == 'camel-k-runtime-cron'
assert catalog.spec.runtime.capabilities['health'].dependencies[0].groupId == 'org.apache.camel.k'
assert catalog.spec.runtime.capabilities['health'].dependencies[0].artifactId == 'camel-k-runtime-health'
assert catalog.spec.runtime.capabilities['rest'].dependencies[0].groupId == 'org.apache.camel'
diff --git a/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/verify.groovy b/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/verify.groovy
index 9a450a0..5ad4fe2 100644
--- a/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/verify.groovy
+++ b/tooling/camel-k-maven-plugin/src/it/generate-catalog-quarkus/verify.groovy
@@ -24,6 +24,8 @@ new File(basedir, "catalog.yaml").withReader {
assert catalog.spec.runtime.metadata['quarkus.version'] == quarkusVersion
assert catalog.spec.runtime.metadata['camel-quarkus.version'] == camelQuarkusVersion
+ assert catalog.spec.runtime.capabilities['cron'].dependencies[0].groupId == 'org.apache.camel.k'
+ assert catalog.spec.runtime.capabilities['cron'].dependencies[0].artifactId == 'camel-k-quarkus-cron'
assert catalog.spec.runtime.capabilities['health'].dependencies[0].groupId == 'org.apache.camel.quarkus'
assert catalog.spec.runtime.capabilities['health'].dependencies[0].artifactId == 'camel-quarkus-microprofile-health'
assert catalog.spec.runtime.capabilities['rest'].dependencies[0].groupId == 'org.apache.camel.quarkus'
diff --git a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
index 99de096..c63fae0 100644
--- a/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
+++ b/tooling/camel-k-maven-plugin/src/main/java/org/apache/camel/k/tooling/maven/GenerateCatalogMojo.java
@@ -145,7 +145,7 @@ public class GenerateCatalogMojo extends AbstractMojo {
runtimeSpec.addDependency("org.apache.camel.k", "camel-k-runtime-quarkus");
runtimeSpec.putCapability(
"cron",
- CamelCapability.forArtifact("org.apache.camel.k", "camel-k-runtime-cron"));
+ CamelCapability.forArtifact("org.apache.camel.k", "camel-k-quarkus-cron"));
runtimeSpec.putCapability(
"health",
CamelCapability.forArtifact("org.apache.camel.quarkus", "camel-quarkus-microprofile-health"));
[camel-k-runtime] 01/03: [quarkus] support stopping the application
#224
Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
commit b7417bfd74eb7813ec0f3070e661ee93561ba8d9
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Fri May 15 16:06:32 2020 +0200
[quarkus] support stopping the application #224
---
.../camel/k/core/quarkus/RuntimeListenerAdapter.java | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/camel-k-quarkus/camel-k-quarkus-core/runtime/src/main/java/org/apache/camel/k/core/quarkus/RuntimeListenerAdapter.java b/camel-k-quarkus/camel-k-quarkus-core/runtime/src/main/java/org/apache/camel/k/core/quarkus/RuntimeListenerAdapter.java
index 58d4d57..72a5116 100644
--- a/camel-k-quarkus/camel-k-quarkus-core/runtime/src/main/java/org/apache/camel/k/core/quarkus/RuntimeListenerAdapter.java
+++ b/camel-k-quarkus/camel-k-quarkus-core/runtime/src/main/java/org/apache/camel/k/core/quarkus/RuntimeListenerAdapter.java
@@ -21,6 +21,7 @@ import java.util.Comparator;
import java.util.List;
import java.util.Properties;
+import io.quarkus.runtime.Quarkus;
import org.apache.camel.CamelContext;
import org.apache.camel.RoutesBuilder;
import org.apache.camel.k.Runtime;
@@ -95,7 +96,17 @@ public class RuntimeListenerAdapter implements MainListener {
}
private static Runtime on(CamelContext context) {
- return Runtime.on(context);
+ return new Runtime() {
+ @Override
+ public CamelContext getCamelContext() {
+ return context;
+ }
+
+ @Override
+ public void stop() throws Exception {
+ Quarkus.asyncExit();
+ }
+ };
}
private static Runtime on(BaseMainSupport main) {
@@ -124,6 +135,11 @@ public class RuntimeListenerAdapter implements MainListener {
public void setProperties(Properties properties) {
main.getCamelContext().getPropertiesComponent().setOverrideProperties(properties);
}
+
+ @Override
+ public void stop() throws Exception {
+ Quarkus.asyncExit();
+ }
};
}
}
[camel-k-runtime] 02/03: cron: use ManagementStrategy to shutdown
the context to make cron available to all the runtimes
Posted by lb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
commit 01762515a757b1b011401d0c220261ffad9e3188
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Fri May 15 16:31:04 2020 +0200
cron: use ManagementStrategy to shutdown the context to make cron available to all the runtimes
---
.../main/java/org/apache/camel/k/RuntimeAware.java | 22 +++++++++
.../apache/camel/k/listener/RoutesConfigurer.java | 5 ++
.../camel/k/cron/CronSourceLoaderInterceptor.java | 56 +++++++++++++++++++++-
.../java/org/apache/camel/k/cron/CronTest.java | 2 -
4 files changed, 82 insertions(+), 3 deletions(-)
diff --git a/camel-k-runtime-core/src/main/java/org/apache/camel/k/RuntimeAware.java b/camel-k-runtime-core/src/main/java/org/apache/camel/k/RuntimeAware.java
new file mode 100644
index 0000000..96f9571
--- /dev/null
+++ b/camel-k-runtime-core/src/main/java/org/apache/camel/k/RuntimeAware.java
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.k;
+
+public interface RuntimeAware {
+ void setRuntime(Runtime runtime);
+ Runtime getRuntime();
+}
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 125eccd..c701621 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
@@ -21,6 +21,7 @@ import java.util.List;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.k.Constants;
import org.apache.camel.k.Runtime;
+import org.apache.camel.k.RuntimeAware;
import org.apache.camel.k.Source;
import org.apache.camel.k.SourceLoader;
import org.apache.camel.k.Sources;
@@ -83,6 +84,10 @@ public class RoutesConfigurer extends AbstractPhaseListener {
try {
for (SourceLoader.Interceptor interceptor: interceptors) {
+ if (interceptor instanceof RuntimeAware) {
+ ((RuntimeAware) interceptor).setRuntime(runtime);
+ }
+
interceptor.beforeLoad(loader, source);
}
diff --git a/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java b/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java
index f24d463..04585e9 100644
--- a/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java
+++ b/camel-k-runtime-cron/src/main/java/org/apache/camel/k/cron/CronSourceLoaderInterceptor.java
@@ -18,18 +18,27 @@ package org.apache.camel.k.cron;
import java.util.Optional;
+import org.apache.camel.CamelContext;
import org.apache.camel.RoutesBuilder;
+import org.apache.camel.k.Runtime;
+import org.apache.camel.k.RuntimeAware;
import org.apache.camel.k.Source;
import org.apache.camel.k.SourceLoader;
import org.apache.camel.k.annotation.LoaderInterceptor;
import org.apache.camel.k.support.RuntimeSupport;
import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.spi.CamelEvent;
+import org.apache.camel.support.EventNotifierSupport;
import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@LoaderInterceptor("cron")
-public class CronSourceLoaderInterceptor implements SourceLoader.Interceptor {
+public class CronSourceLoaderInterceptor implements SourceLoader.Interceptor, RuntimeAware {
+
private String timerUri;
private String overridableComponents;
+ private Runtime runtime;
public CronSourceLoaderInterceptor() {
this.timerUri = "timer:camel-k-cron-override?delay=0&period=1&repeatCount=1";
@@ -53,6 +62,16 @@ public class CronSourceLoaderInterceptor implements SourceLoader.Interceptor {
}
@Override
+ public void setRuntime(Runtime runtime) {
+ this.runtime = runtime;
+ }
+
+ @Override
+ public Runtime getRuntime() {
+ return runtime;
+ }
+
+ @Override
public void beforeLoad(SourceLoader loader, Source source) {
}
@@ -66,12 +85,20 @@ public class CronSourceLoaderInterceptor implements SourceLoader.Interceptor {
return;
}
+ CamelContext context = runtime.getCamelContext();
String[] components = overridableComponents.split(",", -1);
for (RouteDefinition def : builder.getRouteCollection().getRoutes()) {
String uri = def.getInput() != null ? def.getInput().getUri() : null;
if (shouldBeOverridden(uri, components)) {
def.getInput().setUri(timerUri);
+
+ //
+ // Don't install the shutdown strategy more than once.
+ //
+ if (context.getManagementStrategy().getEventNotifiers().stream().noneMatch(CronShutdownStrategy.class::isInstance)) {
+ context.getManagementStrategy().addEventNotifier(new CronShutdownStrategy(runtime));
+ }
}
}
});
@@ -95,4 +122,31 @@ public class CronSourceLoaderInterceptor implements SourceLoader.Interceptor {
}
return false;
}
+
+ private static class CronShutdownStrategy extends EventNotifierSupport {
+ private static final Logger LOGGER = LoggerFactory.getLogger(CronShutdownStrategy.class);
+ private final Runtime runtime;
+
+ public CronShutdownStrategy(Runtime runtime) {
+ this.runtime = runtime;
+ }
+
+ @Override
+ public void notify(CamelEvent event) throws Exception {
+ LOGGER.info("Initiate runtime shutdown");
+ this.runtime.getCamelContext().getExecutorServiceManager().newThread("CronShutdownStrategy", () -> {
+ try {
+ LOGGER.info("Shutting down the runtime");
+ runtime.stop();
+ } catch (Exception e) {
+ LOGGER.warn("Error while shutting down the runtime", e);
+ }
+ }).start();
+ }
+
+ @Override
+ public boolean isEnabled(CamelEvent event) {
+ return event instanceof CamelEvent.ExchangeCompletedEvent || event instanceof CamelEvent.ExchangeFailedEvent;
+ }
+ }
}
diff --git a/camel-k-runtime-cron/src/test/java/org/apache/camel/k/cron/CronTest.java b/camel-k-runtime-cron/src/test/java/org/apache/camel/k/cron/CronTest.java
index 9785987..d90427a 100644
--- a/camel-k-runtime-cron/src/test/java/org/apache/camel/k/cron/CronTest.java
+++ b/camel-k-runtime-cron/src/test/java/org/apache/camel/k/cron/CronTest.java
@@ -37,8 +37,6 @@ public class CronTest {
public void testCronTimerActivation(String routes, String cronOverride) throws Exception {
ApplicationRuntime runtime = new ApplicationRuntime();
runtime.setProperties(
- // does not seems to work
- "camel.main.duration-max-messages", "1",
"loader.interceptor.cron.overridable-components", cronOverride
);
runtime.addListener(RoutesConfigurer.forRoutes(routes));