This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch json-patch-jvm-ext in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit befd834a8f9c5bc9c134017ef41b22d4387007dc Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu Dec 23 08:11:38 2021 +0100 Added Json-Patch Extension --- extensions-jvm/json-patch/deployment/pom.xml | 63 ++++++++++++ .../json/patch/deployment/JsonPatchProcessor.java | 46 +++++++++ extensions-jvm/json-patch/pom.xml | 39 +++++++ extensions-jvm/json-patch/runtime/pom.xml | 112 +++++++++++++++++++++ .../main/resources/META-INF/quarkus-extension.yaml | 32 ++++++ extensions-jvm/pom.xml | 1 + integration-tests/json-patch/pom.xml | 103 +++++++++++++++++++ .../component/json/patch/it/JsonPatchResource.java | 55 ++++++++++ .../component/json/patch/it/JsonPatchTest.java | 37 +++++++ integration-tests/pom.xml | 1 + poms/bom/pom.xml | 15 +++ 11 files changed, 504 insertions(+) diff --git a/extensions-jvm/json-patch/deployment/pom.xml b/extensions-jvm/json-patch/deployment/pom.xml new file mode 100644 index 0000000..87f4f6e --- /dev/null +++ b/extensions-jvm/json-patch/deployment/pom.xml @@ -0,0 +1,63 @@ +<?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"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-json-patch-parent</artifactId> + <version>2.7.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-json-patch-deployment</artifactId> + <name>Camel Quarkus :: JsonPatch :: Deployment</name> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-json-patch</artifactId> + </dependency> + </dependencies> + + <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/extensions-jvm/json-patch/deployment/src/main/java/org/apache/camel/quarkus/component/json/patch/deployment/JsonPatchProcessor.java b/extensions-jvm/json-patch/deployment/src/main/java/org/apache/camel/quarkus/component/json/patch/deployment/JsonPatchProcessor.java new file mode 100644 index 0000000..0e90409 --- /dev/null +++ b/extensions-jvm/json-patch/deployment/src/main/java/org/apache/camel/quarkus/component/json/patch/deployment/JsonPatchProcessor.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.quarkus.component.json.patch.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.pkg.steps.NativeBuild; +import org.apache.camel.quarkus.core.JvmOnlyRecorder; +import org.jboss.logging.Logger; + +class JsonPatchProcessor { + + private static final Logger LOG = Logger.getLogger(JsonPatchProcessor.class); + private static final String FEATURE = "camel-json-patch"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + /** + * Remove this once this extension starts supporting the native mode. + */ + @BuildStep(onlyIf = NativeBuild.class) + @Record(value = ExecutionTime.RUNTIME_INIT) + void warnJvmInNative(JvmOnlyRecorder recorder) { + JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time + recorder.warnJvmInNative(FEATURE); // warn at runtime + } +} diff --git a/extensions-jvm/json-patch/pom.xml b/extensions-jvm/json-patch/pom.xml new file mode 100644 index 0000000..f680858 --- /dev/null +++ b/extensions-jvm/json-patch/pom.xml @@ -0,0 +1,39 @@ +<?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"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-extensions-jvm</artifactId> + <version>2.7.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-json-patch-parent</artifactId> + <name>Camel Quarkus :: JsonPatch</name> + <packaging>pom</packaging> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> +</project> diff --git a/extensions-jvm/json-patch/runtime/pom.xml b/extensions-jvm/json-patch/runtime/pom.xml new file mode 100644 index 0000000..778bffe --- /dev/null +++ b/extensions-jvm/json-patch/runtime/pom.xml @@ -0,0 +1,112 @@ +<?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"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-json-patch-parent</artifactId> + <version>2.7.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-json-patch</artifactId> + <name>Camel Quarkus :: JsonPatch :: Runtime</name> + <description>JsonPatch component which transform JSON using JSON patch (RFC 6902).</description> + + <properties> + <camel.quarkus.jvmSince>2.7.0</camel.quarkus.jvmSince> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-json-patch</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-bootstrap-maven-plugin</artifactId> + </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> + </plugins> + </build> + + + <profiles> + <profile> + <id>full</id> + <activation> + <property> + <name>!quickly</name> + </property> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-maven-plugin</artifactId> + <executions> + <execution> + <id>update-extension-doc-page</id> + <goals> + <goal>update-extension-doc-page</goal> + </goals> + <phase>process-classes</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> diff --git a/extensions-jvm/json-patch/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions-jvm/json-patch/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..b0364aa --- /dev/null +++ b/extensions-jvm/json-patch/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,32 @@ +# +# 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. +# + +# This is a generated file. Do not edit directly! +# To re-generate, run the following command from the top level directory: +# +# mvn -N cq:update-quarkus-metadata +# +--- +name: "Camel JsonPatch" +description: "JsonPatch component which transform JSON using JSON patch (RFC 6902)" +metadata: + unlisted: true + guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/json-patch.html" + categories: + - "integration" + status: + - "preview" diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml index 70b7efe..077362d 100644 --- a/extensions-jvm/pom.xml +++ b/extensions-jvm/pom.xml @@ -87,6 +87,7 @@ <module>jgroups-raft</module> <module>jooq</module> <module>joor</module> + <module>json-patch</module> <module>jsonapi</module> <module>jt400</module> <module>kamelet-reify</module> diff --git a/integration-tests/json-patch/pom.xml b/integration-tests/json-patch/pom.xml new file mode 100644 index 0000000..a39ab63 --- /dev/null +++ b/integration-tests/json-patch/pom.xml @@ -0,0 +1,103 @@ +<?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"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-build-parent-it</artifactId> + <version>2.7.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent-it/pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-integration-test-json-patch</artifactId> + <name>Camel Quarkus :: Integration Tests :: JsonPatch</name> + <description>Integration tests for Camel Quarkus JsonPatch extension</description> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>${quarkus.platform.group-id}</groupId> + <artifactId>${quarkus.platform.artifact-id}</artifactId> + <version>${quarkus.platform.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-test</artifactId> + <version>${camel-quarkus.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-json-patch</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy</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> + </dependencies> + + <profiles> + <profile> + <id>virtualDependencies</id> + <activation> + <property> + <name>!noVirtualDependencies</name> + </property> + </activation> + <dependencies> + <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-json-patch-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> + </profile> + </profiles> +</project> diff --git a/integration-tests/json-patch/src/main/java/org/apache/camel/quarkus/component/json/patch/it/JsonPatchResource.java b/integration-tests/json-patch/src/main/java/org/apache/camel/quarkus/component/json/patch/it/JsonPatchResource.java new file mode 100644 index 0000000..f2bff4f --- /dev/null +++ b/integration-tests/json-patch/src/main/java/org/apache/camel/quarkus/component/json/patch/it/JsonPatchResource.java @@ -0,0 +1,55 @@ +/* + * 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.quarkus.component.json.patch.it; + +import java.net.URI; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.apache.camel.CamelContext; +import org.jboss.logging.Logger; + +@Path("/json-patch") +@ApplicationScoped +public class JsonPatchResource { + + private static final Logger LOG = Logger.getLogger(JsonPatchResource.class); + + private static final String COMPONENT_JSON_PATCH = "json-patch"; + @Inject + CamelContext context; + + @Path("/load/component/json-patch") + @GET + @Produces(MediaType.TEXT_PLAIN) + public Response loadComponentJsonPatch() throws Exception { + /* This is an autogenerated test */ + if (context.getComponent(COMPONENT_JSON_PATCH) != null) { + return Response.ok().build(); + } + LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_JSON_PATCH); + return Response.status(500, COMPONENT_JSON_PATCH + " could not be loaded from the Camel context").build(); + } +} diff --git a/integration-tests/json-patch/src/test/java/org/apache/camel/quarkus/component/json/patch/it/JsonPatchTest.java b/integration-tests/json-patch/src/test/java/org/apache/camel/quarkus/component/json/patch/it/JsonPatchTest.java new file mode 100644 index 0000000..1b004e6 --- /dev/null +++ b/integration-tests/json-patch/src/test/java/org/apache/camel/quarkus/component/json/patch/it/JsonPatchTest.java @@ -0,0 +1,37 @@ +/* + * 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.quarkus.component.json.patch.it; + +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +@QuarkusTest +class JsonPatchTest { + + @Test + public void loadComponentJsonPatch() { + /* A simple autogenerated test */ + RestAssured.get("/json-patch/load/component/json-patch") + .then() + .statusCode(200); + } + +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 436955f..08f2ae2 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -126,6 +126,7 @@ <module>js-dsl</module> <module>jsch</module> <module>jslt</module> + <module>json-patch</module> <module>json-validator</module> <module>jsonata</module> <module>jsonpath</module> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 0916434..2be4808 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -1468,6 +1468,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-json-patch</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-json-validator</artifactId> <version>${camel.version}</version> </dependency> @@ -4036,6 +4041,16 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-json-patch</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-json-patch-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-json-validator</artifactId> <version>${camel-quarkus.version}</version> </dependency>