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-quarkus.git
commit 560693171cfbcdc34b0c021e632552666d0925af Author: lburgazzoli <[email protected]> AuthorDate: Tue Apr 21 08:09:21 2020 +0200 Read lock options for files are ignored #1105 --- .../component/file/deployment/FileProcessor.java | 28 +++++++++++++++++++++- .../camel/quarkus/component/file/it/FileTest.java | 4 ++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/extensions/file/deployment/src/main/java/org/apache/camel/quarkus/component/file/deployment/FileProcessor.java b/extensions/file/deployment/src/main/java/org/apache/camel/quarkus/component/file/deployment/FileProcessor.java index 3739d70..2aac6c8 100644 --- a/extensions/file/deployment/src/main/java/org/apache/camel/quarkus/component/file/deployment/FileProcessor.java +++ b/extensions/file/deployment/src/main/java/org/apache/camel/quarkus/component/file/deployment/FileProcessor.java @@ -16,11 +16,15 @@ */ package org.apache.camel.quarkus.component.file.deployment; +import java.nio.file.Paths; + import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import org.apache.camel.component.file.GenericFile; +import org.apache.camel.component.file.strategy.FileProcessStrategyFactory; import org.apache.camel.component.file.strategy.GenericFileProcessStrategyFactory; +import org.apache.camel.quarkus.core.deployment.CamelServiceBuildItem; class FileProcessor { @@ -35,6 +39,28 @@ class FileProcessor { ReflectiveClassBuildItem registerForReflection() { return new ReflectiveClassBuildItem(true, false, GenericFile.class, - GenericFileProcessStrategyFactory.class); + GenericFileProcessStrategyFactory.class, + FileProcessStrategyFactory.class); + } + + @BuildStep + CamelServiceBuildItem fileProcessStrategyFactoryService() { + // + // The current factory finder set-up does not take into account additional service defined from + // the factory file using prefixes, as example, the factory file content of the file component + // defines two services: + // + // class=org.apache.camel.component.file.FileComponent + // strategy.factory.class=org.apache.camel.component.file.strategy.FileProcessStrategyFactory + // + // but the current implementation puts an instance if the FileComponent class into the registry + // and blindly ignore strategy.factory.class, in addition, the current selector can't distinguish + // between REGISTER and DISCOVERY at service factory property level thus this CamelServiceBuildItem + // is needed to workaround the limitation. + // + return new CamelServiceBuildItem( + Paths.get("META-INF/services/org/apache/camel/component/strategy.factory.file"), + "file.strategy.factory", + "org.apache.camel.component.file.strategy.FileProcessStrategyFactory"); } } diff --git a/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/FileTest.java b/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/FileTest.java index 4452c1f..c7c3675 100644 --- a/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/FileTest.java +++ b/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/FileTest.java @@ -89,7 +89,7 @@ class FileTest { String fileName = RestAssured.given() .contentType(ContentType.TEXT) .body("") - .post("/file/create/" + FileRoutes.READ_LOCK_IN) + .post("/file/create/{name}", FileRoutes.READ_LOCK_IN) .then() .statusCode(201) .extract() @@ -100,7 +100,7 @@ class FileTest { // Read the file that should not be there RestAssured - .get("/file/get/" + FileRoutes.READ_LOCK_OUT + "/" + Paths.get(fileName).getFileName()) + .get("/file/get/{folder}/{name}", FileRoutes.READ_LOCK_OUT, Paths.get(fileName).getFileName()) .then() .statusCode(204); }
