This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push: new b2b07f6 Initial camel-consul support new 9c16da6 Merge pull request #615 from lburgazzoli/consul b2b07f6 is described below commit b2b07f68f2bc88d9ed4f7a4c9b872bdd5c7521a7 Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Tue Jan 7 14:15:26 2020 +0100 Initial camel-consul support --- .../pages/list-of-camel-quarkus-extensions.adoc | 5 +- extensions/consul/deployment/pom.xml | 83 +++++++++++++ .../consul/deployment/ConsulProcessor.java | 48 ++++++++ .../{support/httpcomponents => consul}/pom.xml | 19 +-- extensions/consul/runtime/pom.xml | 90 ++++++++++++++ .../main/resources/META-INF/quarkus-extension.yaml | 27 +++++ extensions/pom.xml | 1 + extensions/readme.adoc | 5 +- .../support/consul-client/deployment/pom.xml | 74 +++++++++++ .../deployment/ConsulClientSupportFeature.java | 29 +++++ .../deployment/ConsulClientSupportProcessor.java | 80 ++++++++++++ .../{httpcomponents => consul-client}/pom.xml | 10 +- extensions/support/consul-client/runtime/pom.xml | 100 +++++++++++++++ .../main/resources/META-INF/quarkus-extension.yaml | 30 +++++ extensions/support/pom.xml | 2 + extensions/support/retrofit/deployment/pom.xml | 74 +++++++++++ .../deployment/RetrofitSupportFeature.java | 29 +++++ .../support/{httpcomponents => retrofit}/pom.xml | 10 +- extensions/support/retrofit/runtime/pom.xml | 92 ++++++++++++++ ...etableFutureCallAdapterFactorySubstitution.java | 27 +++++ .../DefaultCallAdapterFactorySubstitution.java | 27 +++++ .../ExecutorCallAdapterFactorySubstitution.java | 36 ++++++ .../OptionalConverterFactorySubstitution.java | 27 +++++ .../retrofit/graal/PlatformSubstitution.java | 69 +++++++++++ .../main/resources/META-INF/quarkus-extension.yaml | 29 +++++ integration-tests/consul/pom.xml | 135 +++++++++++++++++++++ .../component/consul/it/ConsulResource.java | 63 ++++++++++ .../quarkus/component/consul/it/ConsulIT.java | 23 ++++ .../quarkus/component/consul/it/ConsulTest.java | 53 ++++++++ .../component/consul/it/ConsulTestResource.java | 69 +++++++++++ integration-tests/pom.xml | 1 + pom.xml | 2 + poms/bom-deployment/pom.xml | 15 +++ poms/bom/pom.xml | 40 ++++++ 34 files changed, 1405 insertions(+), 19 deletions(-) diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc index 034c9b1..012169d 100644 --- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc +++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc @@ -6,7 +6,7 @@ As of Camel Quarkus {camel-quarkus-last-release} the following Camel artifacts a == Camel Components // components: START -Number of Camel components: 56 in 48 JAR artifacts (0 deprecated) +Number of Camel components: 57 in 49 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -54,6 +54,9 @@ Number of Camel components: 56 in 48 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/class-component.html[Class] (camel-quarkus-bean) + `class:beanName` | 0.2.0 | The class component is for invoking Java classes (Java beans) from Camel. +| link:https://camel.apache.org/components/latest/consul-component.html[Consul] (camel-quarkus-consul) + +`consul:apiEndpoint` | 1.0.0 | The camel consul component allows you to work with Consul, a distributed, highly available, datacenter-aware, service discovery and configuration system. + | link:https://camel.apache.org/components/latest/controlbus-component.html[Control Bus] (camel-quarkus-controlbus) + `controlbus:command:language` | 0.4.0 | The controlbus component provides easy management of Camel applications based on the Control Bus EIP pattern. diff --git a/extensions/consul/deployment/pom.xml b/extensions/consul/deployment/pom.xml new file mode 100644 index 0000000..379ed00 --- /dev/null +++ b/extensions/consul/deployment/pom.xml @@ -0,0 +1,83 @@ +<?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-consul-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-consul-deployment</artifactId> + <name>Camel Quarkus :: Consul :: Deployment</name> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-jackson-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-consul-client-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-consul</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/consul/deployment/src/main/java/org/apache/camel/quarkus/component/consul/deployment/ConsulProcessor.java b/extensions/consul/deployment/src/main/java/org/apache/camel/quarkus/component/consul/deployment/ConsulProcessor.java new file mode 100644 index 0000000..131adba --- /dev/null +++ b/extensions/consul/deployment/src/main/java/org/apache/camel/quarkus/component/consul/deployment/ConsulProcessor.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.consul.deployment; + +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; + +class ConsulProcessor { + private static final String FEATURE = "camel-consul"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { + return new ExtensionSslNativeSupportBuildItem(FEATURE); + } + + @BuildStep + void reflectiveClasses(BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) { + reflectiveClasses.produce(new ReflectiveClassBuildItem( + true, + false, + "org.apache.camel.component.consul.ConsulConfiguration", + "org.apache.camel.component.consul.ConsulClientConfiguration", + "org.apache.camel.component.consul.health.ConsulHealthCheckRepositoryConfiguration", + "org.apache.camel.component.consul.cloud.ConsulServiceRegistryConfiguration")); + } +} diff --git a/extensions/support/httpcomponents/pom.xml b/extensions/consul/pom.xml similarity index 67% copy from extensions/support/httpcomponents/pom.xml copy to extensions/consul/pom.xml index 459d7ab..bc6c4d0 100644 --- a/extensions/support/httpcomponents/pom.xml +++ b/extensions/consul/pom.xml @@ -17,22 +17,23 @@ 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"> - +<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-support-extensions</artifactId> + <artifactId>camel-quarkus-build-parent</artifactId> <version>1.1.0-SNAPSHOT</version> + <relativePath>../../poms/build-parent/pom.xml</relativePath> </parent> - <modelVersion>4.0.0</modelVersion> - - <artifactId>camel-quarkus-support-httpcomponents</artifactId> - <name>Camel Quarkus :: Support :: Apache HTTP Components</name> + <artifactId>camel-quarkus-consul-parent</artifactId> + <name>Camel Quarkus :: Consul</name> <packaging>pom</packaging> <modules> - <module>httpclient</module> + <module>deployment</module> + <module>runtime</module> </modules> - </project> diff --git a/extensions/consul/runtime/pom.xml b/extensions/consul/runtime/pom.xml new file mode 100644 index 0000000..0a8e6b2 --- /dev/null +++ b/extensions/consul/runtime/pom.xml @@ -0,0 +1,90 @@ +<?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-consul-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <artifactId>camel-quarkus-consul</artifactId> + <name>Camel Quarkus :: Consul :: Runtime</name> + + <properties> + <firstVersion>1.0.0</firstVersion> + </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>io.quarkus</groupId> + <artifactId>quarkus-jackson</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-consul-client</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-consul</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> +</project> diff --git a/extensions/consul/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/consul/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..6e92278 --- /dev/null +++ b/extensions/consul/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,27 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +--- +name: "Camel Quarkus Consul" +description: "Camel Quarkus Consul" +metadata: + keywords: + - "camel" + - "consul" + guide: "https://quarkus.io/guides/camel" + categories: + - "integration" diff --git a/extensions/pom.xml b/extensions/pom.xml index 4e5d44b..aa6e18e 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -58,6 +58,7 @@ <module>base64</module> <module>bean</module> <module>bean-validator</module> + <module>consul</module> <module>controlbus</module> <module>csv</module> <module>dataformat</module> diff --git a/extensions/readme.adoc b/extensions/readme.adoc index b255b72..f8ca437 100644 --- a/extensions/readme.adoc +++ b/extensions/readme.adoc @@ -5,7 +5,7 @@ Apache Camel Quarkus supports the following Camel artifacts as Quarkus Extension == Camel Components // components: START -Number of Camel components: 56 in 48 JAR artifacts (0 deprecated) +Number of Camel components: 57 in 49 JAR artifacts (0 deprecated) [width="100%",cols="4,1,5",options="header"] |=== @@ -53,6 +53,9 @@ Number of Camel components: 56 in 48 JAR artifacts (0 deprecated) | link:https://camel.apache.org/components/latest/class-component.html[Class] (camel-quarkus-bean) + `class:beanName` | 0.2.0 | The class component is for invoking Java classes (Java beans) from Camel. +| link:https://camel.apache.org/components/latest/consul-component.html[Consul] (camel-quarkus-consul) + +`consul:apiEndpoint` | 1.0.0 | The camel consul component allows you to work with Consul, a distributed, highly available, datacenter-aware, service discovery and configuration system. + | link:https://camel.apache.org/components/latest/controlbus-component.html[Control Bus] (camel-quarkus-controlbus) + `controlbus:command:language` | 0.4.0 | The controlbus component provides easy management of Camel applications based on the Control Bus EIP pattern. diff --git a/extensions/support/consul-client/deployment/pom.xml b/extensions/support/consul-client/deployment/pom.xml new file mode 100644 index 0000000..e777273 --- /dev/null +++ b/extensions/support/consul-client/deployment/pom.xml @@ -0,0 +1,74 @@ +<?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.quarkus</groupId> + <artifactId>camel-quarkus-support-consul-client-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-quarkus-support-consul-client-deployment</artifactId> + <name>Camel Quarkus :: Support :: Consul Client :: Deployment</name> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-retrofit-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-consul-client</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <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/support/consul-client/deployment/src/main/java/org/apache/camel/quarkus/support/consul/client/deployment/ConsulClientSupportFeature.java b/extensions/support/consul-client/deployment/src/main/java/org/apache/camel/quarkus/support/consul/client/deployment/ConsulClientSupportFeature.java new file mode 100644 index 0000000..80f8d96 --- /dev/null +++ b/extensions/support/consul-client/deployment/src/main/java/org/apache/camel/quarkus/support/consul/client/deployment/ConsulClientSupportFeature.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.quarkus.support.consul.client.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +public class ConsulClientSupportFeature { + static final String FEATURE = "camel-support-consul-client"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } +} diff --git a/extensions/support/consul-client/deployment/src/main/java/org/apache/camel/quarkus/support/consul/client/deployment/ConsulClientSupportProcessor.java b/extensions/support/consul-client/deployment/src/main/java/org/apache/camel/quarkus/support/consul/client/deployment/ConsulClientSupportProcessor.java new file mode 100644 index 0000000..2864751 --- /dev/null +++ b/extensions/support/consul-client/deployment/src/main/java/org/apache/camel/quarkus/support/consul/client/deployment/ConsulClientSupportProcessor.java @@ -0,0 +1,80 @@ +/* + * 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.support.consul.client.deployment; + +import java.util.stream.Stream; + +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.AdditionalApplicationArchiveMarkerBuildItem; +import io.quarkus.deployment.builditem.CombinedIndexBuildItem; +import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyIgnoreWarningBuildItem; +import org.jboss.jandex.AnnotationInstance; +import org.jboss.jandex.AnnotationTarget; +import org.jboss.jandex.ClassInfo; +import org.jboss.jandex.DotName; + +class ConsulClientSupportProcessor { + private static final DotName DOT_NAME_JSON_SERIALIZER = DotName.createSimple( + "com.fasterxml.jackson.databind.annotation.JsonSerialize"); + private static final DotName DOT_NAME_JSON_DESERIALIZER = DotName.createSimple( + "com.fasterxml.jackson.databind.annotation.JsonDeserialize"); + private static final DotName DOT_NAME_IMMUTABLE_LIST = DotName.createSimple( + "com.google.common.collect.ImmutableList"); + private static final DotName DOT_NAME_IMMUTABLE_MAP = DotName.createSimple( + "com.google.common.collect.ImmutableMap"); + + @BuildStep + AdditionalApplicationArchiveMarkerBuildItem applicationArchiveMarkers() { + return new AdditionalApplicationArchiveMarkerBuildItem("com/orbitz/consul"); + } + + @BuildStep + void ignoredOnReflectiveHierarchyRegistration(BuildProducer<ReflectiveHierarchyIgnoreWarningBuildItem> ignored) { + ignored.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(DOT_NAME_IMMUTABLE_LIST)); + ignored.produce(new ReflectiveHierarchyIgnoreWarningBuildItem(DOT_NAME_IMMUTABLE_MAP)); + } + + @BuildStep + void reflectiveClasses(CombinedIndexBuildItem index, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses) { + Stream.concat( + index.getIndex().getAnnotations(DOT_NAME_JSON_SERIALIZER).stream(), + index.getIndex().getAnnotations(DOT_NAME_JSON_DESERIALIZER).stream()) + .distinct() + .map(AnnotationInstance::target) + .filter(item -> item.kind() == AnnotationTarget.Kind.CLASS) + .map(AnnotationTarget::asClass) + .filter(item -> item.name().prefix().toString().startsWith("com.orbitz.consul.model")) + .flatMap(item -> index.getIndex().getAllKnownSubclasses(item.name()).stream()) + .map(item -> new ReflectiveClassBuildItem(true, false, item.name().toString())) + .forEach(reflectiveClasses::produce); + } + + @BuildStep + void clientProxies(CombinedIndexBuildItem index, BuildProducer<NativeImageProxyDefinitionBuildItem> proxies) { + index.getIndex().getAllKnownSubclasses(DotName.createSimple("com.orbitz.consul.BaseClient")) + .stream() + .map(ClassInfo::name) + .map(DotName::toString) + .map(name -> name + "$Api") + .map(NativeImageProxyDefinitionBuildItem::new) + .forEach(proxies::produce); + } +} diff --git a/extensions/support/httpcomponents/pom.xml b/extensions/support/consul-client/pom.xml similarity index 79% copy from extensions/support/httpcomponents/pom.xml copy to extensions/support/consul-client/pom.xml index 459d7ab..3abd148 100644 --- a/extensions/support/httpcomponents/pom.xml +++ b/extensions/support/consul-client/pom.xml @@ -21,18 +21,20 @@ <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-support-extensions</artifactId> + <artifactId>camel-quarkus-build-parent</artifactId> <version>1.1.0-SNAPSHOT</version> + <relativePath>../../../poms/build-parent/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>camel-quarkus-support-httpcomponents</artifactId> - <name>Camel Quarkus :: Support :: Apache HTTP Components</name> + <artifactId>camel-quarkus-support-consul-client-parent</artifactId> + <name>Camel Quarkus :: Support :: Consul Client</name> <packaging>pom</packaging> <modules> - <module>httpclient</module> + <module>deployment</module> + <module>runtime</module> </modules> </project> diff --git a/extensions/support/consul-client/runtime/pom.xml b/extensions/support/consul-client/runtime/pom.xml new file mode 100644 index 0000000..e151c99 --- /dev/null +++ b/extensions/support/consul-client/runtime/pom.xml @@ -0,0 +1,100 @@ +<?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.quarkus</groupId> + <artifactId>camel-quarkus-support-consul-client-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-quarkus-support-consul-client</artifactId> + <name>Camel Quarkus :: Support :: Consul Client :: Runtime</name> + + <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>io.quarkus</groupId> + <artifactId>quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>com.orbitz.consul</groupId> + <artifactId>consul-client</artifactId> + <exclusions> + <exclusion> + <groupId>com.google.code.findbugs</groupId> + <artifactId>jsr305</artifactId> + </exclusion> + <exclusion> + <groupId>com.google.errorprone</groupId> + <artifactId>error_prone_annotations</artifactId> + </exclusion> + <exclusion> + <groupId>com.google.j2objc</groupId> + <artifactId>j2objc-annotations</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.mojo</groupId> + <artifactId>animal-sniffer-annotations</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-retrofit</artifactId> + </dependency> + <dependency> + <groupId>com.oracle.substratevm</groupId> + <artifactId>svm</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-bootstrap-maven-plugin</artifactId> + </plugin> + <plugin> + <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/support/consul-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/support/consul-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..9546ed7 --- /dev/null +++ b/extensions/support/consul-client/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,30 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +--- +name: "Camel Quarkus Support Consul Client" +description: "Camel Quarkus Consul Client" +metadata: + unlisted: true + keywords: + - "camel" + - "cloud" + - "consul" + guide: "https://quarkus.io/guides/camel" + categories: + - "integration" + diff --git a/extensions/support/pom.xml b/extensions/support/pom.xml index 68842de..bd690f8 100644 --- a/extensions/support/pom.xml +++ b/extensions/support/pom.xml @@ -36,8 +36,10 @@ <module>aws</module> <module>common</module> <module>commons-logging</module> + <module>consul-client</module> <module>httpclient</module> <module>jetty</module> + <module>retrofit</module> <module>spring</module> <module>xstream</module> <module>xml</module> diff --git a/extensions/support/retrofit/deployment/pom.xml b/extensions/support/retrofit/deployment/pom.xml new file mode 100644 index 0000000..e978e4d --- /dev/null +++ b/extensions/support/retrofit/deployment/pom.xml @@ -0,0 +1,74 @@ +<?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.quarkus</groupId> + <artifactId>camel-quarkus-support-retrofit-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-quarkus-support-retrofit-deployment</artifactId> + <name>Camel Quarkus :: Support :: Retrofit :: Deployment</name> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-kotlin-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-retrofit</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <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/support/retrofit/deployment/src/main/java/org/apache/camel/quarkus/support/retrofit/deployment/RetrofitSupportFeature.java b/extensions/support/retrofit/deployment/src/main/java/org/apache/camel/quarkus/support/retrofit/deployment/RetrofitSupportFeature.java new file mode 100644 index 0000000..ee41894 --- /dev/null +++ b/extensions/support/retrofit/deployment/src/main/java/org/apache/camel/quarkus/support/retrofit/deployment/RetrofitSupportFeature.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.quarkus.support.retrofit.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +public class RetrofitSupportFeature { + private static final String FEATURE = "camel-support-retrofit"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } +} diff --git a/extensions/support/httpcomponents/pom.xml b/extensions/support/retrofit/pom.xml similarity index 80% rename from extensions/support/httpcomponents/pom.xml rename to extensions/support/retrofit/pom.xml index 459d7ab..0a95cf2 100644 --- a/extensions/support/httpcomponents/pom.xml +++ b/extensions/support/retrofit/pom.xml @@ -21,18 +21,20 @@ <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-support-extensions</artifactId> + <artifactId>camel-quarkus-build-parent</artifactId> <version>1.1.0-SNAPSHOT</version> + <relativePath>../../../poms/build-parent/pom.xml</relativePath> </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>camel-quarkus-support-httpcomponents</artifactId> - <name>Camel Quarkus :: Support :: Apache HTTP Components</name> + <artifactId>camel-quarkus-support-retrofit-parent</artifactId> + <name>Camel Quarkus :: Support :: Retrofit</name> <packaging>pom</packaging> <modules> - <module>httpclient</module> + <module>deployment</module> + <module>runtime</module> </modules> </project> diff --git a/extensions/support/retrofit/runtime/pom.xml b/extensions/support/retrofit/runtime/pom.xml new file mode 100644 index 0000000..f590b75 --- /dev/null +++ b/extensions/support/retrofit/runtime/pom.xml @@ -0,0 +1,92 @@ +<?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.quarkus</groupId> + <artifactId>camel-quarkus-support-retrofit-parent</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-quarkus-support-retrofit</artifactId> + <name>Camel Quarkus :: Support :: Retrofit :: Runtime</name> + + <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>io.quarkus</groupId> + <artifactId>quarkus-core</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-kotlin</artifactId> + </dependency> + <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib</artifactId> + <exclusions> + <exclusion> + <groupId>org.jetbrains</groupId> + <artifactId>annotations</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>retrofit</artifactId> + </dependency> + <dependency> + <groupId>com.oracle.substratevm</groupId> + <artifactId>svm</artifactId> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-bootstrap-maven-plugin</artifactId> + </plugin> + <plugin> + <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/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/CompletableFutureCallAdapterFactorySubstitution.java b/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/CompletableFutureCallAdapterFactorySubstitution.java new file mode 100644 index 0000000..0a1ac3c --- /dev/null +++ b/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/CompletableFutureCallAdapterFactorySubstitution.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.support.retrofit.graal; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.TargetClass; +import retrofit2.CallAdapter; + +@TargetClass(className = "retrofit2.CompletableFutureCallAdapterFactory") +final class CompletableFutureCallAdapterFactorySubstitution { + @Alias + static CallAdapter.Factory INSTANCE; +} diff --git a/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/DefaultCallAdapterFactorySubstitution.java b/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/DefaultCallAdapterFactorySubstitution.java new file mode 100644 index 0000000..1ffd4eb --- /dev/null +++ b/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/DefaultCallAdapterFactorySubstitution.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.support.retrofit.graal; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.TargetClass; +import retrofit2.CallAdapter; + +@TargetClass(className = "retrofit2.DefaultCallAdapterFactory") +final class DefaultCallAdapterFactorySubstitution { + @Alias + static CallAdapter.Factory INSTANCE; +} diff --git a/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/ExecutorCallAdapterFactorySubstitution.java b/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/ExecutorCallAdapterFactorySubstitution.java new file mode 100644 index 0000000..537a48d --- /dev/null +++ b/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/ExecutorCallAdapterFactorySubstitution.java @@ -0,0 +1,36 @@ +/* + * 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.support.retrofit.graal; + +import java.util.concurrent.Executor; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.annotate.TargetElement; + +@TargetClass(className = "retrofit2.ExecutorCallAdapterFactory") +final class ExecutorCallAdapterFactorySubstitution { + @Alias + Executor callbackExecutor; + + @Substitute + @TargetElement(name = TargetElement.CONSTRUCTOR_NAME) + ExecutorCallAdapterFactorySubstitution(Executor callbackExecutor) { + this.callbackExecutor = callbackExecutor; + } +} diff --git a/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/OptionalConverterFactorySubstitution.java b/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/OptionalConverterFactorySubstitution.java new file mode 100644 index 0000000..14dc320 --- /dev/null +++ b/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/OptionalConverterFactorySubstitution.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.support.retrofit.graal; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.TargetClass; +import retrofit2.Converter; + +@TargetClass(className = "retrofit2.OptionalConverterFactory") +final class OptionalConverterFactorySubstitution { + @Alias + static Converter.Factory INSTANCE; +} diff --git a/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/PlatformSubstitution.java b/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/PlatformSubstitution.java new file mode 100644 index 0000000..4f0ae65 --- /dev/null +++ b/extensions/support/retrofit/runtime/src/main/java/org/apache/camel/quarkus/support/retrofit/graal/PlatformSubstitution.java @@ -0,0 +1,69 @@ +/* + * 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.support.retrofit.graal; + +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.Executor; + +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +@TargetClass(className = "retrofit2.Platform") +final class PlatformSubstitution { + @Substitute + static PlatformSubstitution get() { + return new PlatformSubstitution(); + } + + @Substitute + boolean isDefaultMethod(Method method) { + return method.isDefault(); + } + + @Substitute + Object invokeDefaultMethod(Method method, Class<?> declaringClass, Object object, Object... args) throws Throwable { + method.setAccessible(true); + return method.invoke(object, args); + } + + @Substitute + List<Object> defaultCallAdapterFactories(Executor callbackExecutor) { + return Arrays.asList( + CompletableFutureCallAdapterFactorySubstitution.INSTANCE, + callbackExecutor != null + ? new ExecutorCallAdapterFactorySubstitution(callbackExecutor) + : DefaultCallAdapterFactorySubstitution.INSTANCE); + } + + @Substitute + int defaultCallAdapterFactoriesSize() { + return 2; + } + + @Substitute + List<? extends retrofit2.Converter.Factory> defaultConverterFactories() { + return Collections.singletonList(OptionalConverterFactorySubstitution.INSTANCE); + } + + @Substitute + int defaultConverterFactoriesSize() { + return 1; + } +} diff --git a/extensions/support/retrofit/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/support/retrofit/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 0000000..0859941 --- /dev/null +++ b/extensions/support/retrofit/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -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. +# + +--- +name: "Camel Quarkus Support Retrofit" +description: "Camel Quarkus Support Retrofit" +metadata: + unlisted: true + keywords: + - "camel" + - "retrofit" + guide: "https://quarkus.io/guides/camel" + categories: + - "integration" + diff --git a/integration-tests/consul/pom.xml b/integration-tests/consul/pom.xml new file mode 100644 index 0000000..774cc2b --- /dev/null +++ b/integration-tests/consul/pom.xml @@ -0,0 +1,135 @@ +<?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-integration-tests</artifactId> + <version>1.1.0-SNAPSHOT</version> + </parent> + + <artifactId>camel-quarkus-integration-test-consul</artifactId> + <name>Camel Quarkus :: Integration Tests :: Consul</name> + <description>Integration tests for Camel Quarkus Consul extension</description> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-consul</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.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-testcontainers-support</artifactId> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>build</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <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> + <native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path> + </systemProperties> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-maven-plugin</artifactId> + <executions> + <execution> + <id>native-image</id> + <goals> + <goal>native-image</goal> + </goals> + <configuration> + <cleanupServer>true</cleanupServer> + <enableHttpsUrlHandler>true</enableHttpsUrlHandler> + <enableServer>false</enableServer> + <dumpProxies>false</dumpProxies> + <enableJni>true</enableJni> + <enableAllSecurityServices>true</enableAllSecurityServices> + <disableReports>true</disableReports> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> diff --git a/integration-tests/consul/src/main/java/org/apache/camel/quarkus/component/consul/it/ConsulResource.java b/integration-tests/consul/src/main/java/org/apache/camel/quarkus/component/consul/it/ConsulResource.java new file mode 100644 index 0000000..c11fa37 --- /dev/null +++ b/integration-tests/consul/src/main/java/org/apache/camel/quarkus/component/consul/it/ConsulResource.java @@ -0,0 +1,63 @@ +/* + * 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.consul.it; + +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.QueryParam; +import javax.ws.rs.core.MediaType; + +import org.apache.camel.FluentProducerTemplate; +import org.apache.camel.component.consul.ConsulConstants; +import org.apache.camel.component.consul.endpoint.ConsulKeyValueActions; + +import com.orbitz.consul.model.kv.ImmutableValue; + +@Path("/test/kv") +@ApplicationScoped +public class ConsulResource { + @Inject + FluentProducerTemplate producerTemplate; + + @GET + @Produces(MediaType.TEXT_PLAIN) + public String get(@QueryParam("key") String key) { + ImmutableValue result = producerTemplate + .withHeader(ConsulConstants.CONSUL_ACTION, ConsulKeyValueActions.GET_VALUE) + .withHeader(ConsulConstants.CONSUL_KEY, key) + .to("consul:kv?url={{camel.consul.test-url}}") + .request(ImmutableValue.class); + + return result.getValueAsString().orElseThrow(IllegalStateException::new); + } + + @POST + @Consumes(MediaType.TEXT_PLAIN) + public void post(@QueryParam("key") String key, String value) { + producerTemplate + .withHeader(ConsulConstants.CONSUL_ACTION, ConsulKeyValueActions.PUT) + .withHeader(ConsulConstants.CONSUL_KEY, key) + .withBody(value) + .to("consul:kv?url={{camel.consul.test-url}}") + .send(); + } +} diff --git a/integration-tests/consul/src/test/java/org/apache/camel/quarkus/component/consul/it/ConsulIT.java b/integration-tests/consul/src/test/java/org/apache/camel/quarkus/component/consul/it/ConsulIT.java new file mode 100644 index 0000000..38208f2 --- /dev/null +++ b/integration-tests/consul/src/test/java/org/apache/camel/quarkus/component/consul/it/ConsulIT.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.quarkus.component.consul.it; + +import io.quarkus.test.junit.NativeImageTest; + +@NativeImageTest +class ConsulIT extends ConsulTest { +} diff --git a/integration-tests/consul/src/test/java/org/apache/camel/quarkus/component/consul/it/ConsulTest.java b/integration-tests/consul/src/test/java/org/apache/camel/quarkus/component/consul/it/ConsulTest.java new file mode 100644 index 0000000..4e52a1e --- /dev/null +++ b/integration-tests/consul/src/test/java/org/apache/camel/quarkus/component/consul/it/ConsulTest.java @@ -0,0 +1,53 @@ +/* + * 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.consul.it; + +import java.util.UUID; + +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.core.Is.is; + +@QuarkusTest +@QuarkusTestResource(ConsulTestResource.class) +class ConsulTest { + @Test + public void basic() { + final String key = UUID.randomUUID().toString(); + final String value = UUID.randomUUID().toString(); + + RestAssured + .given() + .queryParam("key", key) + .body(value) + .when() + .post("/test/kv") + .then().statusCode(204); + + RestAssured + .given() + .queryParam("key", key) + .when() + .get("/test/kv") + .then() + .statusCode(200) + .body(is(value)); + } +} diff --git a/integration-tests/consul/src/test/java/org/apache/camel/quarkus/component/consul/it/ConsulTestResource.java b/integration-tests/consul/src/test/java/org/apache/camel/quarkus/component/consul/it/ConsulTestResource.java new file mode 100644 index 0000000..d746b9e --- /dev/null +++ b/integration-tests/consul/src/test/java/org/apache/camel/quarkus/component/consul/it/ConsulTestResource.java @@ -0,0 +1,69 @@ +/* + * 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.consul.it; + +import java.util.Map; + +import com.orbitz.consul.Consul; +import org.apache.camel.quarkus.testcontainers.ContainerResourceLifecycleManager; +import org.apache.camel.util.CollectionHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.utility.TestcontainersConfiguration; + +public class ConsulTestResource implements ContainerResourceLifecycleManager { + private static final Logger LOGGER = LoggerFactory.getLogger(ConsulTestResource.class); + private static final int CONTAINER_PORT = Consul.DEFAULT_HTTP_PORT; + private static final String CONTAINER_IMAGE = "consul:1.6"; + + private GenericContainer container; + + @Override + public Map<String, String> start() { + LOGGER.info(TestcontainersConfiguration.getInstance().toString()); + + try { + container = new GenericContainer(CONTAINER_IMAGE) + .withExposedPorts(CONTAINER_PORT) + .withCommand("agent", "-dev", "-server", "-bootstrap", "-client", "0.0.0.0", "-log-level", "trace") + .waitingFor(Wait.forLogMessage(".*Synced node info.*", 1)); + + container.start(); + + return CollectionHelper.mapOf( + "camel.consul.test-url", + String.format("http://%s:%d", + container.getContainerIpAddress(), + container.getMappedPort(CONTAINER_PORT))); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + @Override + public void stop() { + try { + if (container != null) { + container.stop(); + } + } catch (Exception e) { + // ignored + } + } +} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 125095f..217d8c6 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -161,6 +161,7 @@ <module>base64</module> <module>bean</module> <module>bean-validator</module> + <module>consul</module> <module>controlbus</module> <module>csv</module> <module>dataformat</module> diff --git a/pom.xml b/pom.xml index 4e0dde3..7390234 100644 --- a/pom.xml +++ b/pom.xml @@ -51,6 +51,8 @@ <xalan.version>2.7.2</xalan.version> <kotlin.version>1.3.21</kotlin.version> <spring.version>5.2.1.RELEASE</spring.version> + <retrofit.version>2.5.0</retrofit.version> + <consul-client.version>1.3.3</consul-client.version> <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version> <maven.compiler.target>1.8</maven.compiler.target> diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml index 6418d9b..f03beb3 100644 --- a/poms/bom-deployment/pom.xml +++ b/poms/bom-deployment/pom.xml @@ -136,6 +136,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-consul-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-controlbus-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> @@ -376,6 +381,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-consul-client-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-support-httpclient-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> @@ -386,6 +396,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-retrofit-deployment</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-support-spring-deployment</artifactId> <version>${camel-quarkus.version}</version> </dependency> diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml index 11aa045..38b02a0 100644 --- a/poms/bom/pom.xml +++ b/poms/bom/pom.xml @@ -158,6 +158,11 @@ </dependency> <dependency> <groupId>org.apache.camel</groupId> + <artifactId>camel-consul</artifactId> + <version>${camel.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> <artifactId>camel-controlbus</artifactId> <version>${camel.version}</version> </dependency> @@ -560,6 +565,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-consul</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-controlbus</artifactId> <version>${camel-quarkus.version}</version> </dependency> @@ -800,6 +810,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-consul-client</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-support-httpclient</artifactId> <version>${camel-quarkus.version}</version> </dependency> @@ -810,6 +825,11 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-support-retrofit</artifactId> + <version>${camel-quarkus.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-support-spring</artifactId> <version>${camel-quarkus.version}</version> </dependency> @@ -876,6 +896,21 @@ <version>${hapi.version}</version> </dependency> <dependency> + <groupId>com.orbitz.consul</groupId> + <artifactId>consul-client</artifactId> + <version>${consul-client.version}</version> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>converter-jackson</artifactId> + <version>${retrofit.version}</version> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>retrofit</artifactId> + <version>${retrofit.version}</version> + </dependency> + <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> <version>${xstream.version}</version> @@ -906,6 +941,11 @@ <version>${jetty.version}</version> </dependency> <dependency> + <groupId>org.jetbrains.kotlin</groupId> + <artifactId>kotlin-stdlib</artifactId> + <version>${kotlin.version}</version> + </dependency> + <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${spring.version}</version>