From 6b09b2beee782d340af4eddd62ea694dffa89a9a Mon Sep 17 00:00:00 2001 From: Ladislav Thon Date: Wed, 11 Oct 2023 16:06:18 +0200 Subject: [PATCH] Infinispan Client: add runtime SPI and deployment SPI modules Some constants from the Infinispan Client runtime module are moved to the runtime SPI module, so that they can be used from other modules that cannot directly depend on the Infinispan Client extension. Two build items, `InfinispanClientBuildItem` and `InfinispanClientNameBuildItem`, are moved from the Infinispan Client deployment module to the deployment SPI module. This is technically a breaking change, because they are also moved to a different package, but these build items don't seem to be used anywhere outside of Quarkus, so it should be safe. --- bom/application/pom.xml | 10 +++++ .../infinispan-client/deployment-spi/pom.xml | 44 +++++++++++++++++++ .../spi}/InfinispanClientBuildItem.java | 5 +-- .../spi}/InfinispanClientNameBuildItem.java | 2 +- .../infinispan-client/deployment/pom.xml | 4 ++ .../InfinispanBindingProcessor.java | 1 + .../deployment/InfinispanClientProcessor.java | 8 ++-- extensions/infinispan-client/pom.xml | 2 + .../infinispan-client/runtime-spi/pom.xml | 15 +++++++ .../runtime/spi/InfinispanConstants.java | 6 +++ extensions/infinispan-client/runtime/pom.xml | 8 ++-- .../client/runtime/InfinispanClientUtil.java | 6 ++- 12 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 extensions/infinispan-client/deployment-spi/pom.xml rename extensions/infinispan-client/{deployment/src/main/java/io/quarkus/infinispan/client/deployment => deployment-spi/src/main/java/io/quarkus/infinispan/client/deployment/spi}/InfinispanClientBuildItem.java (87%) rename extensions/infinispan-client/{deployment/src/main/java/io/quarkus/infinispan/client/deployment => deployment-spi/src/main/java/io/quarkus/infinispan/client/deployment/spi}/InfinispanClientNameBuildItem.java (88%) create mode 100644 extensions/infinispan-client/runtime-spi/pom.xml create mode 100644 extensions/infinispan-client/runtime-spi/src/main/java/io/quarkus/infinispan/client/runtime/spi/InfinispanConstants.java diff --git a/bom/application/pom.xml b/bom/application/pom.xml index c5fd6ad9c5a395..3474d103d52e63 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -1223,6 +1223,16 @@ quarkus-infinispan-client ${project.version} + + io.quarkus + quarkus-infinispan-client-runtime-spi + ${project.version} + + + io.quarkus + quarkus-infinispan-client-deployment-spi + ${project.version} + io.quarkus quarkus-infinispan-client-deployment diff --git a/extensions/infinispan-client/deployment-spi/pom.xml b/extensions/infinispan-client/deployment-spi/pom.xml new file mode 100644 index 00000000000000..63fa74e0f5c84e --- /dev/null +++ b/extensions/infinispan-client/deployment-spi/pom.xml @@ -0,0 +1,44 @@ + + + + quarkus-infinispan-client-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-infinispan-client-deployment-spi + Quarkus - Infinispan - Client - Deployment SPI + + + + io.quarkus + quarkus-infinispan-client-runtime-spi + + + io.quarkus + quarkus-core-deployment + + + org.infinispan + infinispan-client-hotrod-jakarta + + + org.infinispan + infinispan-jboss-marshalling + + + org.jboss.spec.javax.transaction + jboss-transaction-api_1.2_spec + + + io.netty + netty-transport-native-epoll + + + + + + diff --git a/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanClientBuildItem.java b/extensions/infinispan-client/deployment-spi/src/main/java/io/quarkus/infinispan/client/deployment/spi/InfinispanClientBuildItem.java similarity index 87% rename from extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanClientBuildItem.java rename to extensions/infinispan-client/deployment-spi/src/main/java/io/quarkus/infinispan/client/deployment/spi/InfinispanClientBuildItem.java index 13c0e8fb701673..ed658d82d79cc0 100644 --- a/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanClientBuildItem.java +++ b/extensions/infinispan-client/deployment-spi/src/main/java/io/quarkus/infinispan/client/deployment/spi/InfinispanClientBuildItem.java @@ -1,4 +1,4 @@ -package io.quarkus.infinispan.client.deployment; +package io.quarkus.infinispan.client.deployment.spi; import org.infinispan.client.hotrod.RemoteCacheManager; @@ -12,8 +12,7 @@ public final class InfinispanClientBuildItem extends MultiBuildItem { private final RuntimeValue client; private final String name; - public InfinispanClientBuildItem(RuntimeValue client, - String name) { + public InfinispanClientBuildItem(RuntimeValue client, String name) { this.client = client; this.name = name; } diff --git a/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanClientNameBuildItem.java b/extensions/infinispan-client/deployment-spi/src/main/java/io/quarkus/infinispan/client/deployment/spi/InfinispanClientNameBuildItem.java similarity index 88% rename from extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanClientNameBuildItem.java rename to extensions/infinispan-client/deployment-spi/src/main/java/io/quarkus/infinispan/client/deployment/spi/InfinispanClientNameBuildItem.java index 95481aa42144a5..64f10f004234fd 100644 --- a/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanClientNameBuildItem.java +++ b/extensions/infinispan-client/deployment-spi/src/main/java/io/quarkus/infinispan/client/deployment/spi/InfinispanClientNameBuildItem.java @@ -1,4 +1,4 @@ -package io.quarkus.infinispan.client.deployment; +package io.quarkus.infinispan.client.deployment.spi; import io.quarkus.builder.item.MultiBuildItem; diff --git a/extensions/infinispan-client/deployment/pom.xml b/extensions/infinispan-client/deployment/pom.xml index 163f3a0896b32b..e4aa11df67fa59 100644 --- a/extensions/infinispan-client/deployment/pom.xml +++ b/extensions/infinispan-client/deployment/pom.xml @@ -29,6 +29,10 @@ io.quarkus quarkus-infinispan-client + + io.quarkus + quarkus-infinispan-client-deployment-spi + io.quarkus quarkus-caffeine-deployment diff --git a/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanBindingProcessor.java b/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanBindingProcessor.java index 78b22f6058d7b8..3ecfe43a080da7 100644 --- a/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanBindingProcessor.java +++ b/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanBindingProcessor.java @@ -7,6 +7,7 @@ import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.infinispan.client.deployment.spi.InfinispanClientBuildItem; import io.quarkus.infinispan.client.runtime.InfinispanClientUtil; import io.quarkus.kubernetes.service.binding.spi.ServiceBindingQualifierBuildItem; diff --git a/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanClientProcessor.java b/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanClientProcessor.java index 58201a89f0b4fe..bebfff5f64fb1e 100644 --- a/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanClientProcessor.java +++ b/extensions/infinispan-client/deployment/src/main/java/io/quarkus/infinispan/client/deployment/InfinispanClientProcessor.java @@ -92,6 +92,8 @@ import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; import io.quarkus.infinispan.client.InfinispanClientName; import io.quarkus.infinispan.client.Remote; +import io.quarkus.infinispan.client.deployment.spi.InfinispanClientBuildItem; +import io.quarkus.infinispan.client.deployment.spi.InfinispanClientNameBuildItem; import io.quarkus.infinispan.client.runtime.InfinispanClientBuildTimeConfig; import io.quarkus.infinispan.client.runtime.InfinispanClientProducer; import io.quarkus.infinispan.client.runtime.InfinispanClientUtil; @@ -623,9 +625,9 @@ List infinispanClients(InfinispanRecorder recorder, List infinispanClientNames, // make sure all beans have been initialized @SuppressWarnings("unused") BeanContainerBuildItem beanContainer) { - List result = new ArrayList<>(infinispanClientNames.size()); - for (InfinispanClientNameBuildItem ic : infinispanClientNames) { - String name = ic.getName(); + Set names = infinispanClientNames.stream().map(icn -> icn.getName()).collect(Collectors.toSet()); + List result = new ArrayList<>(names.size()); + for (String name : names) { result.add(new InfinispanClientBuildItem(recorder.getClient(name), name)); } return result; diff --git a/extensions/infinispan-client/pom.xml b/extensions/infinispan-client/pom.xml index 098c9701f31260..4bcaaeebab1194 100644 --- a/extensions/infinispan-client/pom.xml +++ b/extensions/infinispan-client/pom.xml @@ -15,6 +15,8 @@ pom deployment + deployment-spi runtime + runtime-spi diff --git a/extensions/infinispan-client/runtime-spi/pom.xml b/extensions/infinispan-client/runtime-spi/pom.xml new file mode 100644 index 00000000000000..32c2c6571463b8 --- /dev/null +++ b/extensions/infinispan-client/runtime-spi/pom.xml @@ -0,0 +1,15 @@ + + + + quarkus-infinispan-client-parent + io.quarkus + 999-SNAPSHOT + + 4.0.0 + + quarkus-infinispan-client-runtime-spi + Quarkus - Infinispan - Client - Runtime SPI + + diff --git a/extensions/infinispan-client/runtime-spi/src/main/java/io/quarkus/infinispan/client/runtime/spi/InfinispanConstants.java b/extensions/infinispan-client/runtime-spi/src/main/java/io/quarkus/infinispan/client/runtime/spi/InfinispanConstants.java new file mode 100644 index 00000000000000..bb139bb217d05e --- /dev/null +++ b/extensions/infinispan-client/runtime-spi/src/main/java/io/quarkus/infinispan/client/runtime/spi/InfinispanConstants.java @@ -0,0 +1,6 @@ +package io.quarkus.infinispan.client.runtime.spi; + +public class InfinispanConstants { + public static final String DEFAULT_INFINISPAN_CLIENT_NAME = ""; + public static final String INFINISPAN_CLIENT_CONFIG_ROOT_NAME = "infinispan-client"; +} diff --git a/extensions/infinispan-client/runtime/pom.xml b/extensions/infinispan-client/runtime/pom.xml index a9ff61b97ae812..91440a2169ae3c 100644 --- a/extensions/infinispan-client/runtime/pom.xml +++ b/extensions/infinispan-client/runtime/pom.xml @@ -41,6 +41,10 @@ io.quarkus quarkus-elytron-security-common + + io.quarkus + quarkus-infinispan-client-runtime-spi + org.wildfly.security wildfly-elytron-sasl-plain @@ -75,9 +79,7 @@ org.jboss.spec.javax.transaction - - jboss-transaction-api_1.2_spec - + jboss-transaction-api_1.2_spec io.netty diff --git a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientUtil.java b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientUtil.java index 99c6b72c42c694..14d7496dd39ab6 100644 --- a/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientUtil.java +++ b/extensions/infinispan-client/runtime/src/main/java/io/quarkus/infinispan/client/runtime/InfinispanClientUtil.java @@ -3,11 +3,13 @@ import java.util.Collection; import java.util.List; +import io.quarkus.infinispan.client.runtime.spi.InfinispanConstants; + public final class InfinispanClientUtil { public static final String DEFAULT_INFINISPAN_DEV_SERVICE_NAME = "infinispan"; - public static final String DEFAULT_INFINISPAN_CLIENT_NAME = ""; - public static final String INFINISPAN_CLIENT_CONFIG_ROOT_NAME = "infinispan-client"; + public static final String DEFAULT_INFINISPAN_CLIENT_NAME = InfinispanConstants.DEFAULT_INFINISPAN_CLIENT_NAME; + public static final String INFINISPAN_CLIENT_CONFIG_ROOT_NAME = InfinispanConstants.INFINISPAN_CLIENT_CONFIG_ROOT_NAME; public static boolean isDefault(String infinispanClientName) { return DEFAULT_INFINISPAN_CLIENT_NAME.equals(infinispanClientName);